SelectEntityAtPos
Docslocal retval = SelectEntityAtPos(fracX, fracY, hitFlags, precise)Description
Gets the selected entity at the specified mouse cursor position, and changes the current selection depth. This function supports SDK infrastructure and is not intended to be used directly from your code.
Parameters
| Name | Type | Description |
|---|---|---|
fracX | float | Mouse cursor X fraction. |
fracY | float | Mouse cursor Y fraction. |
hitFlags | int | A bit mask of entity types to match. |
precise | BOOL | Whether to do a *precise* test, i.e. of visual coordinates, too. |
Quick Snippet: Get Entity→ Entity
→ 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
EntityReturns an entity handle.