29.04.2010, 12:52
how to make a command available only 1 time per minute.
/kill
/kill
#define CMD_VAR "cmdVar"
#define CMD_DELAY (60)
forward myTimer();
/* Use it under OnFilterScriptInit() if you want to use it as a filterscript or under OnGameModeInit() if you want to use it as a gamemode. */
SetTimer("myTimer", 1000, true);
public myTimer()
{
foreach(Player, u)
{
if(GetPVarInt(u, CMD_VAR) > 0) SetPVarInt(u, CMD_VAR, GetPVarInt(u, CMD_VAR) - 1);
}
return true;
}
command(kill, playerid, params[])
{
#pragma unused params
if(GetPVarInt(playerid, CMD_VAR) == 0)
{
SetPlayerHealth(playerid, 0);
SetPVarInt(playerid, CMD_VAR, CMD_DELAY);
}
else
{
new
arr[64];
format(arr, sizeof(arr), "SERVER: You'll have to wait %i more seconds to use this command.", GetPVarInt(playerid, CMD_VAR));
SendClientMessage(playerid, 0xFFFFFFFF, arr);
}
return true;
}