mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 04:01:24 +00:00
Inventory Update
This commit is contained in:
@@ -165,6 +165,33 @@ function QBCore.Functions.GetDutyCount(job)
|
||||
return count
|
||||
end
|
||||
|
||||
function QBCore.Functions.GetClosestPlayer(source, coords)
|
||||
local ped = GetPlayerPed(source)
|
||||
if coords then
|
||||
coords = type(coords) == 'table' and vector3(coords.x, coords.y, coords.z) or coords
|
||||
else
|
||||
coords = GetEntityCoords(ped)
|
||||
end
|
||||
|
||||
local closestDistance = -1
|
||||
local closestPlayer = -1
|
||||
|
||||
for _, playerId in ipairs(GetPlayers()) do
|
||||
local playerPed = GetPlayerPed(playerId)
|
||||
if playerPed ~= ped then
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
local distance = #(playerCoords - coords)
|
||||
|
||||
if closestDistance == -1 or distance < closestDistance then
|
||||
closestPlayer = playerId
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return closestPlayer, closestDistance
|
||||
end
|
||||
|
||||
-- Routing buckets (Only touch if you know what you are doing)
|
||||
|
||||
---Returns the objects related to buckets, first returned value is the player buckets, second one is entity buckets
|
||||
|
||||
Reference in New Issue
Block a user