scripting:reference:system_functions:textfunctions
This is an old revision of the document!
Table of Contents
Text Functions
sysGetPlayerName
| Format | sysGetPlayerName( [PlayerID] ) |
|---|---|
| Description | Returns the name of the specified player |
| Parameters | Player ID |
| Returns | Player Name |
Example:
Event( "UseItem", "Potion" )
{
$targetName = sysGetPlayerName( $gTargetID )
*msg %PLAYER% You used the potion while targeting $targetName
}
sysGetItemName
Example : $var = sysGetItemName ($itemNum))
TBD
sysGetSkillName
Example : $var = sysGetSkillName($skillNum))
TBD
sysGetItemNum
| Format | sysGetItemNum( [Item Name] ) |
|---|---|
| Description | Gets an item number from a name |
| Parameters | Item Name |
| Returns | Item number |
Example:
Event( "UseItem", "Potion" )
{
$itemNum = sysGetItemNum( "Potion" )
*msg %PLAYER% The item number is $itemNum
}
sysGetSkillNum
TBD
sysGetPriceText
| Format | sysGetPriceText ( [Price] ) |
|---|---|
| Description | Returns a text string displaying the price value expressed in a short format - e.g 2s 3d |
| Parameters | Price value (in denari) |
| Returns | Price text |
Example:
Event( "UseItem", "Potion" )
{
$price = 20
if ( $gPlayerCash < $price )
{
$priceText = sysGetPriceText( $price )
*alert %PLAYER% You need at least $priceText to use the potion
CancelTransaction()
}
else
{
*grantcash %PLAYER% -$price
}
}
sysGetDateText
| Format | sysGetDateText( [Unix Time] ) |
|---|---|
| Description | Returns a text string displaying the date and time |
| Parameters | Unix time (Number of seconds since 1 Jan 1970) |
| Returns | Text of the date and time (e.g. “31st December 2014 18:00” ) |
Example:
Event( "UseItem", "Potion" )
{
$nextUsePotionTime = $gServerTimeVar[0]
$currTime = sysGetRealTime( "UnixTime" )
if ( $currTime < $nextUsePotionTime )
{
$useDateText = sysGetDateText( $nextUsePotionTime )
*msg %PLAYER% You cannot use the potion until $useDateText
CancelTransaction()
}
else
{
// Set server variable to store the next time the potion can be used - one hour from now
$kOneHourInSeconds = 60 * 60
$gServerTimeVar[0] = $currTime + $kOneHourInSeconds
}
}
sysGetTimeText
TBD
sysGetRealTimeTextForDays
| 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:
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
}
}
scripting/reference/system_functions/textfunctions.1580294593.txt.gz · Last modified: (external edit)
