OnClientReady

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

This event is triggered when after the player is successfully connected to the server, everything is downloaded and all clientside scripts are started. This is the FIRST place where you can work with API.getLocalPlayer() and Cameras and stuff. (The Serverside pendant for this is onPlayerFinishedDownload) The usage of player/game related API-Calls in onResourceStart can lead to unexpected behavior (or just be ignored), as the client is not fully initialized yet when the scripts are starting. onResourceStart should only be used to initialize Cef-Browsers and other stuff needed for the resource that is not Game-related. This does not apply to resources that are started after the player is connected to the server via API.startResource().

Dialog-warning.png Note: This feature is currently not in the API, or is currently not accurate on the wiki due to upcoming API changes. New API functions and changes will be released with the next update.

Syntax

In Javascript
Client-Side Function

API.onClientReady.connect(function() => {
    // do stuff
});

Usage example(s)

In Javascript
Client-Side Function

API.onClientReady.connect(function() => {
    // do stuff
});

References