setTimeout
Jump to navigation
Jump to search
Function
Server and Client
Online and Offline
Available since Server 1.0.0, Client 1.0.0
Timer setTimeout(function callback, int durationMilliseconds, [ ... ])
The setTimeout function is used to add a timer with a callback function that is invoked once after the specified duration has passed.
Parameters
1) | int | durationMilliseconds | The duration, in milliseconds, before the scripting function is called. |
2) | function | callback | The scripting function to call when the interval has occurred. |
3) | vararg | ... | Optional, defaults to n/a. The arguments to send to the callback function. |
Return
Timer | A handle to the timer. |
Callbacks
function callback([...])
1) | ... | vararg | The arguments that were sent to the setTimeout function.
|
Notes
- GTA Connected guarantees that the timer will be triggered after at least the interval you specify. The resolution of the timer is tied to the frame rate (server side and client-side). All the overdue timers are triggered at a single point each frame. This means that if, for example, the player is running at 30 frames per second, then two timers specified to occur after 100ms and 110ms would more than likely occur during the same frame, as the difference in time between the two timers (10ms) is less than half the length of the frame (33ms). As with most timers provided by other languages, you shouldn't rely on the timer triggering at an exact point in the future.
Examples
There aren't any examples for this function.
Compatibility
There isn't any compatibility information for this function.
Related
Server Related
clearImmediate
clearInterval
clearTimeout
setImmediate
setInterval
setTimeout
Client Related
clearImmediate
clearInterval
clearTimeout
setImmediate
setInterval
setTimeout