natives.hasScriptLoaded

From GTA Connected
Revision as of 16:45, 28 November 2025 by ChrisGame20 (talk | contribs) (Created page with "{{ScriptItem |endpoint = client |games = iv |type = function |name = natives.hasScriptLoaded |parameters = string scriptName |parameter1 = string scriptName Name of the script to check |usage = Checks if a requested script has finished loading into memory |notes = - Returns true if the script is loaded and ready to start - Must be used after natives.requestScript to confirm the script is available - Useful to avoid errors when calling natives.startNewScript |ret...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.