Merge pull request #928 from 3869542/patch-RemoveInventoryItem

fix(es_extended/server/classes/player.lua): negative removeInventroyItem count
This commit is contained in:
P Gergő
2023-03-04 22:15:12 +01:00
committed by GitHub
+10 -6
View File
@@ -295,14 +295,18 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
if item then
count = ESX.Math.Round(count)
local newCount = item.count - count
if count > 0 then
local newCount = item.count - count
if newCount >= 0 then
item.count = newCount
self.weight = self.weight - (item.weight * count)
if newCount >= 0 then
item.count = newCount
self.weight = self.weight - (item.weight * count)
TriggerEvent('esx:onRemoveInventoryItem', self.source, item.name, item.count)
self.triggerEvent('esx:removeInventoryItem', item.name, item.count)
TriggerEvent('esx:onRemoveInventoryItem', self.source, item.name, item.count)
self.triggerEvent('esx:removeInventoryItem', item.name, item.count)
end
else
print(('[^1ERROR^7] Player ID:^5%s Tried remove a Invalid count -> %s of %s'):format(self.playerId, count,name))
end
end
end