I did this but if i load dsr file with one primary weapon and no secondary it doesnt work. Can someone fix it?
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Addon;
namespace giveammo
{
public class Class1:CPlugin
{
public override void OnServerLoad()
{
ServerPrint("Ammo Plugin");
}
public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
{
if (Message.ToLower().StartsWith("!giveammo"))
{
string[] options = Message.Split(' ');
if (options.Length != 3)
{
TellClient(Client.ClientNum, " invalid values", true);
TellClient(Client.ClientNum, "!giveammo [playername] [ammo]", true);
}
else
{
string name = options[1];
string ammo = options[2];
if (name.ToLower() == "me")
{
Client.Ammo.PrimaryAmmo += Convert.ToInt32(ammo);
Client.Ammo.PrimaryAmmoClip += GetWeaponClipSize(Client.Other.PrimaryWeapon);
}
if (name.ToLower() == "all")
{
foreach (ServerClient client in GetClients())
{
Client.Ammo.PrimaryAmmo += Convert.ToInt32(ammo);
Client.Ammo.PrimaryAmmoClip += GetWeaponClipSize(Client.Other.PrimaryWeapon);
}
}
else
{
foreach (ServerClient client in GetClients())
{
if (client.Name.ToLower().Contains(name.ToLower()))
{
Client.Ammo.PrimaryAmmo += Convert.ToInt32(ammo);
Client.Ammo.PrimaryAmmoClip += GetWeaponClipSize(Client.Other.PrimaryWeapon);
}
}
}
}
return ChatType.ChatNone;
}
else
{
return ChatType.ChatContinue;
}
}
}
}