There are various kinds of identifiers and handles used across FiveM.
Client-side: Server ID
Server-side: ‘NetID’, player source, Player
The server ID, canonically known as the NetID, is a transient handle that is usually seen in server scripts as source.
To convert between a player index on the client and a server index, use GET_PLAYER_FROM_SERVER_ID and GET_PLAYER_SERVER_ID on the client.
Client-side: Player Server-side: Non-existent. Use server IDs.
The player index is used on the client to refer to a player. It is usually a number from 0 to 128 (inclusive).
Note that a player existent on the server does not necessarily exist on the client as well: GET_PLAYER_FROM_SERVER_ID can return -1 if this is the case.
Client-side: Ped Server-side: Ped
A player will usually have a ped representing the physical entity making up the player’s character.
To get a player’s ped, use GET_PLAYER_PED, and to get the player belonging to a ped handle, use NETWORK_GET_PLAYER_INDEX_FROM_PED.
Both sides: Entity, subclasses such as Ped, Object, Vehicle Server-side: Only available if state awareness is not disabled
An entity handle refers to the internal game representation of the entity, and is local to a specific client. This means you cannot expect the same entity to have the same handle on different clients.
Entity handles do not tend to be reused for different entities, however the same entity - if recreated locally or remotely - may get a different handle.
To convert from an entity handle to a network ID and back, use NETWORK_GET_NETWORK_ID_FROM_ENTITY and NETWORK_GET_ENTITY_FROM_NETWORK_ID.
Both sides: network ID Server-side: Can be round-tripped, but with state awareness disabled is meaningless on the server
An entity network ID is a 16-bit integer representing a given entity. These can and will be reused, but during the lifetime of an entity, the network ID will not change.
If you need to refer to an entity across machines (clients, or the server), you should use its network ID.
Note that just like with players, a network ID is not necessarily in scope on a client: verify its existence using NETWORK_DOES_ENTITY_EXIST_WITH_NETWORK_ID before using it.