forked from Simnation/Main
ed
This commit is contained in:
parent
23e3e52966
commit
68151e44fe
11 changed files with 594 additions and 0 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue