GetEntityCoords
Docslocal retval = GetEntityCoords(entity)Description
Gets the current coordinates for a specified entity. This native is used server side when using OneSync.
See GET_ENTITY_COORDS for client side.
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | The entity to get the coordinates from. |
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
Vector3Returns a 3D vector (x, y, z).
Examples
Official
local function ShowCoordinates()
local player = source
local ped = GetPlayerPed(player)
local playerCoords = GetEntityCoords(ped)
print(playerCoords) -- vector3(...)
end
RegisterNetEvent("myCoordinates")
AddEventHandler("myCoordinates", ShowCoordinates)