[Include] y_timers - Simple timer creation and load balancing.
#15

Quote:
Originally Posted by Dodo9655
Посмотреть сообщение
What is the correct way of checking that a timer is active?

After doing
Код:
Player[playerid][LoginTimer] = defer OnLoginTimeout(playerid);
Would the following be correct?
Код:
if (Player[playerid][LoginTimer])
{
	// Timer active
}
else
{
	// Timer not active
}
Also when I want to kill the timer:
Код:
stop Player[playerid][LoginTimer]; // is this enough?
Player[playerid][LoginTimer] = 0; // or do I also have to do this?
In the first place, excuse me for bumping this thread! As I'm working with y_timers right now, let me answer this question for the next generation:
PHP код:
/* Set all cells to -1 */
new Timer:myTimer[MAX_PLAYERS] = {Timer:-1, ...};
/* Start the timer */
CMD:mycommand(playeridparams[])
{
    
myTimer[playerid] = repeat MyOwnFunction(playerid);
    
/* MyOwnFunction will be called 1 second after we type the
    command, due the delay parameter from timer, that's how it works. */
    
return 1;
}
/* Declare MyOwnFunction as a timer */
timer MyOwnFunction[1000](playerid)
{
    
printf("The player who started timer %d has the ID %d."_:myTimer[playerid], playerid);
    
// This function will print the same message every second.
}
/* Stop the timer */
COMMAND:stoptimer(playeridparams[])
{
    if(
myTimer[playerid] != Timer:-1)
    {
        
stop myTimer[playerid];
        
myTimer[playerid] = Timer:-1;
    }
    else
    {
        
// The timer isn't running.
    
}
    return 
1;

Reply


Messages In This Thread
y_timers - Simple timer creation and load balancing. - by corne - 15.04.2015, 18:38
Re: y_timers - Simple timer creation and load balancing. - by iSkyline - 18.04.2015, 07:29
Re: y_timers - Simple timer creation and load balancing. - by dusk - 13.05.2015, 16:37
Re: y_timers - Simple timer creation and load balancing. - by Misiur - 14.05.2015, 16:45
Re: y_timers - Simple timer creation and load balancing. - by Patchwerk - 14.05.2015, 16:51
Re: y_timers - Simple timer creation and load balancing. - by Finn707 - 14.05.2015, 20:34
Re: y_timers - Simple timer creation and load balancing. - by Misiur - 15.05.2015, 09:16
Re: y_timers - Simple timer creation and load balancing. - by dusk - 20.05.2015, 18:56
Respuesta: y_timers - Simple timer creation and load balancing. - by Adoniiz - 31.05.2015, 23:23
Re: Respuesta: y_timers - Simple timer creation and load balancing. - by dusk - 01.06.2015, 16:32
Respuesta: Re: Respuesta: y_timers - Simple timer creation and load balancing. - by Adoniiz - 02.06.2015, 02:44
Re: y_timers - Simple timer creation and load balancing. - by andyandyy8 - 24.06.2015, 11:32
Re: y_timers - Simple timer creation and load balancing. - by andyandyy8 - 24.06.2015, 12:50
Re: y_timers - Simple timer creation and load balancing. - by Dodo9655 - 16.09.2016, 10:52
Re: y_timers - Simple timer creation and load balancing. - by RIDE2DAY - 19.12.2016, 17:15
Re: y_timers - Simple timer creation and load balancing. - by Crayder - 14.02.2017, 17:02
Re: y_timers - Simple timer creation and load balancing. - by Hansrutger - 22.06.2017, 16:51
Re: y_timers - Simple timer creation and load balancing. - by Chaprnks - 04.07.2017, 10:30
Re: y_timers - Simple timer creation and load balancing. - by wallee - 20.07.2017, 16:13
Re: y_timers - Simple timer creation and load balancing. - by Misiur - 20.07.2017, 16:19
Re: y_timers - Simple timer creation and load balancing. - by Dayrion - 20.07.2017, 23:54

Forum Jump:


Users browsing this thread: 1 Guest(s)