I have a problem at this code..
Someone try this?
There are two problems:
1.) FCVAR_CLIENTCMD_CAN_EXECUTE prevented running command: buy
2.) The Drop Command Does not allow to drop the c4..
The reason why i blocked the drop command is that it has a glitch when blocking the weapons.. when you drop a weapon with an ammo.. the reserved ammo is gone..well its a nice way to hook it but.....
Code:
//File weaponremover.sp
#include <sourcemod>
#include <hooker>//Secksy
new bool:IsBuying[MAXPLAYERS+1];
new bool:IsEquipped[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "WeaponRemover",
author = "Francis",
description = "Duh",
version = "1.0",
url = "http://www.sourcemod.net"
}
public OnPluginStart()
{
RegConsoleCmd("drop", DropCommand);
RegConsoleCmd("buy", Buy);
RegConsoleCmd("autobuy", Buy);
RegConsoleCmd("rebuy", Buy);
RegisterHook(HK_WeaponDrop, WeaponDrop, false);
RegisterHook(HK_WeaponCanSwitchTo, WeaponSwitchFunction, false);
}
public Action:WeaponSwitchFunction(client, weapon)
{
decl String:cls[64];
GetEdictClassname(weapon, cls, sizeof(cls));
if(StrEqual(cls, "weapon_c4"))
{
IsEquipped[client] = true;
}
else if(!StrEqual(cls, "weapon_c4"))//double check
{
IsEquipped[client] = false;
}
}
public Action:DropCommand(client, args)
{
if(IsEquipped[client] == false)
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action:Buy(client,arg)
{
IsBuying[client] = true;
CreateTimer(0.1, IsBuyingDelay, client);
}
public Action:IsBuyingDelay(Handle:timer, any:client)
{
IsBuying[client] = false;
}
public Action:WeaponDrop(client, weapon)
{
decl String:WeaponName[64];
GetEdictClassname(weapon, WeaponName, sizeof(WeaponName));
if(StrContains(WeaponName, "weapon_c4") != -1)
{
return Plugin_Continue;
}
else if(IsBuying[client] == false)
{
return Plugin_Handled;
}
return Plugin_Continue;
}