Variable that goes down by 1 per second
#1

Hi I need a variable that goes down every second can someone please explain me it?
Reply
#2

Use a timer that repeats itself every 1 second and decreases the variable by 1...
Reply
#3

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...
Reply
#4

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;
}
Reply
#5

Thanks :D
Reply
#6

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)