After

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

Executes given function after given amount of time in milliseconds.

See also: every, stop

Syntax

In Javascript
Client-Side Function

API.after(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)

Example displays how to start a timer with and without parameters.

In Javascript
Client-Side Function

API.onResourceStart.connect(function() {
    var id1 = API.after(5000, "noParameters");
    var id2 = API.after(10000, "withParameters", true, 1);
});

function noParameters() {
    API.sendNotification("noParameters done");
}
function withParameters(first, second) {
    API.sendNotification("withParameters done: " + first + " - " + second);
}

Changelog

Version Description
1.638.634 Release.

References