Entity::id: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 1: Line 1:
{{SharedFunctionJS}}
{{SharedPropertyJS}}
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.
{{Note|A server-side ID is NOT the same as a client-side ID. Use [[Pool::remoteId|remoteID]] clientside if you want it to match the server-side ID.}}


==Getter==
==Getter==
Line 8: Line 8:


== Example ==
== Example ==
This event will log to the console the players name and the ID they have been assigned when joining the server.
This event will log to the console the players name and the ID they have been assigned [[PlayerJoin|when joining the server]].
{{ServersideCode|
{{ServersideCode|
<pre>
<pre>
Line 19: Line 19:
==See Also==
==See Also==
{{Entity_definition}}
{{Entity_definition}}
[[Category:Entity API]]
[[Category:Shared Property]]

Revision as of 10:00, 30 April 2019

Shared
Property

 JavaScript

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

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