Files
Elite-Gaming-FiveM/resources/security_cameras_V2/client/managers/exports.lua
T
2025-05-19 16:45:39 -07:00

24 lines
583 B
Lua

-- Get Closest Camera
function GetClosestCam(ped)
local closest, closestDist
if ped == nil then
ped = PlayerPedId()
end
local pedCoords = GetEntityCoords(ped, false)
for k, v in pairs(CCTV_Config.Cameras) do
local camCoords = v.location
local dist = GetDistanceBetweenCoords(pedCoords, camCoords, false) -- False means not to use the Z coord
if not closestDist or dist < closestDist then
closest = v.name
closestDist = dist
end
end
if closest then
return closest
else
return nil
end
end