ESX
if you are going to do this make sure that all players have a cash value of 0, if players have a cash value higher than 0 set them all to 0
Find self.setAccountMoney() function
Replace the function with the following
function self.setAccountMoney(accountName, money, reason, forInventory)
reason = reason or "unknown"
if not tonumber(money) then
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
return
end
if money >= 0 then
local account = self.getAccount(accountName)
if account then
money = account.round and ESX.Math.Round(money) or money
self.accounts[account.index].money = money
if accountName == "money" and not forInventory then
local moneyAmount = exports["tgiann-inventory"]:GetItemByName(self.source, "money_item").amount
if moneyAmount > 0 then
exports["tgiann-inventory"]:RemoveItem(self.source, "money_item", moneyAmount)
end
exports["tgiann-inventory"]:AddItem(self.source, "money_item", money)
end
self.triggerEvent("esx:setAccountMoney", account)
_TriggerEvent("esx:setAccountMoney", self.source, accountName, money, reason)
else
print(("[^1ERROR^7] Tried To Set Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
end
else
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
end
end
Find self.addAccountMoney() function
Replace the function with the following
function self.addAccountMoney(accountName, money, reason)
reason = reason or "Unknown"
if not tonumber(money) then
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
return
end
if money > 0 then
local account = self.getAccount(accountName)
if account then
money = account.round and ESX.Math.Round(money) or money
self.accounts[account.index].money = self.accounts[account.index].money + money
if accountName == "money" then
exports["tgiann-inventory"]:AddItem(self.source, "money_item", money)
end
self.triggerEvent("esx:setAccountMoney", account)
_TriggerEvent("esx:addAccountMoney", self.source, accountName, money, reason)
else
print(("[^1ERROR^7] Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
end
else
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
end
end
Find self.removeAccountMoney() function
Replace the function with the following
function self.removeAccountMoney(accountName, money, reason)
reason = reason or "Unknown"
if not tonumber(money) then
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
return
end
if money > 0 then
local account = self.getAccount(accountName)
if account then
money = account.round and ESX.Math.Round(money) or money
if self.accounts[account.index].money - money > self.accounts[account.index].money then
print(("[^1ERROR^7] Tried To Underflow Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
return
end
self.accounts[account.index].money = self.accounts[account.index].money - money
if accountName == "money" then
exports["tgiann-inventory"]:RemoveItem(self.source, "money_item", money)
end
self.triggerEvent("esx:setAccountMoney", account)
_TriggerEvent("esx:removeAccountMoney", self.source, accountName, money, reason)
else
print(("[^1ERROR^7] Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
end
else
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
end
end
Add the following item to the itemlist
money_item = { name = 'money_item', label = 'Money', weight = 0, type = 'item', image = 'money.webp', unique = false, useable = false, shouldClose = false, description = 'Green Paper' },
Last updated