Skip to content

Commit

Permalink
fix(server/player): ox_inventory money vs cash
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon authored Sep 17, 2024
1 parent bd4ed96 commit 83812b9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ function CreatePlayer(playerData, Offline)
end
local oxmoneytype = moneytype == 'cash' and 'money' or moneytype
if accountsAsItems[oxmoneytype] then
exports.ox_inventory:SetItem(self.PlayerData.source, moneytype, self.PlayerData.money[moneytype])
exports.ox_inventory:SetItem(self.PlayerData.source, oxmoneytype, self.PlayerData.money[moneytype])
end
end

Expand Down Expand Up @@ -840,6 +840,12 @@ function CreatePlayer(playerData, Offline)
return item
end

---@param item string
---@return string
local function oxItemCompat(item)
return item == 'cash' and 'money' or item
end

---@deprecated use ox_inventory exports directly
---@param item string
---@param amount number
Expand All @@ -848,7 +854,7 @@ function CreatePlayer(playerData, Offline)
---@return boolean success
function self.Functions.AddItem(item, amount, slot, metadata)
assert(not self.Offline, 'unsupported for offline players')
return exports.ox_inventory:AddItem(self.PlayerData.source, item, amount, metadata, slot)
return exports.ox_inventory:AddItem(self.PlayerData.source, oxItemCompat(item), amount, metadata, slot)
end

---@deprecated use ox_inventory exports directly
Expand All @@ -858,7 +864,7 @@ function CreatePlayer(playerData, Offline)
---@return boolean success
function self.Functions.RemoveItem(item, amount, slot)
assert(not self.Offline, 'unsupported for offline players')
return exports.ox_inventory:RemoveItem(self.PlayerData.source, item, amount, nil, slot)
return exports.ox_inventory:RemoveItem(self.PlayerData.source, oxItemCompat(item), amount, nil, slot)
end

---@deprecated use ox_inventory exports directly
Expand All @@ -874,15 +880,15 @@ function CreatePlayer(playerData, Offline)
---@return any table
function self.Functions.GetItemByName(itemName)
assert(not self.Offline, 'unsupported for offline players')
return qbItemCompat(exports.ox_inventory:GetSlotWithItem(self.PlayerData.source, itemName))
return qbItemCompat(exports.ox_inventory:GetSlotWithItem(self.PlayerData.source, oxItemCompat(itemName)))
end

---@deprecated use ox_inventory exports directly
---@param itemName string
---@return any table
function self.Functions.GetItemsByName(itemName)
assert(not self.Offline, 'unsupported for offline players')
return qbItemCompat(exports.ox_inventory:GetSlotsWithItem(self.PlayerData.source, itemName))
return qbItemCompat(exports.ox_inventory:GetSlotsWithItem(self.PlayerData.source, oxItemCompat(itemName)))
end

---@deprecated use ox_inventory exports directly
Expand Down

0 comments on commit 83812b9

Please sign in to comment.