IsEntityOnScreen
Docslocal retval = IsEntityOnScreen(entity)Description
Determines whether the screen position of the specified entity is within the 2D bounds of the screen.
This native will not check if the entity is not visible due to being occluded (for example, behind a wall). To check if a entity is on screen and is not occluded, use IS_ENTITY_OCCLUDED.
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | The entity to check. |
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
BOOLReturns TRUE (1) or FALSE (0).