Timer - 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 (
/showthread.php?tid=112054)
Timer -
jaksimaksi - 05.12.2009
Hi. i'm creating /weapons command. When round starts 30 sec this command gona work, after 30sec gona dont work
But i've have some problems, the /weapons command is working all time -.-
Can somebody help me?
This is my code:
Код:
new canuseguns;
----------------------------
if (strcmp("/weapons", cmdtext, true, 10) == 0)
{
if ( canuseguns == 1 ) ResetPlayerWeapons(playerid), ShowMenuForPlayer(WEAP1, playerid);
return 1;
}
-----------------------
canuseguns = 1;
SetTimer("canuseguns = 0;",10000,false);
Re: Timer -
V1ceC1ty - 05.12.2009
For starters 30 seconds is 30000, 1 second = 1000.
What exactly do you want the command to do? Reset their weapons and show a menu?
Re: Timer -
jaksimaksi - 05.12.2009
Quote:
Originally Posted by V1ceC1ty
For starters 30 seconds is 30000, 1 second = 1000.
What exactly do you want the command to do? Reset their weapons and show a menu?
|
Yes, i'm making this command, for starting round and when you select guns from menu, you can change it on 30sec
I want that /weapons command show menu, but when 30 sec going out, /weapons command doesn't work.
So i want that /weapons command don't work any more after 30sec
Re: Timer -
jaksimaksi - 06.12.2009
Can someone help? -_-
Re: Timer -
Balon - 06.12.2009
You use timers in wrong way.
https://sampwiki.blast.hk/wiki/SetTimer
Re: Timer -
Donny_k - 06.12.2009
pawn Код:
//tos
new
gRoundStartTime = 0;
//round starts
gRoundStartTimer = gettime();
//weapon command
if ( ( gettime() - gRoundStartTime ) < 30 )
{
//give weapon or whatever the command does
}
else
{
//30 seconds has passed deny them the weapon (message or whatever)
}
No need for a timer as the round start time never changes, only the time they used the command does so we only need to check the period from the start to the current and react accordingly to it.