scripting:reference:system_functions:playerstatusfunctions
This is an old revision of the document!
Table of Contents
Player Status Functions
System functions that provide you information about the player
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 } } }
sysGetNearestPlayer
Format | sysGetNearestPlayer( [WorldX], [WorldY] ) |
---|---|
Description | Returns the ID of the player closest to the specified world coordinate |
Parameters | World Coordinate X,Y |
Returns | Player ID |
Example:
$kSpecialBuildingRecordNum = 10 Event( "UseItem", "Plunger" ) { SetBuildingContext( $kSpecialBuildingRecordNum ) $posX = $gBuildingWorldX $posY = $gBuildingWorldY $targetPlayerID = sysGetNearestPlayer( $posX, $posY ) $targetPlayerName = sysGetPlayerName( $targetPlayerID ) *say %PLAYER% used the plunger. The person closest to the special building was $targetPlayerName *explodebuilding $kSpecialBuildingRecordNum }
sysGetPlayerID
Format | sysGetPlayerID( [Player Name] ) |
---|---|
Description | Returns the ID for a specified player name |
Parameters | Player Name |
Returns | Player ID |
Example:
Event( "Custom", "Special" ) { $playerID = sysGetPlayerID( "Bob" ) if ( $playerID <= 0 ) { *msg %PLAYER% Bob doesn't exist on this world } else { *msg %PLAYER% Bob's player ID is $playerID } }
sysIsPlayerIDOnline
Format | sysIsPlayerIDOnline( [Player ID] ) |
---|---|
Description | Used to determine if the specified player is currently online on the world |
Parameters | Player ID |
Returns | 1 if the player is connected, 0 if not |
Example | $isOnline = sysIsPlayerIDOnline(32) |
sysIsInSpawnZone
Format | sysIsInSpawnZone( [SpawnZone Type/ID] ) |
---|---|
Description | Used to determine if the current player is within the specified spawn zone region |
Parameters | SpawnZone Type/ID |
Returns | 1 if the player is in the region, 0 if not |
Example | $isInDefaultSpawnZone = sysIsInSpawnZone(0) |
sysIsInTown
Example : $var = sysIsInTown(“Home Town”))
Returns 1 if the current player is within the boundaries of the specified town, 0 if not
sysNumPlayersOnTeam
Example : $var = sysNumPlayersOnTeam(3)
Returns the number of players currently online and in the specified team
sysPlayerInventory
Format | sysPlayerInventory ( [Item] ) |
---|---|
Description | Returns the number of an item the current player currently posesses |
Parameters | [Item] - Name or number of the item |
Returns | Amount carried |
Example:
Event( "PreAccessBuilding", "10" ) { $hasKeys = sysPlayerInventory( "Keys" ) if ( $hasKeys == 0 ) { *msg %PLAYER% You cannot access this building without keys CancelTransaction() } }
sysPlayerSkillLevel
Example : $var = sysPlayerSkillLevel(“Farmer”)
Returns the current player's skill level for the skill named (0 means the player does not yet have this skill)
sysPlayerIsLearningSkill
Example : $isLearning = sysPlayerIsLearningSkill(“Farmer”)
Returns 1 if the player is currently learning the specified skill, 0 if not.
scripting/reference/system_functions/playerstatusfunctions.1580293894.txt.gz · Last modified: 2020/01/29 04:31 by mit