SixL client API / game/script / GameScriptMp

Interface: GameScriptMp

The script and thread functions: whether a script exists or runs, and the thread iterator.

Remarks

Script names are hashed: a string is hashed to its 32-bit joaat, a number is taken as the hash already. Getters are asynchronous: they return a Promise.

Example

const running = await mp.game.script.doesScriptExist('freemode');

Methods

doesExist()

doesExist(scriptName): Promise<boolean>

The same check as doesScriptExist.

Parameters

scriptName

string | number

The script's name, or its hash.

Returns

Promise<boolean>

A Promise of true when the script exists.

Example

const exists = await mp.game.script.doesExist('freemode');

doesScriptExist()

doesScriptExist(scriptName): Promise<boolean>

Whether a script with this name exists in the game.

Parameters

scriptName

string | number

The script's name, or its hash.

Returns

Promise<boolean>

A Promise of true when the script exists.

Example

const exists = await mp.game.script.doesScriptExist('freemode');

doesWithNameHashExist()

doesWithNameHashExist(scriptHash): Promise<boolean>

Whether a script with this name hash exists.

Parameters

scriptHash

number

The script's hash, as a number.

Returns

Promise<boolean>

A Promise of true when the script exists.

Example

const exists = await mp.game.script.doesWithNameHashExist(hash);

getIdOfThisThread()

getIdOfThisThread(): Promise<number>

The id of the thread that runs this script.

Returns

Promise<number>

A Promise of the thread id.

Example

const id = await mp.game.script.getIdOfThisThread();

isThreadActive()

isThreadActive(threadId): Promise<boolean>

Whether a thread is active (it has not finished).

Parameters

threadId

number

The thread's id.

Returns

Promise<boolean>

A Promise of true while the thread runs.

Example

const active = await mp.game.script.isThreadActive(threadId);

setNoLoadingScreen()

setNoLoadingScreen(toggle): void

Turns the game's loading screen off or on for the next loads.

Parameters

toggle

boolean

true to skip the loading screen, false to show it.

Returns

void

Example

mp.game.script.setNoLoadingScreen(true);

setStreamedScriptAsNoLongerNeeded()

setStreamedScriptAsNoLongerNeeded(scriptHash): void

Marks a streamed script as no longer needed, so the game may unload it.

Parameters

scriptHash

number

The script's hash, as a number.

Returns

void

Example

mp.game.script.setStreamedScriptAsNoLongerNeeded(hash);

setWithNameHashAsNoLongerNeeded()

setWithNameHashAsNoLongerNeeded(scriptHash): void

The same as setStreamedScriptAsNoLongerNeeded.

Parameters

scriptHash

number

The script's hash, as a number.

Returns

void

Example

mp.game.script.setWithNameHashAsNoLongerNeeded(hash);

shutdownLoadingScreen()

shutdownLoadingScreen(): void

Shuts down the loading screen at once.

Returns

void

Example

mp.game.script.shutdownLoadingScreen();

threadIteratorGetNextThreadId()

threadIteratorGetNextThreadId(): Promise<number>

The next thread id of the iterator started by threadIteratorReset.

Returns

Promise<number>

A Promise of the next thread id from the iterator.

Example

mp.game.script.threadIteratorReset();
    const id = await mp.game.script.threadIteratorGetNextThreadId();

threadIteratorReset()

threadIteratorReset(): void

Restarts the thread iterator, so that threadIteratorGetNextThreadId lists the threads from the first.

Returns

void

Example

mp.game.script.threadIteratorReset();