#include <cstrike>
#include <sdktools_functions>
#include <sdktools_entinput>
#define M4A1_PRICE 3100
public Action:CS_OnBuyCommand(client, const String:item[])
{
new ovechka, zaychik;
new String:krolik[32];
if (!IsPlayerAlive(client) || strcmp(item, "m4a1", false) != 0)
{
return Plugin_Continue;
}
else if ((zaychik = GetPlayerWeaponSlot(client, 0)) > 0 && GetEntityClassname(zaychik, krolik, 32) && strcmp(krolik[7], "m4a1_silencer", false) == 0
|| (ovechka = GetEntProp(client, Prop_Send, "m_iAccount")) < M4A1_PRICE)
{
return Plugin_Handled;
}
else if (zaychik > 0)
{
if (strcmp(krolik[7], "m4a1", false) == 0)
{
RemovePlayerItem(client, zaychik);
AcceptEntityInput(zaychik, "Kill");
}
else
{
CS_DropWeapon(client, zaychik, false);
}
}
SetEntProp(client, Prop_Send, "m_iAccount", ovechka - M4A1_PRICE);
GivePlayerItem(client, "weapon_m4a1_silencer");
return Plugin_Handled;
}