Skip to content

Commit

Permalink
refactor(server/bridge): add account money instead of item to fix qs …
Browse files Browse the repository at this point in the history
…inventory weirdness
  • Loading branch information
Demigod916 committed Mar 7, 2024
1 parent 72c73a5 commit 060ba3a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/bridge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ function Bridge.removeItem(src, item, amount, slot)
end
end

function Bridge.addMoney(src, amount)
local Player = Bridge.getPlayer(src)

if not Player then return end

if framework == 'esx' then
Player.addAccountMoney("money", amount)
elseif framework == 'qb' then
return Player.Functions.AddMoney("cash", amount)
end
end

function Bridge.giveItem(src, item, amount, metadata, checkWeight)
local PlayerState = Player(src).state

Expand All @@ -80,6 +92,11 @@ function Bridge.giveItem(src, item, amount, metadata, checkWeight)

if not Player then return end

if item == 'money' then
Bridge.addMoney(src, amount)
return
end

if framework == "esx" then
if not checkWeight or Player.canCarryItem(item, amount) then
Player.addInventoryItem(item, amount, metadata or {})
Expand Down

0 comments on commit 060ba3a

Please sign in to comment.