Command timer
#4

pawn Код:
new CommandCheck[MAX_PLAYERS];
public ResetCommandCheck(playerid)
{
return CommandCheck[playerid] = 0;
}
    if(strcmp(cmd, "/askq", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /askq [text]");
                return 1;
            }
            if(CommandCheck[playerid] == 1)
            {
                return SendClientMessage(playerid, COLOR_WHITE, "You must wait 2 minutes before using this command again.");
            }
            format(string, sizeof(string), "Frage von %s: %s", sendername, (result));
            ABroadCast(COLOR_ASKQ,string,1);
            CommandCheck[playerid] = 1;
            SetTimerEx("ResetCommandCheck", 120000, 0, "i", playerid); // 120,000 MS = 2 minutes.
            SendClientMessage(playerid, COLOR_ASKQ, "Deine Frage wurde an alle Online Admins verschickt.");
      }
      return 1;
    }
You'll have to reset CommandCheck[playerid] to 0 when they disconnect etc.. The command bit needs to be under OnPlayerCommandText(), the "new CommandCheck" bit needs to be at the top where the other definitions are, and put the public anywhere that's not in another function/callback.
Reply


Messages In This Thread
Command timer - by DauerDicht - 12.09.2009, 22:55
Re: Command timer - by [HiC]TheKiller - 13.09.2009, 01:12
Re: Command timer - by DauerDicht - 13.09.2009, 11:17
Re: Command timer - by Calgon - 13.09.2009, 12:01

Forum Jump:


Users browsing this thread: 1 Guest(s)