I don't think I need to reset the count when people disconnect. It rather depends on how high you set the cvars.
You need to place this plugin's file name above admincmd.amxx in plugins.ini.
Code:
#include <amxmodx>
#pragma semicolon 1
#define SLAP 0
#define SLAY 1
#define KICK 2
#define BAN 3
new pcvars[4];
public plugin_init()
{
register_plugin("Command Limits", "1.0", "Lee");
register_clcmd("amx_slap", "cmdSlap", ADMIN_LEVEL_D);
register_clcmd("amx_slay", "cmdSlay", ADMIN_LEVEL_D);
register_clcmd("amx_kick", "cmdKick", ADMIN_LEVEL_D);
register_clcmd("amx_ban", "cmdBan", ADMIN_LEVEL_D);
pcvars[SLAP] = register_cvar("amx_slap_usage", "30");
pcvars[SLAY] = register_cvar("amx_slay_usage", "30");
pcvars[KICK] = register_cvar("amx_kick_usage", "30");
pcvars[BAN] = register_cvar("amx_ban_usage", "30");
}
public cmdSlap(playerID, accessLevel)
{
return get_user_flags(playerID) & accessLevel ? canUseCommand(playerID, SLAP) : PLUGIN_CONTINUE;
}
public cmdSlay(playerID, accessLevel)
{
return get_user_flags(playerID) & accessLevel ? canUseCommand(playerID, SLAY) : PLUGIN_CONTINUE;
}
public cmdKick(playerID, accessLevel)
{
return get_user_flags(playerID) & accessLevel ? canUseCommand(playerID, KICK) : PLUGIN_CONTINUE;
}
public cmdBan(playerID, accessLevel)
{
return get_user_flags(playerID) & accessLevel ? canUseCommand(playerID, BAN) : PLUGIN_CONTINUE;
}
canUseCommand(playerID, commandIssued)
{
static lastUseTime[33][4];
new currentTime = get_systime();
new nextUse = lastUseTime[playerID][commandIssued] - currentTime + get_pcvar_num(pcvars[commandIssued]);
if(nextUse > 0)
{
client_print(playerID, print_console, "Error: You cannot use this command for another %d second%s.",
nextUse, nextUse > 1 ? "s" : "");
return PLUGIN_HANDLED;
}
lastUseTime[playerID][commandIssued] = currentTime;
return PLUGIN_CONTINUE;
}