Merge pull request #563 from OMikkel/item-error-handling

refactor(es_extended/server/classes/player.lua): xPlayer.canCarryItem - Error handling - Item not found
This commit is contained in:
JackDUpModZ
2022-10-28 17:53:21 +01:00
committed by GitHub
+7 -3
View File
@@ -300,10 +300,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
end
function self.canCarryItem(name, count, metadata)
local currentWeight, itemWeight = self.weight, ESX.Items[name].weight
local newWeight = currentWeight + (itemWeight * count)
if ESX.Items[name] then
local currentWeight, itemWeight = self.weight, ESX.Items[name].weight
local newWeight = currentWeight + (itemWeight * count)
return newWeight <= self.maxWeight
return newWeight <= self.maxWeight
else
print(('[^3WARNING^7] Item ^5"%s"^7 was used but does not exist!'):format(name))
end
end
function self.canSwapItem(firstItem, firstItemCount, testItem, testItemCount)