User Tools

Site Tools


scripting:reference:system_functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:reference:system_functions [2015/02/23 13:45] – doc for sysGetNearestPlayer mitscripting:reference:system_functions [2025/05/28 16:35] (current) – external edit 127.0.0.1
Line 33: Line 33:
 ^ Parameters | **[index]** - Inventory slot number | ^ Parameters | **[index]** - Inventory slot number |
 ^ Returns | **[ItemNum]** - The item number in the specified inventory slot (or 0 if the slot is empty) | ^ Returns | **[ItemNum]** - The item number in the specified inventory slot (or 0 if the slot is empty) |
-^ Notes | Players currently have 16 inventory slots. |+^ Notes | Players currently have up to 64 inventory slots. |
 //Example//: <note> //Example//: <note>
 <code>Event( "Custom", "ListInventory" ) <code>Event( "Custom", "ListInventory" )
 { {
     $loop = 0     $loop = 0
-    while( $loop < 16 )+    while( $loop < 64 )
     {     {
        $itemNum = sysGetInventoryItemIndex( $loop )        $itemNum = sysGetInventoryItemIndex( $loop )
Line 96: Line 96:
  
 ==== sysIsPlayerIDOnline ==== ==== sysIsPlayerIDOnline ====
-Example : ''**$var = sysIsPlayerIDOnline(32))**''  \\ +^ Format | sysIsPlayerIDOnline( [Player ID] )| 
-Returns 1 if the specified player (BillingID) is currently online, 0 if not \\+^ 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 ==== ==== sysIsInSpawnZone ====
-Example : ''**$var = sysIsInSpawnZone(2))**'' \\ +^ Format | sysIsInSpawnZone( [SpawnZone Type/ID] )| 
-Returns 1 if the current player is in the specified spawn zone, 0 if not \\+^ 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 ==== ==== sysIsInTown ====
Line 130: Line 136:
  
 ==== sysPlayerSkillLevel ==== ==== sysPlayerSkillLevel ====
-Example : ''**$var = PlayerSkillLevel("Farmer")**'' \\ +Example : ''**$var = sysPlayerSkillLevel("Farmer")**'' \\ 
-Returns the current player's skill level for the skill named \\+Returns the current player's skill level for the skill named (0 means the player does not yet have this skill) \\
  
 ==== sysPlayerIsLearningSkill ==== ==== sysPlayerIsLearningSkill ====
-TBD // +Example : ''**$isLearning = sysPlayerIsLearningSkill("Farmer")**'' \\ 
-//+Returns **1** if the player is currently learning the specified skill, **0** if not. \\
  
 ===== Player Building Ownership Functions ===== ===== Player Building Ownership Functions =====
Line 208: Line 214:
  
 ==== sysAmountInStocks ==== ==== sysAmountInStocks ====
-Example ''**$var = sysAmountInStocks("Bongos))**''  \\ +^ Format | sysAmountInStocks( [Item_Name or Num] )| 
-Returns the amount of the item named currently in the player's inventory.\\+^ Description | Returns the amount of the item currently in the building's stocks | 
 +^ Parameters | Item Name or number | 
 +Example ''**$amountInBuilding = sysAmountInStocks("Wood")**'' |
  
 ==== sysGetBuyPrice ==== ==== sysGetBuyPrice ====
Line 230: Line 238:
 </note> </note>
  
-==== sysGetSellPrice==== +==== sysGetSellPrice ==== 
-Example : ''**$var sysAmountInStocks("Bongos" ))**''  \\ +^ Format | sysGetSellPrice( [Item_Name or Num] )| 
-TBD\\ +^ Description | Returns the price that the item is currently set for sale at (Or 0 if it is not currently for sale) | 
 +^ Parameters | Item Name or number | 
 +//Example//: 
 +<note> 
 +<code>Event( "AccessBuilding", "12"
 +
 +    osdcreate( OSDBUILDING, "Building", "Example"
 +    $woodSellPrice sysGetSellPrice( "Wood" )   
 +    if ( $woodSellPrice == 0 ) 
 +    { 
 +        osdaddat( TEXT, 100, 100, 400, 0, "", "Not currently selling wood" )    
 +    } 
 +    else 
 +    {  
 +        $woodSellPriceText = sysGetPriceText( $woodSellPrice ) 
 +        osdaddat( TEXT, 100, 100, 400, 0, "", "Currently selling wood at $woodSellPriceText"
 +    } 
 +    osdactivate() 
 +
 +</code> 
 +</note>
 ==== sysGetEmployeeID ==== ==== sysGetEmployeeID ====
 ^ Format | sysGetEmployeeID( [Index] ) | ^ Format | sysGetEmployeeID( [Index] ) |
Line 240: Line 267:
 ^ Returns | PlayerID of the employee or 0 if none is set for this index | ^ Returns | PlayerID of the employee or 0 if none is set for this index |
 //Example//:<note> //Example//:<note>
-<code>Event( "AccessBuilding", "12" )+<code>Event( "AccessBuilding", "13" )
 { {
     osdcreate( OSDBUILDING, "Building", "Example" )     osdcreate( OSDBUILDING, "Building", "Example" )
Line 253: Line 280:
         osdaddat( TEXT, 100, 100, 400, 0, "", "There is no-one currently employed at this building" )         osdaddat( TEXT, 100, 100, 400, 0, "", "There is no-one currently employed at this building" )
     }     }
-    osdcreate()+    osdactivate()
 } }
 </code> </code>
Line 301: Line 328:
  
 ==== sysAddBuilding ==== ==== sysAddBuilding ====
-TBD\\+^ Format | sysAddBuilding ( [Building Type], [Owner ID], [MapX], [MapY], [ [Building_Name], [Construction Amount 1], [Construction Amount 2] ] ) )| 
 +^ Description | Used to add a new building to your world | 
 +^ Parameters | Building Type number | 
 +^  | Owner player ID | 
 +^  | Map Coordinate X | 
 +^  | Map Coordinate Y | 
 +^  | (Optional) Building Name | 
 +^  | (Optional) Construction Amount 1 | 
 +^  | (Optional) Construction Amount 2 | 
 +^ Returns | 1 if the building was added to the world, 0 if not | 
 +//Example//: <note> 
 +<code>Event( "PlaceAnyBuilding", ""
 +
 +    $nBuildingType = $gParam[1] 
 + 
 +    $valid = sysIsBuildingPositionValid( $nBuildingType ) 
 +    if ( $valid = 1 ) 
 +    { 
 + $buildingName = sysGetTextEntry() 
 + $didAdd = sysAddBuilding( nBuildingType,$gPlayerID,$gPlayerX,$gPlayerY,$buildingName ) 
 +    } 
 +
 +</code> 
 +</note> 
 ==== sysAddBuildingWorld ==== ==== sysAddBuildingWorld ====
 TBD\\ TBD\\
Line 509: Line 560:
  
 ==== sysGetRealTimeTextForDays ==== ==== sysGetRealTimeTextForDays ====
-TBD // +^ Format | sysGetRealTimeTextForDays ( [Number of game days] )| 
-// +^ Description | Returns a text description of the time that will pass for the specified number of game days | 
 +^ Parameters | Number of game days | 
 +^ Returns | Time text | 
 +//Example//: <note> 
 +<code>Event( "UseItem", "Magic Potion"
 +
 +    $daysSinceLastUsed = $gGameDay - $gPlayerKey[LastUsedPotionDay] 
 +    if ( $daysSinceLastUsed < 10 ) 
 +    { 
 +        $daysUntilCanUse = 10 - $daysSinceLastUsed 
 +        $timeText = sysGetRealTimeTextForDays( $daysUntilCanUse ) 
 +        *say You must wait $timeText until you can use the Magic Potion again 
 +    } 
 +    else 
 +    { 
 +        *effect %PLAYER% 10 
 +        $gPlayerKey[LastUsedPotionDay] = $gGameDay 
 +    } 
 +
 +</code> 
 +</note>
 ===== Battle game Functions ===== ===== Battle game Functions =====
  
Line 525: Line 595:
  
  
-===== Misc other functions =====+===== Maths Functions =====
  
 ==== sysRand ==== ==== sysRand ====
-Example : ''**$var = Rand(500)**'' \\ +^ Format | sysRand ( [MAX_NUM] )| 
- Returns a random number between 1 and the value specified \\ +^ Description | Returns a random number between and the value specified 
- +Example ''**$var Rand(500)**'' |
-==== sysRealTime ==== +
-^ Format | sysRealTime ( [Type] )| +
-^ Description | Returns details of the current real time (according to the server clock)| +
-^ Parameters | Type field specifying the date or time to fetch | +
-^ Returns | Depending on the type field: | +
-^  | **Year** - returns the current year (e.g. 2014) | +
-^  | **Month** - returns the current month number (to 12) | +
-^  | **Day** - returns the current day number (1 to 31) +
- | **Hour** - returns the current hour (0 to 23) | +
-^  | **Minute** - returns the current minute (0 to 59) | +
-^  | **Second** - returns the current second (0 to 59) | +
-^  | **UnixTime** - number of seconds passed since 1st Jan, 1970 | +
-//Example//: <note> +
-<code>Event( "UseItem", "Tea"+
-+
-   $hour sysRealTime"Hour" ) +
-   if ( $hour < 18 ) +
-   { +
-      *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm) +
-    } +
-    else if ( $hour >= 20 ) +
-    { +
-      *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm)     +
-    } +
-    else +
-    { +
-        *notifylarge %PLAYER% Tea-time! +
-    } +
-+
-</code> +
-</note> +
-==== sysGetDist ==== +
-^ Format sysGetDist ( [X1], [Y1], [X2], [Y2] )| +
-^ Description | Calculates the distance between two points| +
-^ Parameters | Point 1 X,Y | +
-^  | Point 2 X,Y | +
-^ Returns | Distance | +
-//Example//: <note> +
-<code>Event( "AccessBuilding", "1"+
-+
-    $dist = sysGetDist( $gPlayerWorldX, $gPlayerWorldY, $gBuildingWorldX, $gBuildingWorldY ) +
-    *msg %PLAYER% You accessed the building from $dist cm away +
-+
-</code> +
-</note>+
  
 ==== sysSin ==== ==== sysSin ====
Line 608: Line 633:
 //Example//: See sysSin above \\ //Example//: See sysSin above \\
 \\ \\
 +
 +==== sysGetDist ====
 +^ Format | sysGetDist ( [X1], [Y1], [X2], [Y2] )|
 +^ Description | Calculates the distance between two points|
 +^ Parameters | Point 1 X,Y |
 +^  | Point 2 X,Y |
 +^ Returns | Distance |
 +//Example//: <note>
 +<code>Event( "AccessBuilding", "1" )
 +{
 +    $dist = sysGetDist( $gPlayerWorldX, $gPlayerWorldY, $gBuildingWorldX, $gBuildingWorldY )
 +    *msg %PLAYER% You accessed the building from $dist cm away
 +}
 +</code>
 +</note>
 +
 +===== Misc other functions =====
 +
 +==== sysRealTime ====
 +^ Format | sysRealTime ( [Type] )|
 +^ Description | Returns details of the current real time (according to the server clock)|
 +^ Parameters | Type field specifying the date or time to fetch |
 +^ Returns | Depending on the type field: |
 +^  | **Year** - returns the current year (e.g. 2014) |
 +^  | **Month** - returns the current month number (1 to 12) |
 +^  | **Day** - returns the current day number (1 to 31) |
 +^  | **Hour** - returns the current hour (0 to 23) |
 +^  | **Minute** - returns the current minute (0 to 59) |
 +^  | **Second** - returns the current second (0 to 59) |
 +^  | **UnixTime** - number of seconds passed since 1st Jan, 1970 |
 +//Example//: <note>
 +<code>Event( "UseItem", "Tea" )
 +{
 +   $hour = sysRealTime( "Hour" )
 +   if ( $hour < 18 )
 +   {
 +      *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm)
 +    }
 +    else if ( $hour >= 20 )
 +    {
 +      *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm)    
 +    }
 +    else
 +    {
 +        *notifylarge %PLAYER% Tea-time!
 +    }
 +}
 +</code>
 +</note>
  
 ==== sysRaceIsActive ==== ==== sysRaceIsActive ====
 TBD \\ TBD \\
 \\ \\
scripting/reference/system_functions.1424699149.txt.gz · Last modified: (external edit)