Entity::id: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
Line 1: Line 1:
{{SharedFunctionJS}}
This property is used for getting an entity ID. The ID is a unique identifier for the entity.
This property is used for getting an entity ID. The ID is a unique identifier for the entity.
'''NOTE:''' A server-side ID is NOT the same as a client-side ID. Use remoteID clientside if you want it to match the server-side ID.


==Getter==
==Getter==
* '''<span style="color:#008017>Number</span>'''
* {{RageType|Int}}


== Example ==
== Example ==
{{ServerSide}}
This event will log to the console the players name and the ID they have been assigned when joining the server.
<syntaxhighlight lang="javascript">
{{ServersideCode|
const playerID = mp.players.at(1).id;
<pre>
console.log(playerID); // Player ID, e.g. 1 ( ??? )
mp.events.add("playerJoin", (player) => {
</syntaxhighlight>
console.log(`${player.name} has joined. [${player.id}]`);
});
</pre>
}}


==See Also==
==See Also==
{{Entity_block}}
{{Entity_definition}}

Revision as of 01:28, 3 February 2019

Shared
Function

 JavaScript


This property is used for getting an entity ID. The ID is a unique identifier for the entity.

NOTE: A server-side ID is NOT the same as a client-side ID. Use remoteID clientside if you want it to match the server-side ID.

Getter

  • Int

Example

This event will log to the console the players name and the ID they have been assigned when joining the server.

Server-Side
mp.events.add("playerJoin", (player) => {
	console.log(`${player.name} has joined. [${player.id}]`);
});

See Also