mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 02:01:33 +00:00
Inventory Update
This commit is contained in:
+2
-11
@@ -72,19 +72,10 @@ QBConfig.Player.PlayerDefaults = {
|
|||||||
jailitems = {},
|
jailitems = {},
|
||||||
status = {},
|
status = {},
|
||||||
phone = {},
|
phone = {},
|
||||||
fitbit = {},
|
rep = {},
|
||||||
bloodtype = function() return QBConfig.Player.Bloodtypes[math.random(1, #QBConfig.Player.Bloodtypes)] end,
|
|
||||||
dealerrep = 0,
|
|
||||||
craftingrep = 0,
|
|
||||||
attachmentcraftingrep = 0,
|
|
||||||
currentapartment = nil,
|
currentapartment = nil,
|
||||||
jobrep = {
|
|
||||||
tow = 0,
|
|
||||||
trucker = 0,
|
|
||||||
taxi = 0,
|
|
||||||
hotdog = 0
|
|
||||||
},
|
|
||||||
callsign = 'NO CALLSIGN',
|
callsign = 'NO CALLSIGN',
|
||||||
|
bloodtype = function() return QBConfig.Player.Bloodtypes[math.random(1, #QBConfig.Player.Bloodtypes)] end,
|
||||||
fingerprint = function() return QBCore.Player.CreateFingerId() end,
|
fingerprint = function() return QBCore.Player.CreateFingerId() end,
|
||||||
walletid = function() return QBCore.Player.CreateWalletId() end,
|
walletid = function() return QBCore.Player.CreateWalletId() end,
|
||||||
criminalrecord = {
|
criminalrecord = {
|
||||||
|
|||||||
@@ -165,6 +165,33 @@ function QBCore.Functions.GetDutyCount(job)
|
|||||||
return count
|
return count
|
||||||
end
|
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)
|
-- 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
|
---Returns the objects related to buckets, first returned value is the player buckets, second one is entity buckets
|
||||||
|
|||||||
+22
-4
@@ -236,13 +236,31 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
|||||||
return self.PlayerData.metadata[meta]
|
return self.PlayerData.metadata[meta]
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.Functions.AddJobReputation(amount)
|
function self.Functions.AddRep(rep, amount)
|
||||||
if not amount then return end
|
if not rep or not amount then return end
|
||||||
amount = tonumber(amount)
|
local addAmount = tonumber(amount)
|
||||||
self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] = self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] + amount
|
local currentRep = self.PlayerData.metadata['rep'][rep] or 0
|
||||||
|
self.PlayerData.metadata['rep'][rep] = currentRep + addAmount
|
||||||
self.Functions.UpdatePlayerData()
|
self.Functions.UpdatePlayerData()
|
||||||
end
|
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)
|
function self.Functions.AddMoney(moneytype, amount, reason)
|
||||||
reason = reason or 'unknown'
|
reason = reason or 'unknown'
|
||||||
moneytype = moneytype:lower()
|
moneytype = moneytype:lower()
|
||||||
|
|||||||
Reference in New Issue
Block a user