mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
feat(player): refine inventory item count handling with rounding and maximum limit enforcement.
This commit is contained in:
@@ -407,10 +407,9 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
---@return nil
|
||||
function self.addInventoryItem(itemName, count)
|
||||
local item = self.getInventoryItem(itemName)
|
||||
if not item then return end
|
||||
|
||||
count += item.count
|
||||
item.count = (count <= MAX_AMOUNT and count) or MAX_AMOUNT
|
||||
item.count = ESX.Math.Round(count) <= MAX_AMOUNT and ESX.Math.Round(count) or MAX_AMOUNT
|
||||
self.weight += (item.weight * count)
|
||||
|
||||
TriggerEvent("esx:onAddInventoryItem", self.source, item.name, item.count)
|
||||
|
||||
Reference in New Issue
Block a user