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 14:05] – [sysGetSellPrice] 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 242: Line 242:
 ^ Description | Returns the price that the item is currently set for sale at (Or 0 if it is not currently for sale) | ^ 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 | ^ 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 249: 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 262: 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 310: 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 518: 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 534: 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 617: 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.1424700314.txt.gz · Last modified: (external edit)