forked from Simnation/Main
Update player.lua
This commit is contained in:
parent
a8a35fd831
commit
7533584a53
1 changed files with 82 additions and 67 deletions
|
@ -310,7 +310,7 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||||
return self.PlayerData.metadata['rep'][rep] or 0
|
return self.PlayerData.metadata['rep'][rep] or 0
|
||||||
end
|
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()
|
||||||
amount = tonumber(amount)
|
amount = tonumber(amount)
|
||||||
|
@ -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
|
||||||
|
@ -331,9 +336,9 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.Functions.RemoveMoney(moneytype, amount, reason)
|
function self.Functions.RemoveMoney(moneytype, amount, reason)
|
||||||
reason = reason or 'unknown'
|
reason = reason or 'unknown'
|
||||||
moneytype = moneytype:lower()
|
moneytype = moneytype:lower()
|
||||||
amount = tonumber(amount)
|
amount = tonumber(amount)
|
||||||
|
@ -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()
|
||||||
|
@ -365,9 +373,9 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
||||||
|
@ -385,7 +400,7 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.Functions.GetMoney(moneytype)
|
function self.Functions.GetMoney(moneytype)
|
||||||
if not moneytype then return false end
|
if not moneytype then return false end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue