fix: check if money is below 0

This commit is contained in:
Andyyy7666
2023-08-23 00:33:21 +02:00
parent 26ae7ea1a3
commit 0a5ddfe1a8

View File

@@ -25,7 +25,7 @@ local function createCharacterTable(info)
---@return boolean ---@return boolean
function self.deductMoney(account, amount, reason) function self.deductMoney(account, amount, reason)
local amount = tonumber(amount) local amount = tonumber(amount)
if not amount or account ~= "bank" and account ~= "cash" then return end if not amount or amount <= 0 or account ~= "bank" and account ~= "cash" then return end
self[account] -= amount self[account] -= amount
if NDCore.players[self.source] then if NDCore.players[self.source] then
self.triggerEvent("ND:updateMoney", self.cash, self.bank) self.triggerEvent("ND:updateMoney", self.cash, self.bank)
@@ -40,7 +40,7 @@ local function createCharacterTable(info)
---@return boolean ---@return boolean
function self.addMoney(account, amount, reason) function self.addMoney(account, amount, reason)
local amount = tonumber(amount) local amount = tonumber(amount)
if not amount or account ~= "bank" and account ~= "cash" then return end if not amount or amount <= 0 or account ~= "bank" and account ~= "cash" then return end
self[account] += amount self[account] += amount
if NDCore.players[self.source] then if NDCore.players[self.source] then
self.triggerEvent("ND:updateMoney", self.cash, self.bank) self.triggerEvent("ND:updateMoney", self.cash, self.bank)