Command timer
#1

Hi, i want that the Command can be write all 2 Minutes.. but how?

Код:
	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;
			}
			format(string, sizeof(string), "Frage von %s: %s", sendername, (result));
			ABroadCast(COLOR_ASKQ,string,1);
			SendClientMessage(playerid, COLOR_ASKQ, "Deine Frage wurde an alle Online Admins verschickt.");
	  }
	  return 1;
	}
Reply
#2

Please explain a bit clearer. Do you want the command to work 2 minutes after you type it?
Reply
#3

Yes, and then it show a message like

"Please wait 2 minutes, then you can write the command again"


askq is a command for player who need support from admins.. but sometimes they spam it..
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)