User Tools

Site Tools


scripting:reference:system_functions:playerinventoryandwealthfunctions

This is an old revision of the document!


sysAddToInventory

Format sysAddToInventory ( [Item], [Amount] )
Description Attempts to add an item to the current player's inventory.
Parameters [Item] - Name or number of the item
[Amount] - Amount of the item to be added
Returns [Amount added] - The actual amount of the item that was added
Notes This is an alternate method to calling *grantitem [PlayerName] [Amount] [Item] but the sys function does not message the player unlike *grantitem. Also, this function adheres to the player's capacity limit (*grantitem ignores it) - no items will be added if the player's inventory is already full.

Example:

Event( "UseSkill", "Baker" )
{
    $added = sysAddToInventory( "Bread", 3 )
    if ( $added > 0 )
    {
        *msg %PLAYER% You made yourself $added Bread
    }
    else
    {
        *alert %PLAYER% You're carrying too much stuff
    }
}

sysGetInventoryItemIndex

Format sysGetInventoryItemIndex ( [index] )
Description Returns the item in the current player's inventory.
Parameters [index] - Inventory slot number
Returns [ItemNum] - The item number in the specified inventory slot (or 0 if the slot is empty)
Notes Players currently have up to 64 inventory slots.

Example:

Event( "Custom", "ListInventory" )
{
    $loop = 0
    while( $loop < 64 )
    {
       $itemNum = sysGetInventoryItemIndex( $loop )
       if ( $itemNum != 0 )
       {
          *msg %PLAYER% Item $loop : $itemNum
       }
    }
}

sysAddWealth

TBD: sysAddWealth( Amount, ACCOUNT_SOURCE )

sysRemoveWealth

TBD: sysRemoveWealth( Amount, ACCOUNT_SOURCE )

scripting/reference/system_functions/playerinventoryandwealthfunctions.1580299748.txt.gz · Last modified: 2020/01/29 06:09 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki