command available
#1

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)