NetworkGetNetworkIdFromEntity
Docslocal retval = NetworkGetNetworkIdFromEntity(entity)Description
Get the network id of the given entity
An entity network id represents a given entity for other clients, it's a handle shared between clients, can be reconverted to a client entity handle.
These (entity network IDs) can and will be reused, 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.
Read more at Network and local IDs
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | the handle of the entity from which the network id should be taken |
Quick Snippet: Get Entityentity
entityUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
intReturns an integer value.
Examples
Official
local obj = CreateObject(`prop_weed_01`, vector3(0.0, 0.0, 0.0), true)
local netId = NetworkGetNetworkIdFromEntity(obj)