Timer Help - 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: Timer Help (
/showthread.php?tid=84499)
Timer Help -
FreeSoul - 01.07.2009
Sorry if this is the wrong section.
I really have problems using timers,I don't really know how to make a timer like,for an object,a command,I saw some examples and I could copy them but this won't make me understand them.
So,can somebody help me with timers? I would be very grateful,like timers for commands,for object,who knows for vehicles,textdraws.
Thanks in advance,I appreciate any help
Have a nice day/night
Re: Timer Help -
Abernethy - 01.07.2009
pawn Код:
// Top of script
forward Timer();
// Bottom of script.
public Timer()
{
//effect
}
// Somewhere else.
SetTimer("Timer", /*SECONDS_IN_MILLISECONDS*/, /*TRUE=REPEATING - 1, FALSE=NON_REPEATING - 0*/);
Re: Timer Help -
refshal - 01.07.2009
https://sampwiki.blast.hk/wiki/Scripting...29_RU#SetTimer
https://sampwiki.blast.hk/wiki/Scripting..._RU#SetTimerEx
https://sampwiki.blast.hk/wiki/Scripting...9_RU#KillTimer
I don't know why it's in Russian.
You can create a Timer with this:
and
Re: Timer Help -
Djiango - 01.07.2009
Becuase you're linking to the russian examples.
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/KillTimer
Re: Timer Help -
FreeSoul - 01.07.2009
Ok thanks
But how can I make a timer for a command? like the command should only be available if the timer passed.
Like player does something like /gotolasventuras and he can do it again after lets say 1 minute has passed
Re: Timer Help -
Ignas1337 - 01.07.2009
it can be done with a variable.
pawn Код:
//On top of script
new CommandUsed[MAX_PLAYERS];
// command
if(strcmp(...)==0)
{
if(CommandUsed[playerid] == -1) return SendClientMessage(... /* command was used before, pleae wait this and that */);
//do command here
CommandUsed[playerid] = -1;
SetTimerEx("ResetCmd", 5000 /*5 seconds*/, 0 /* not repeating*/, "i", playerid /* this sets the first parameter of ResetCmd(i) to be playerid);
}
//ResetCmd(i)
{
CommandUsed[i] = 0;
}
sorry it's messy but if you edit it properly it hsould work. this is just the principle how it should be like