Skip to main content

canCarryItem

xPlayer.canCarryItem(item, count)

This function is used to determinate if a player can carry an item, and is the successor to the previous item limit checks

Arguments

ArgumentData TypeOptionalDefault ValueExplanation
itemstringNo-Item name
countnumberNo-Item count

Example

if targetXPlayer.canCarryItem(itemName, itemCount) then
sourceXPlayer.removeInventoryItem(itemName, itemCount)
targetXPlayer.addInventoryItem (itemName, itemCount)

sourceXPlayer.showNotification(_U('gave_item', itemCount, sourceItem.label, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_item', itemCount, sourceItem.label, sourceXPlayer.name))
else
sourceXPlayer.showNotification(_U('ex_inv_lim', targetXPlayer.name))
end