[HELP] A timer on a command(triggered, whatever) + find command
#1

Hello,

I'm trying to find a way how to add a timer on my command. It can't really find a function to add the time check to the command. (e.g you type /taxi then you'll have to wait 30 seconds before using it again.)

This is my taxi command(clean):
Код:
if(strcmp(cmd, "/taxi", true) == 0)
{
               if(IsPlayerConnected(playerid)) {
                 format(string, sizeof(string), "%s(%i) is looking for a Taxi at %s to pick him up.", playername, playerid);
                 SendClientMessageToAll(COLOR_ORANGE, string);
               return 1;
     } else {
               return 1;
     }
}
And I'm trying to find a way to make a command /find. It's supposed to show you where the player is located at(cordinates).
e.g /find Biesmen
Message:"Biesmen is located at x=blabla, z=blabla, y=blabla".

Thank you.
Reply
#2

For the timer command, you could do something like this:
pawn Код:
new TaxiSpam[MAX_PLAYERS];
forward ResetTaxiSpam(playerid);
public ResetTaxiSpam(playerid)
{
     return TaxiSpam[playerid] = 0;
}

OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/taxi", true) == 0)
{
     if(IsPlayerConnected(playerid))
     {
          if(TaxiSpam[playerid] == 0)
          {
                 format(string, sizeof(string), "%s(%i) is looking for a Taxi at %s to pick him up.", playername, playerid);
                 SendClientMessageToAll(COLOR_ORANGE, string);
                 TaxiSpam[playerid] = 1;
                 SetTimerEx("ResetTaxiSpam", 120000, 0, "i", playerid);
                 return 1;
          }
          else
          {
               SendClientMessage(playerid, COLOR_RED, "You must wait 30 seconds before using this command again");
          }
          return 1;
     }
}
Reply
#3

I think you mean

Код:
forward ResetTaxiSpam(playerid);

public ResetTaxiSpam(playerid)
{     
return TaxiSpam[playerid] = 0;
}
Or else it won't work, ofcourse.

I'll test it in a few hours. Thank you
Reply
#4

Yes, thanks. Updated
Reply
#5

I use GetTickCount, timers can have quite a time offset.

http://pastebin.com/s5CD1rHk
Reply
#6

Edit: Nevermind, forgot you made it 2 minutes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)