SetEntityAsMissionEntity
DocsSetEntityAsMissionEntity(entity, scriptHostObject, bGrabFromOtherScript)Description
Assigns an existing entity to be owned by the current script. If the entity was not owned by a script yet, this also means the entity will remain persistent until released.
Note that this is not needed right after creating an entity as a script-created entity will automatically be assigned.
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | An entity handle. |
scriptHostObject | BOOL | Whether or not to assign script info to this entity, if set to false the entity will only be protected from despawning locally. |
bGrabFromOtherScript | BOOL | Changes the entity so it's owned by the current script if the entity is already a mission entity. This will only work on entities the machine has control of (non-remote entities). |
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
voidThis native does not return a value.