SetTimerEx

From SA-MP Wiki

Jump to: navigation, search

SetTimerEx


Sets a timer to call a function after some time. This variant can pass parameters to the function.


Parameters:
(funcname[], interval, repeating, const format[], {Float,_}:...)
funcname[]Name of the function to call as a string. Needs to be a public!
intervalInverval in milliseconds.
repeatingBoolean if the timer should oocur repeatedly or only once
format[]Special format indicating the types of the variables following
{Float,_}:...Indefinite number of arguments to pass


Note: The function that should be called must be public. That means it has to be forwarded.


ReturnsThe ID of the timer created.


Format Strings

Placeholder Meaning
%b Inserts a number at this position in binary radix
%c Inserts a single character.
%d Inserts an integer (whole) number
%f Inserts a floating point number.
%i Inserts an integer.
%s Inserts a string.
%x Inserts a number in hexadecimal notation.
%% Inserts the literal '%'

The values for the placeholders follow in the exact same order as parameters in the call.

You may optionally put a number between the '%' and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces.

forward message(second, msg[]);
 
public OnGameModeInit()
{
    print("Starting timer...");
    SetTimerEx("message", 1000, false, "is", 1, "string to pass");
}
 
public message(second, msg[])
{
    printf("%i second has passed, also we have a %s.", second, msg);
    return 1;
}

Related Functions

The following functions might be useful as well, as they're related to this function in one way or another.