natives.hasScriptLoaded

From GTA Connected
Jump to navigation Jump to search

Function Client Only icon-iv.png Online and Offline

Available since Client 1.0.0
bool natives.hasScriptLoaded(string scriptName)
The natives.hasScriptLoaded function is used to Checks if a requested script has finished loading into memory.

Parameters

1) string scriptName Name of the script to check.

Return

bool True if the script is loaded.

Notes

Examples

Example 1 - JavaScript:

bindEventHandler("OnResourceReady", thisResource, function() {
    // Request and check script
    natives.requestScript("trafficControl");
    if (natives.hasScriptLoaded("trafficControl")) {
        natives.startNewScript("trafficControl", 1024);
        console.log("trafficControl script started successfully.");
    } else {
        console.log("Script trafficControl is not yet loaded.");
    }
});

Compatibility

There isn't any compatibility information for this function.