fix(es_extended/server): return if not ox inventory

This commit is contained in:
Kasey FItton
2024-11-08 05:53:52 +00:00
parent f84b7031bd
commit c9677e5427
3 changed files with 17 additions and 15 deletions
@@ -1,4 +1,4 @@
if Config.CustomInventory ~= "ox" then return end
if Config.CustomInventory ~= "ox" then return end
MySQL.ready(function()
TriggerEvent("__cfx_export_ox_inventory_Items", function(ref)
@@ -12,14 +12,15 @@ MySQL.ready(function()
end)
end)
function ESX.GetItemLabel(item)
---@diagnostic disable-next-line: duplicate-set-field
ESX.GetItemLabel = function(item)
item = exports.ox_inventory:Items(item)
if item then
return item.label
end
end
function setPlayerInventory(playerId, xPlayer, inventory, isNew)
function setPlayerInventory(playerId, xPlayer, inventory, isNew)
exports.ox_inventory:setPlayerInventory(xPlayer, inventory)
if isNew then
local shared = json.decode(GetConvar("inventory:accounts", '["money"]'))
@@ -32,4 +33,4 @@ function setPlayerInventory(playerId, xPlayer, inventory, isNew)
end
end
end
end
end
@@ -1,6 +1,6 @@
local Inventory
if Config.OxInventory ~= "ox" then end
if Config.CustomInventory ~= "ox" then return end
AddEventHandler("ox_inventory:loadInventory", function(module)
Inventory = module
@@ -9,9 +9,9 @@ end)
Core.PlayerFunctionOverrides.OxInventory = {
getInventory = function(self)
return function(minimal)
if not minimal then
return self.inventory
end
if not minimal then
return self.inventory
end
local minimalInventory = {}
@@ -45,10 +45,10 @@ Core.PlayerFunctionOverrides.OxInventory = {
setAccountMoney = function(self)
return function(accountName, money, reason)
reason = reason or "unknown"
if money < 0 then return end
if money < 0 then return end
local account = self.getAccount(accountName)
if not account then return end
if not account then return end
money = account.round and ESX.Math.Round(money) or money
self.accounts[account.index].money = money
@@ -67,7 +67,7 @@ Core.PlayerFunctionOverrides.OxInventory = {
if money < 1 then return end
local account = self.getAccount(accountName)
if not account then return end
if not account then return end
money = account.round and ESX.Math.Round(money) or money
self.accounts[account.index].money = self.accounts[account.index].money + money
@@ -82,10 +82,10 @@ Core.PlayerFunctionOverrides.OxInventory = {
removeAccountMoney = function(self)
return function(accountName, money, reason)
reason = reason or "unknown"
if money < 1 then return end
if money < 1 then return end
local account = self.getAccount(accountName)
if not account then return end
if not account then return end
money = account.round and ESX.Math.Round(money) or money
self.accounts[account.index].money = self.accounts[account.index].money - money
@@ -204,7 +204,7 @@ Core.PlayerFunctionOverrides.OxInventory = {
self.weight, self.maxWeight = weight, maxWeight
self.inventory = items
if not money then return end
if not money then return end
for accountName, amount in pairs(money) do
local account = self.getAccount(accountName)
+2 -1
View File
@@ -545,6 +545,7 @@ end
---@param item string
---@return string?
---@diagnostic disable-next-line: duplicate-set-field
function ESX.GetItemLabel(item)
if ESX.Items[item] then
return ESX.Items[item].label
@@ -609,6 +610,6 @@ function Core.IsPlayerAdmin(playerId)
return true
end
local xPlayer = ESX.Players[playerId]
local xPlayer = ESX.Players[playerId]
return (xPlayer and Config.AdminGroups[xPlayer.group] and true) or false
end