Thread: [Plugin] Timer Fix
View Single Post
Old 13/01/2020, 07:50 PM   #112
KashCherry
Big Clucker
 
KashCherry's Avatar
 
Join Date: Feb 2018
Location: Estonia
Posts: 60
Reputation: 30
Default Re: Timer Fix

Plugin updated to version 1.1.1

Fixed:
- Fixed the problem when timers just stopped.
- Fixed the problem when the callback was called after the timer was deleted.

Added:
- Now you can pause the timer and continue it in the future.
Example:
PHP Code:
#include <timerfix>

new timer[MAX_PLAYERS];

forward WhileNotInVehicle(playerid);
public 
WhileNotInVehicle(playerid)
{
    return 
1;
}

public 
OnPlayerSpawn(playerid)
{
    
timer[playerid] = SetTimerEx("WhileNotInVehicle"1000true"i"playerid);
}

public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    
PauseTimer(timer[playerid]);
}

public 
OnPlayerExitVehicle(playeridvehicleid)
{
    
ContinueTimer(timer[playerid]);

- You can add additional callbacks for one timer.
Example:
PHP Code:
#include <timerfix>

forward CallbackOne(number);
public 
CallbackOne(number)
{
    
printf("[CallbackOne] Number is %d"number);
}

forward CallbackTwo(number);
public 
CallbackTwo(number)
{
    
printf("[CallbackTwo] Number is %d"number);
}

public 
OnGameModeInit()
{
    new 
timer SetTimerEx("CallbackOne"1000false"i"727);
    
// The same arguments will be passed for both callbacks.
    
AddTimerHandler(timer"CallbackTwo");

- Also added the custom timers with count of executions and delay before the timer starts.
Example:
PHP Code:
#include <timerfix>

new timer;

forward CallbackOne(number);
public 
CallbackOne(number)
{
    
printf("[CallbackOne] Number is %d"number);
}

forward CallbackTwo(number);
public 
CallbackTwo(number)
{
    
printf("[CallbackTwo] Number is %d"number);
    
KillTimer(timer);
}

public 
OnGameModeInit()
{
    
// Set the count to -1 for infinite timer
    
timer SetCustomTimerEx("CallbackOne"10005005"i"800);
    
// The same arguments will be passed for both callbacks.
    
AddTimerHandler(timer"CallbackTwo");

Report about any bugs here please.
KashCherry is offline   Reply With Quote