About y_timers
#3

Read through this! This was posted by RIDE2DAY on the y_timers thread. This might help

Код:
/* Set all cells to -1 */ 
new Timer:myTimer[MAX_PLAYERS] = {Timer:-1, ...}; 

/* Start the timer */ 
CMD:mycommand(playerid, params[]) 
{ 
    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(playerid, params[]) 
{ 
    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
About y_timers - by sams90 - 23.04.2017, 12:22
Re: About y_timers - by JessThompson - 24.04.2017, 06:33
Re: About y_timers - by JessThompson - 24.04.2017, 06:36
Re: About y_timers - by sams90 - 24.04.2017, 06:41
Re: About y_timers - by JessThompson - 24.04.2017, 06:49
Re: About y_timers - by sams90 - 24.04.2017, 07:07

Forum Jump:


Users browsing this thread: 1 Guest(s)