SA-MP Forums Archive
command available - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: command available (/showthread.php?tid=144849)



command available - shoru93 - 29.04.2010

how to make a command available only 1 time per minute.
/kill


Re: command - Correlli - 29.04.2010

pawn Код:
#define CMD_VAR "cmdVar"
#define CMD_DELAY (60)
pawn Код:
forward myTimer();
pawn Код:
/* 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);
pawn Код:
public myTimer()
{
  foreach(Player, u)
  {
    if(GetPVarInt(u, CMD_VAR) > 0) SetPVarInt(u, CMD_VAR, GetPVarInt(u, CMD_VAR) - 1);
  }
  return true;
}
pawn Код:
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;
}
You'll need foreach function (******) and zcmd (Zeex).

This will work one time in minute (60 seconds) for every player.