SA-MP Forums Archive
Timer question - 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: Timer question (/showthread.php?tid=512084)



Timer question - Xenforox - 08.05.2014

Hello, is there a way to detect if a timer still running ?


Re: Timer question - Beckett - 08.05.2014

Yes, set a variable, when the timer starts, assign the variable as 1 as simple as that, if you didn't get it I'll write you an example.


Re: Timer question - Xenforox - 08.05.2014

Hey danice, i'll be gratefull if you give me an example.


Re: Timer question - terrow - 08.05.2014

Danice for a good explanation give them a example i'll give you the example
:
pawn Код:
forward MyTimer();
new MyVariable[MAX_PLAYERS]; // let's create the function

public MyTimer()
{
    MyVariable[playerid] = 1;
    return 1;
}

// To use the timer
SetTimer("MyTimer", time, false / true);

// Now let's verify if the variable is 1
if(MyVariable[playerid] == 1)
{
    // doo something here //
   return 1;
}
This is just a example i hope i helped you!
REGARDS!~~


Re: Timer question - Beckett - 08.05.2014

pawn Код:
forward MyTimer();
new MyVariable = 0; // let's create the function

public MyTimer()
{
    MyVariable= 1;
    return 1;
}

// To use the timer
SetTimer("MyTimer", time, false / true);

// Now let's verify if the variable is 1
if(MyVariable == 1)
{
    // doo something here //
   return 1;
}
It shouldn't be MAX_PLAYERS since it's a timer not a player, and it's only one timer, not 1 timer for each player, however your example overall is right.