Scripting 102: Global Variables
Posted: Sun Jul 29, 2007 11:30 pm
Please see http://theuniversal.net/worldmanual for all the latest info on world scripting.
Variable scripting is a way of controlling the flow of scripts per player, or serverwide.
Playervariables ( $gPlayervar1 - 64) are player specific to store data in a numeric fashion.
Servervariables ($gservervar1 - 128 (i think)) are server specific, a reference all players scripts to access.
playertimevariables ($gPlayertimevar1-4) are for using timed variables, on a per-player basis.
Along with the 3 above, there are also server refrences per player that you can call to the script. Those include: $gplayerkudos, $gplayerteam, $gplayerfamily, $gplayercash,$gplayerhealth, $gplayerlevel.
All variables SHOULD start at 0 by default.
SETTING VARIABLES
in order to set a variable, you would format it like this:
Now, you have something that sets a playervariable. Lets get a little more complicated.
In the above example, the script looks to see if playervariable 1 is 1 before it executes the script. If its not, it tells them it cannot, and gives the item back so it can be used again later.
Hope this helps some people. Ill make another post later of a more basic scripting instructions, with all the events possible etc.
----===========----------------------================
Time Variables
$gservertime is used with $playertimevar1 - 4
servertime is in seconds from the very start of planet time.
An example for using this. What this does is allow use of an item every 3 minutes.
Variable scripting is a way of controlling the flow of scripts per player, or serverwide.
Playervariables ( $gPlayervar1 - 64) are player specific to store data in a numeric fashion.
Servervariables ($gservervar1 - 128 (i think)) are server specific, a reference all players scripts to access.
playertimevariables ($gPlayertimevar1-4) are for using timed variables, on a per-player basis.
Along with the 3 above, there are also server refrences per player that you can call to the script. Those include: $gplayerkudos, $gplayerteam, $gplayerfamily, $gplayercash,$gplayerhealth, $gplayerlevel.
All variables SHOULD start at 0 by default.
SETTING VARIABLES
in order to set a variable, you would format it like this:
Code: Select all
Event( "Useitem", "Usable Item 1" )
{
*msg %player% Playervar1 set to 1
$playervar1 = 1 // <------------defines plavervar1
}
Code: Select all
Event( "Useitem", "Usable Item 2" )
{
if ( $playervar1 = 1 )
{
*msg %player% You may use this item.
}
else
{
*msg %player% you must use Usable Item 1 before using this item.
canceltransaction()
}
}
Hope this helps some people. Ill make another post later of a more basic scripting instructions, with all the events possible etc.
----===========----------------------================
Time Variables
$gservertime is used with $playertimevar1 - 4
servertime is in seconds from the very start of planet time.
An example for using this. What this does is allow use of an item every 3 minutes.
Code: Select all
Event( "Useitem", "Usable Item 1" )
{
if ( $gservertime > $playertimevar1 + 180 ) // checks to see if time has //lapsed. 180 seconds from previous use
{
$playertimevar1 = $gservertime // <----- inputs current servertime // to playertimevar1
*msg %player% Item used... you can use this item again in 3 minutes
}
else
{
*msg %player% You cannot use this item again yet
}
}