Variable that goes down by 1 per second - 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)
+--- Thread: Variable that goes down by 1 per second (
/showthread.php?tid=290628)
Variable that goes down by 1 per second -
CrazyShooterJoe - 16.10.2011
Hi I need a variable that goes down every second can someone please explain me it?
Re: Variable that goes down by 1 per second -
SchurmanCQC - 16.10.2011
Use a timer that repeats itself every 1 second and decreases the variable by 1...
Re: Variable that goes down by 1 per second -
CrazyShooterJoe - 16.10.2011
How do I do that, I'm guessing SetTimerEx but I never worked well with it.....
Like variable is JailTime[MAX_PLAYERS]
I want it decreased by 1 every second, so when it reaches 0 the guy is unjailed which I will script later...
Re: Variable that goes down by 1 per second -
Baboon - 16.10.2011
Use set timer.
Like:
New val;
SetTimer("decreaseval", 1000, true);
This will repeat every 1000 ms = 1 second.
forward decreaseval();
public decreaseval()
{
val--;
return 1;
}
Re: Variable that goes down by 1 per second -
CrazyShooterJoe - 16.10.2011
Thanks :D
Re: Variable that goes down by 1 per second -
DRIFT_HUNTER - 16.10.2011
well its easy to make variable goes -1 every x time
pawn Код:
new VariableTimer;
new Variable;
VariableTimer = SetTimer("LoverVariable", 1000, 1);
forward LoverVariable();
public LoverVariable()
{
Variable--;
if(Variable == 0) KillTimer(VariableTimer);
}
But we dont use auto unjail like that...
We just make a public function to unjail player and set timer to call that function just once...