mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Merge pull request #35 from Dark3581/patch-1
feat(server/functions): GetPlayersFromCoords
This commit is contained in:
@@ -10,6 +10,27 @@ function NDCore.Functions.GetCharacters()
|
||||
return NDCore.Characters
|
||||
end
|
||||
|
||||
|
||||
function NDCore.Functions.GetPlayersFromCoords(distance, coords)
|
||||
if coords then
|
||||
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
|
||||
else
|
||||
coords = GetEntityCoords(PlayerPedId())
|
||||
end
|
||||
distance = distance or 5
|
||||
local closePlayers = {}
|
||||
local players = GetActivePlayers()
|
||||
for _, player in ipairs(players) do
|
||||
local target = GetPlayerPed(player)
|
||||
local targetCoords = GetEntityCoords(target)
|
||||
local targetdistance = #(targetCoords - coords)
|
||||
if targetdistance <= distance then
|
||||
closePlayers[#closePlayers + 1] = player
|
||||
end
|
||||
end
|
||||
return closePlayers
|
||||
end
|
||||
|
||||
-- Callbacks are licensed under LGPL v3.0
|
||||
-- <https://github.com/overextended/ox_lib>
|
||||
NDCore.callback = {}
|
||||
|
||||
Reference in New Issue
Block a user