1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-11 16:10:18 +02:00
parent 23e3e52966
commit 68151e44fe
11 changed files with 594 additions and 0 deletions

View file

@ -0,0 +1,35 @@
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