Merge branch 'main' into main

This commit is contained in:
Kakarot
2024-05-20 20:43:56 -04:00
committed by GitHub
6 changed files with 274 additions and 232 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
+24 -6
View File
@@ -201,8 +201,8 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
return true
end
function self.Functions.Notify(text, type, lenght)
TriggerClientEvent('QBCore:Notify', self.PlayerData.source, text, type, lenght)
function self.Functions.Notify(text, type, length)
TriggerClientEvent('QBCore:Notify', self.PlayerData.source, text, type, length)
end
function self.Functions.HasItem(items, amount)
@@ -236,13 +236,31 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
return self.PlayerData.metadata[meta]
end
function self.Functions.AddJobReputation(amount)
if not amount then return end
amount = tonumber(amount)
self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] = self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] + amount
function self.Functions.AddRep(rep, amount)
if not rep or not amount then return end
local addAmount = tonumber(amount)
local currentRep = self.PlayerData.metadata['rep'][rep] or 0
self.PlayerData.metadata['rep'][rep] = currentRep + addAmount
self.Functions.UpdatePlayerData()
end
function self.Functions.RemoveRep(rep, amount)
if not rep or not amount then return end
local removeAmount = tonumber(amount)
local currentRep = self.PlayerData.metadata['rep'][rep] or 0
if currentRep - removeAmount < 0 then
self.PlayerData.metadata['rep'][rep] = 0
else
self.PlayerData.metadata['rep'][rep] = currentRep - removeAmount
end
self.Functions.UpdatePlayerData()
end
function self.Functions.GetRep(rep)
if not rep then return end
return self.PlayerData.metadata['rep'][rep] or 0
end
function self.Functions.AddMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()