How to activate a timer
#4

Quote:
Originally Posted by Calinut200
View Post
How to activate a timer like that only if a variable is 1;
PHP Code:
ptask name[1000](playerid
{
    
// my code

This is the timer from YNI includes, i wanna work only work if a variable test[playerid] = 1;
how to make that? I don't wanna to work in background each second and do nothing
You could create a player timer then.
PHP Code:
new Timer:mytimer[MAX_PLAYERS] = {Timer:-1, ...}; 
In your function, where you set that variable to 1 you should set the timer also.
PHP Code:
if(MyVariable[playerid] == 1)
    
mytimer[playerid] = repeat MyFunction(playerid); 
OnPlayerDisconnect, or when you put that variable on 0:
PHP Code:
if(mytimer[playerid] != Timer:-1)
{
    
stop mytimer[playerid];
    
mytimer[playerid] = Timer:-1;

Reply


Messages In This Thread
How to activate a timer - by Calinut200 - 28.05.2020, 13:24
Re: How to activate a timer - by hopeonxanny - 28.05.2020, 13:52
Re: How to activate a timer - by jasperschellekens - 28.05.2020, 14:00
Re: How to activate a timer - by SharpenBlade - 28.05.2020, 14:23

Forum Jump:


Users browsing this thread: 3 Guest(s)