SixL client API / game/network / GameNetworkMp
Interface: GameNetworkMp
The network session functions: the session clock, network ids of entities and the players of the session.
Remarks
Getters are asynchronous: they return a Promise. An entity is given as an entity object or as its handle.
Example
const ms = await mp.game.network.getTime();
Methods
canBail()
canBail():Promise<boolean>
Whether the session allows this script to stop right now.
Returns
Promise<boolean>
A Promise of true when the script may stop.
Example
const canStop = await mp.game.network.canBail();
getEntityIsNetworked()
getEntityIsNetworked(entity):Promise<boolean>
Whether an entity is registered with the network session (it has a network id).
Parameters
entity
number | { handle: number; }
The entity, or its handle.
Returns
Promise<boolean>
A Promise of true when the entity is networked.
Example
const networked = await mp.game.network.getEntityIsNetworked(vehicle);
getNetworkTime()
getNetworkTime():Promise<number>
The same clock as getTime.
Returns
Promise<number>
A Promise of the time in milliseconds since the session started.
Example
const ms = await mp.game.network.getNetworkTime();
getNetworkTimeAccurate()
getNetworkTimeAccurate():Promise<number>
The same clock as getTimeAccurate.
Returns
Promise<number>
A Promise of the time in milliseconds since the session started.
Example
const ms = await mp.game.network.getNetworkTimeAccurate();
getPlayerIndexFromPed()
getPlayerIndexFromPed(ped):Promise<number>
The index of the player who controls a ped.
Parameters
ped
number | { handle: number; }
The ped, or its handle.
Returns
Promise<number>
A Promise of the player index, 0 and up.
Example
const index = await mp.game.network.getPlayerIndexFromPed(ped);
getThisScriptIsNetworkScript()
getThisScriptIsNetworkScript():Promise<boolean>
Whether this script is a network script (one the session runs on every machine).
Returns
Promise<boolean>
A Promise of true for a network script.
Example
const isNetworkScript = await mp.game.network.getThisScriptIsNetworkScript();
getTime()
getTime():Promise<number>
The network session clock.
Returns
Promise<number>
A Promise of the time in milliseconds since the session started.
Example
const ms = await mp.game.network.getTime();
getTimeAccurate()
getTimeAccurate():Promise<number>
The network session clock, read with more precision than getTime.
Returns
Promise<number>
A Promise of the time in milliseconds since the session started.
Example
const ms = await mp.game.network.getTimeAccurate();
getTimeDifference()
getTimeDifference(timeA,timeB):Promise<number>
The difference between two network clock readings.
Parameters
timeA
number
The first time, in milliseconds.
timeB
number
The second time, in milliseconds.
Returns
Promise<number>
A Promise of timeA - timeB in milliseconds: negative when timeB is the later one.
Example
const elapsed = await mp.game.network.getTimeDifference(now, start);
hasControlOfNetworkId()
hasControlOfNetworkId(netId):Promise<boolean>
Whether this machine controls a networked entity right now.
Parameters
netId
number | { handle: number; }
The entity, or its handle.
Returns
Promise<boolean>
A Promise of true when this machine has control of the entity.
Example
const mine = await mp.game.network.hasControlOfNetworkId(vehicle);
isHostOfThisScript()
isHostOfThisScript():Promise<boolean>
Whether this machine is the host of the script.
Returns
Promise<boolean>
A Promise of true when this machine hosts the script.
Example
const isHost = await mp.game.network.isHostOfThisScript();
isPlayerActive()
isPlayerActive(player):Promise<boolean>
Whether a player index is an active player of the session.
Parameters
player
number
The player index, 0 and up.
Returns
Promise<boolean>
A Promise of true when the player is active.
Example
const active = await mp.game.network.isPlayerActive(0);
isPlayerAParticipant()
isPlayerAParticipant(player):Promise<boolean>
Whether a player index takes part in the session (a participant, not only connected).
Parameters
player
number
The player index, 0 and up.
Returns
Promise<boolean>
A Promise of true when the player is a participant.
Example
const participant = await mp.game.network.isPlayerAParticipant(0);
releaseAllCommerceItemImages()
releaseAllCommerceItemImages(): void
Releases the cached pictures of all commerce items (the store images).
Returns
void
Example
mp.game.network.releaseAllCommerceItemImages();
removeAllStickyBombsFromEntity()
removeAllStickyBombsFromEntity(entity,ped):void
Removes the sticky bombs that a ped has attached to an entity.
Parameters
entity
number | { handle: number; }
The entity, or its handle, the bombs are attached to.
ped
number | { handle: number; }
The ped, or its handle, who placed them.
Returns
void
Example
mp.game.network.removeAllStickyBombsFromEntity(vehicle, ped);
requestControlOfNetworkId()
requestControlOfNetworkId(netId):void
Asks for control of a networked entity. Nothing is returned: check hasControlOfNetworkId on the next frames.
Parameters
netId
number | { handle: number; }
The entity, or its handle, whose control is requested.
Returns
void
Example
mp.game.network.requestControlOfNetworkId(vehicle);
setIdExistsOnAllMachines()
setIdExistsOnAllMachines(netId,toggle):void
Makes a networked entity exist, or not, on every machine.
Parameters
netId
number | { handle: number; }
The entity, or its handle.
toggle
boolean
true to make the entity exist on all machines.
Returns
void
Example
mp.game.network.setIdExistsOnAllMachines(vehicle, true);
setScriptReadyForEvents()
setScriptReadyForEvents(toggle):void
Tells the network session whether this script is ready to receive network events.
Parameters
toggle
boolean
true when the script is ready, false when it is not.
Returns
void
Example
mp.game.network.setScriptReadyForEvents(true);
unregisterNetworkedEntity()
unregisterNetworkedEntity(entity):void
Removes an entity from the network session, so it is no longer synchronised.
Parameters
entity
number | { handle: number; }
The entity, or its handle.
Returns
void
Example
mp.game.network.unregisterNetworkedEntity(vehicle);