[HELP] A timer on a command(triggered, whatever) + find command - 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: [HELP] A timer on a command(triggered, whatever) + find command (
/showthread.php?tid=181678)
[HELP] A timer on a command(triggered, whatever) + find command -
Biesmen - 06.10.2010
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.
Re: [HELP] A timer on a command(triggered, whatever) + find command -
randomkid88 - 06.10.2010
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;
}
}
Re: [HELP] A timer on a command(triggered, whatever) + find command -
Biesmen - 06.10.2010
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
Re: [HELP] A timer on a command(triggered, whatever) + find command -
randomkid88 - 07.10.2010
Yes, thanks. Updated
Re: [HELP] A timer on a command(triggered, whatever) + find command -
bigcomfycouch - 07.10.2010
I use GetTickCount, timers can have quite a time offset.
http://pastebin.com/s5CD1rHk
Re: [HELP] A timer on a command(triggered, whatever) + find command -
Biesmen - 07.10.2010
Edit: Nevermind, forgot you made it 2 minutes.