1
0
Fork 0
forked from Simnation/Main
Main/resources/[inventory]/nordi_alctester/client/client_functions.lua

36 lines
1 KiB
Lua
Raw Normal View History

2025-08-11 16:10:18 +02:00
function GetClosestPlayerRadius(radius)
local players = GetPlayers()
local closestDistance = -1
local closestPlayer = -1
local ply = PlayerPedId()
local plyCoords = GetEntityCoords(ply)
for index,value in ipairs(players) do
local target = GetPlayerPed(value)
if(target ~= ply) then
local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
local distance = #(targetCoords - plyCoords)
if(closestDistance == -1 or closestDistance > distance) then
closestPlayer = value
closestDistance = distance
end
end
end
if closestDistance ~= -1 and closestDistance <= radius then
return closestPlayer
else
return nil
end
end
function GetPlayers()
local players = {}
for _, player in ipairs(GetActivePlayers()) do
local ped = GetPlayerPed(player)
if DoesEntityExist(ped) then
table.insert(players, player)
end
end
return players
end