natives.hasScriptLoaded
Jump to navigation
Jump to search
Function Client Only ![]()
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
- - 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.
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.