Update player.lua

Fix some cheats use xPlayer.removeInventoryItem(itemName, negative number) to get Item
This commit is contained in:
3869542
2023-03-05 01:06:12 +08:00
committed by GitHub
parent 4ce57fc566
commit d4f1cbb366
+10 -6
View File
@@ -293,14 +293,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 of name'):format(self.playerId, money))
end
end
end