Every

From GT-MP
Jump to: navigation, search
Every
Client-Side Function
System-users.png Client-Side Javascript.png JavaScript

Executes given function after given amount of time in milliseconds and repeats it until stopped.

See also: after, stop

Syntax

API.every(uint time, string functionName, Object ...arguments);

Required Arguments

  • time: time in milliseconds in uint type.
  • functionName: name of function in string type.

Optional Arguments

  • arguments: parameter input should be in bool type.

NOTE: This function returns the timer-id in uint type. 1 or higher if successfull, 0 otherwise.

Usage example(s)

Start repeating timer

API.onResourceStart.connect(function() {
    var id1 = API.every(5000, "repeatNoParams");
    var id2 = API.every(10000, "repeatWithParams", true, 1);
});

function repeatNoParams() {
    API.sendNotification("1 done");
}
function repeatWithParams(first, second) {
    API.sendNotification("2 done: " + first + " - " + second);
}

Changelog

Version Description
1.638.634 Release.

References