Inventory Update

This commit is contained in:
Kakarot
2024-05-20 05:28:38 -05:00
parent 8ddbf0555a
commit 435c5335a3
3 changed files with 51 additions and 15 deletions
+27
View File
@@ -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