1
0
Fork 0
forked from Simnation/Main

Update player.lua

This commit is contained in:
Nordi98 2025-07-20 21:52:11 +02:00
parent a8a35fd831
commit 7533584a53

View file

@ -318,6 +318,11 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
if not self.PlayerData.money[moneytype] then return false end if not self.PlayerData.money[moneytype] then return false end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount
local isMoneyItem, moneyItemName = exports["tgiann-inventory"]:IsMoneyItem(moneytype)
if isMoneyItem then
exports["tgiann-inventory"]:SetItem(self.PlayerData.source, moneyItemName, self.PlayerData.money[moneytype])
end
if not self.Offline then if not self.Offline then
self.Functions.UpdatePlayerData() self.Functions.UpdatePlayerData()
if amount > 100000 then if amount > 100000 then
@ -346,8 +351,11 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
end end
end end
end end
if self.PlayerData.money[moneytype] - amount < QBCore.Config.Money.MinusLimit then return false end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
local isMoneyItem, moneyItemName = exports["tgiann-inventory"]:IsMoneyItem(moneytype)
if isMoneyItem then
exports["tgiann-inventory"]:SetItem(self.PlayerData.source, moneyItemName, self.PlayerData.money[moneytype])
end
if not self.Offline then if not self.Offline then
self.Functions.UpdatePlayerData() self.Functions.UpdatePlayerData()
@ -367,7 +375,7 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
return true return true
end end
function self.Functions.SetMoney(moneytype, amount, reason) function self.Functions.SetMoney(moneytype, amount, reason, forInventory)
reason = reason or 'unknown' reason = reason or 'unknown'
moneytype = moneytype:lower() moneytype = moneytype:lower()
amount = tonumber(amount) amount = tonumber(amount)
@ -376,6 +384,13 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
local difference = amount - self.PlayerData.money[moneytype] local difference = amount - self.PlayerData.money[moneytype]
self.PlayerData.money[moneytype] = amount self.PlayerData.money[moneytype] = amount
if not forInventory then
local isMoneyItem, moneyItemName = exports["tgiann-inventory"]:IsMoneyItem(moneytype)
if isMoneyItem then
exports["tgiann-inventory"]:SetItem(self.PlayerData.source, moneyItemName, amount)
end
end
if not self.Offline then if not self.Offline then
self.Functions.UpdatePlayerData() self.Functions.UpdatePlayerData()
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason) TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)