Skip to content

Commit

Permalink
Fix: remove and add money works with latest ox_core
Browse files Browse the repository at this point in the history
  • Loading branch information
FjamZoo committed Jan 7, 2025
1 parent 454592e commit 4356aba
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions framework/ox/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ end)
---@return boolean
exports('removeMoney', function(source, amount, moneyType, reason)
if moneyType == 'bank' then
local Player = Ox.GetPlayer(source)
local account = Ox.GetCharacterAccount(source)

if Player then
Ox.RemoveAccountBalance(Player.getAccount(), -amount, reason)
if account then
return account.removeBalance({
amount = amount,
message = reason,
overdraw = false
}).success
end
else -- cash
else
return exports.ox_inventory:RemoveItem(source, 'money', amount)
end

Expand All @@ -53,12 +57,15 @@ end)
---@return boolean
exports('addMoney', function(source, amount, moneyType, reason)
if moneyType == 'bank' then
local Player = Ox.GetPlayer(source)
local account = Ox.GetCharacterAccount(source)

if Player then
Ox.AddAccountBalance(Player.getAccount(), -amount, reason)
if account then
account.addBalance({
amount = amount,
message = reason
}).success
end
else -- cash
else
return exports.ox_inventory:AddItem(source, 'money', amount)
end

Expand Down

0 comments on commit 4356aba

Please sign in to comment.