πInventoryService
Service for handling inventory actions.
-- Set up a 20% chance to drop an emerald when damaging enemies
Events.EntityDamage(function(event)
if not event.fromEntity then
return
end
-- Only give emeralds when random between 1 and 5 is 1
if math.random(1, 5) ~= 1 then
return
end
local fromPlayer = event.fromEntity:getPlayer()
if fromPlayer then
InventoryService.giveItem(fromPlayer, ItemType.EMERALD, 1, true)
end
end)Functions
getAmount(player: Player, itemType: ItemType): number
removeItemAmount(player: Player, itemType: ItemType, amount: number)
clearInventory(player: Player)
getInventory(player: Player): { itemType: ItemType, amount: number }[]
Last updated