<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.herc.ws/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.herc.ws/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Annieruru</id>
		<title>Hercules Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.herc.ws/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Annieruru"/>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Special:Contributions/Annieruru"/>
		<updated>2026-05-01T07:34:50Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.21.11</generator>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-30T08:23:29Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: someone revert back to the old information ... did he miss TXT server so much ?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and both also supports arrays. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it only use to store player's information that last until player logout, since it behaved that way, without having to use OnPCLogoutEvent to clear them.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in the table called 'char_reg_num_db' for integer type, and 'char_reg_str_db' for string type. The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;{,&amp;lt;min&amp;gt;{,&amp;lt;max&amp;gt;}};&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is simulate Guild/Party Array or simulate multi-dimensional array.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
     [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2); &lt;br /&gt;
     // If your guild ID would be 204, the contents of .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
     [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
     [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
     [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
or you can just&lt;br /&gt;
     [[setd]] &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2), [[getd]](&amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2)) +1;&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 32 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Gettimestr</id>
		<title>Gettimestr</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Gettimestr"/>
				<updated>2015-12-24T21:53:40Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: change the format to easier to understand&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Syntax ==&lt;br /&gt;
*'''gettimestr'''(&amp;lt;&amp;quot;format&amp;quot;&amp;gt;, &amp;lt;max length&amp;gt;);&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
This function returns the current system time and date as a string, according to given ''format'', which has same syntax as the one of C library function [http://www.cplusplus.com/reference/clibrary/ctime/strftime/ strftime]. The parameter ''max length'' specifies the maximum length of the string returned.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
 [[mes]] gettimestr(&amp;quot;%Y-%m/%d %H:%M:%S&amp;quot;,21);&lt;br /&gt;
Would print out the full current date and time, ex. &amp;quot;2010-10/30 07:48:37&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Example compile under MSVC ===&lt;br /&gt;
This example compile under MSVC 2010&lt;br /&gt;
 prontera,156,192,6	script	Time Sample	8W_SOLDIER,{&lt;br /&gt;
 	mes &amp;quot;System Tick : &amp;quot;+ gettimetick(0);&lt;br /&gt;
 	mes &amp;quot; Time Tick  : &amp;quot;+ gettimetick(1);&lt;br /&gt;
 	mes &amp;quot; UNIX Tick  : &amp;quot;+ gettimetick(2);&lt;br /&gt;
 	mes &amp;quot; GetTime(1) : &amp;quot;+ gettime(GETTIME_SECOND) +&amp;quot; (Sec)&amp;quot;; // 15 (second 0~59)&lt;br /&gt;
 	mes &amp;quot; GetTime(2) : &amp;quot;+ gettime(GETTIME_MINUTE) +&amp;quot; (Min)&amp;quot;; // 04 (minute 0~59)&lt;br /&gt;
 	mes &amp;quot; GetTime(3) : &amp;quot;+ gettime(GETTIME_HOUR) +&amp;quot; (Hour)&amp;quot;; // 5 (hour 0~23)&lt;br /&gt;
 	mes &amp;quot; GetTime(4) : &amp;quot;+ gettime(GETTIME_WEEKDAY) +&amp;quot; (WeekDay)&amp;quot;; // 2 (Sun=0,Sat=6 0~6)&lt;br /&gt;
 	mes &amp;quot; GetTime(5) : &amp;quot;+ gettime(GETTIME_DAYOFMONTH) +&amp;quot; (MonthDay)&amp;quot;; // 22 (day 1~31)&lt;br /&gt;
 	mes &amp;quot; GetTime(6) : &amp;quot;+ gettime(GETTIME_MONTH) +&amp;quot; (Month)&amp;quot;; // 12 (month 1~12)&lt;br /&gt;
 	mes &amp;quot; GetTime(7) : &amp;quot;+ gettime(GETTIME_YEAR) +&amp;quot; (Year)&amp;quot;; // 2015 (year)&lt;br /&gt;
 	mes &amp;quot; GetTime(8) : &amp;quot;+ gettime(GETTIME_DAYOFYEAR) +&amp;quot; (No.day in year)&amp;quot;; // 356 (day of the year)&lt;br /&gt;
 	mes &amp;quot; GetTimeStr : %Y-%m/%d %H:%M:%S,40&amp;quot;;&lt;br /&gt;
 	mes gettimestr(&amp;quot;%Y-%m/%d %H:%M:%S&amp;quot;,40); // 2015-12/22 05:04:15&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%a : &amp;quot;+ gettimestr(&amp;quot;%a&amp;quot;,19); // Tue (short week)&lt;br /&gt;
 	mes &amp;quot;%A : &amp;quot;+ gettimestr(&amp;quot;%A&amp;quot;,19); // Tuesday (long week)&lt;br /&gt;
 	mes &amp;quot;%b : &amp;quot;+ gettimestr(&amp;quot;%b&amp;quot;,19); // Dec (short month)&lt;br /&gt;
 	mes &amp;quot;%B : &amp;quot;+ gettimestr(&amp;quot;%B&amp;quot;,19); // December (long month)&lt;br /&gt;
 	mes &amp;quot;%c : &amp;quot;+ gettimestr(&amp;quot;%c&amp;quot;,19); // 12/22/15 05:04:15 (== %x %X)&lt;br /&gt;
 	mes &amp;quot;%d : &amp;quot;+ gettimestr(&amp;quot;%d&amp;quot;,19); // 22 (day 01~31)&lt;br /&gt;
 	mes &amp;quot;%H : &amp;quot;+ gettimestr(&amp;quot;%H&amp;quot;,19); // 05 (hour 00~23)&lt;br /&gt;
 	mes &amp;quot;%I : &amp;quot;+ gettimestr(&amp;quot;%I&amp;quot;,19); // 05 (hour 01~12)&lt;br /&gt;
 	mes &amp;quot;%j : &amp;quot;+ gettimestr(&amp;quot;%j&amp;quot;,19); // 356 (day of the year)&lt;br /&gt;
 	mes &amp;quot;%m : &amp;quot;+ gettimestr(&amp;quot;%m&amp;quot;,19); // 12 (month 01~12)&lt;br /&gt;
 	mes &amp;quot;%M : &amp;quot;+ gettimestr(&amp;quot;%M&amp;quot;,19); // 04 (minute 00~59)&lt;br /&gt;
 	mes &amp;quot;%p : &amp;quot;+ gettimestr(&amp;quot;%p&amp;quot;,19); // AM (AM / PM)&lt;br /&gt;
 	mes &amp;quot;%S : &amp;quot;+ gettimestr(&amp;quot;%S&amp;quot;,19); // 15 (second 00~59)&lt;br /&gt;
 	mes &amp;quot;%U : &amp;quot;+ gettimestr(&amp;quot;%U&amp;quot;,19); // 51 (Week number with the first Sunday as the first day of week one (00-53))&lt;br /&gt;
 	mes &amp;quot;%w : &amp;quot;+ gettimestr(&amp;quot;%w&amp;quot;,19); // 2 (Sun=0,Sat=6 0~6)&lt;br /&gt;
 	mes &amp;quot;%W : &amp;quot;+ gettimestr(&amp;quot;%W&amp;quot;,19); // 51 (Week number with the first Monday as the first day of week one (00-53))&lt;br /&gt;
 	mes &amp;quot;%x : &amp;quot;+ gettimestr(&amp;quot;%x&amp;quot;,19); // 12/22/15 (== %m/%d/%y)&lt;br /&gt;
 	mes &amp;quot;%X : &amp;quot;+ gettimestr(&amp;quot;%X&amp;quot;,19); // 05:04:15 (== %H:%M:%S)&lt;br /&gt;
 	mes &amp;quot;%y : &amp;quot;+ gettimestr(&amp;quot;%y&amp;quot;,19); // 15 (year 00~99)&lt;br /&gt;
 	mes &amp;quot;%Y : &amp;quot;+ gettimestr(&amp;quot;%Y&amp;quot;,19); // 2015 (year)&lt;br /&gt;
 	mes &amp;quot;%z : &amp;quot;+ gettimestr(&amp;quot;%z&amp;quot;,19); // cannot determine timezone, this is blank&lt;br /&gt;
 	mes &amp;quot;%Z : &amp;quot;+ gettimestr(&amp;quot;%Z&amp;quot;,19); // cannot determine timezone, this is blank&lt;br /&gt;
 	mes &amp;quot;%% : &amp;quot;+ gettimestr(&amp;quot;%%&amp;quot;,19); // print '%' sign&lt;br /&gt;
 	close;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Old Example compile under Cygwin ===&lt;br /&gt;
This example was compile under Cygwin provided by Bowiebowie. The script can be found [http://www.eathena.ws/board/index.php?s=&amp;amp;showtopic=181741&amp;amp;view=findpost&amp;amp;p=1329705 here].&lt;br /&gt;
 prontera.gat,157,181,6	script	Time Sample	105,{&lt;br /&gt;
 	mes &amp;quot;System Tick : &amp;quot;+ gettimetick(0);&lt;br /&gt;
 	mes &amp;quot; Time Tick  : &amp;quot;+ gettimetick(1);&lt;br /&gt;
 	mes &amp;quot; UNIX Tick  : &amp;quot;+ gettimetick(2);&lt;br /&gt;
 	mes &amp;quot; GetTime(1) : &amp;quot;+ gettime(1) +&amp;quot; (Sec)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(2) : &amp;quot;+ gettime(2) +&amp;quot; (Min)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(3) : &amp;quot;+ gettime(3) +&amp;quot; (Hour)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(4) : &amp;quot;+ gettime(4) +&amp;quot; (WeekDay)&amp;quot;; // (day in the week 0~6)&lt;br /&gt;
 	mes &amp;quot; GetTime(5) : &amp;quot;+ gettime(5) +&amp;quot; (MonthDay)&amp;quot;; // (Day of the month)&lt;br /&gt;
 	mes &amp;quot; GetTime(6) : &amp;quot;+ gettime(6) +&amp;quot; (Month)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(7) : &amp;quot;+ gettime(7) +&amp;quot; (Year)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(8) : &amp;quot;+ gettime(8) +&amp;quot; (No.day in year)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTimeStr : %Y-%m/%d %H:%M:%S,40&amp;quot;;&lt;br /&gt;
 	mes gettimestr(&amp;quot;%Y-%m/%d %H:%M:%S&amp;quot;,40); // 2007-07/27 16:59:22&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%a : &amp;quot;+ gettimestr(&amp;quot;%a&amp;quot;,19); // Tue (short week)&lt;br /&gt;
 	mes &amp;quot;%A : &amp;quot;+ gettimestr(&amp;quot;%A&amp;quot;,19); // Tuesday (long week)&lt;br /&gt;
 	mes &amp;quot;%b : &amp;quot;+ gettimestr(&amp;quot;%b&amp;quot;,19); // Jul (short month)&lt;br /&gt;
 	mes &amp;quot;%B : &amp;quot;+ gettimestr(&amp;quot;%B&amp;quot;,19); // July (long month)&lt;br /&gt;
 	mes &amp;quot;%c : &amp;quot;+ gettimestr(&amp;quot;%c&amp;quot;,19); // Tue Jul 24 16:30&lt;br /&gt;
 	mes &amp;quot;%C : &amp;quot;+ gettimestr(&amp;quot;%C&amp;quot;,19); // 20 (year -&amp;gt;20&amp;lt;-07)&lt;br /&gt;
 	mes &amp;quot;%d : &amp;quot;+ gettimestr(&amp;quot;%d&amp;quot;,19); // 24 (day 01~31)&lt;br /&gt;
 	mes &amp;quot;%D : &amp;quot;+ gettimestr(&amp;quot;%D&amp;quot;,19); // 07/24/07 (month/day/year)&lt;br /&gt;
 	mes &amp;quot;%e : &amp;quot;+ gettimestr(&amp;quot;%e&amp;quot;,19); // 24 (day  1~31)&lt;br /&gt;
 	mes &amp;quot;%F : &amp;quot;+ gettimestr(&amp;quot;%F&amp;quot;,19); // 2007/07/24 (year/month/day)&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%g : &amp;quot;+ gettimestr(&amp;quot;%g&amp;quot;,19); // 07 (year 00~99)&lt;br /&gt;
 	mes &amp;quot;%G : &amp;quot;+ gettimestr(&amp;quot;%G&amp;quot;,19); // 2007 (year)&lt;br /&gt;
 	mes &amp;quot;%h : &amp;quot;+ gettimestr(&amp;quot;%h&amp;quot;,19); // Jul (short month) ( == %b )&lt;br /&gt;
 	mes &amp;quot;%H : &amp;quot;+ gettimestr(&amp;quot;%H&amp;quot;,19); // 16 (hour 00~23)&lt;br /&gt;
 	mes &amp;quot;%I : &amp;quot;+ gettimestr(&amp;quot;%I&amp;quot;,19); // 04 (hour 01~12)&lt;br /&gt;
 	mes &amp;quot;%j : &amp;quot;+ gettimestr(&amp;quot;%j&amp;quot;,19); // 205 (day of the year)&lt;br /&gt;
 	mes &amp;quot;%k : &amp;quot;+ gettimestr(&amp;quot;%k&amp;quot;,19); // 16 (hour  0~23)&lt;br /&gt;
 	mes &amp;quot;%l : &amp;quot;+ gettimestr(&amp;quot;%l&amp;quot;,19); //  4 (hour  1~12)&lt;br /&gt;
 	mes &amp;quot;%m : &amp;quot;+ gettimestr(&amp;quot;%m&amp;quot;,19); // 07 (month 01~12)&lt;br /&gt;
 	mes &amp;quot;%M : &amp;quot;+ gettimestr(&amp;quot;%M&amp;quot;,19); // 30 (minute 00~59)&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%p : &amp;quot;+ gettimestr(&amp;quot;%p&amp;quot;,19); // PM ( AM / PM )&lt;br /&gt;
 //	mes &amp;quot;%p : &amp;quot;+ gettimestr(&amp;quot;%P&amp;quot;,19); // pm ( am / pm ) &amp;lt;-- not supported !!&lt;br /&gt;
 	mes &amp;quot;%r : &amp;quot;+ gettimestr(&amp;quot;%r&amp;quot;,19); // 4:30:00 PM ( == %I:%M:%S %p )&lt;br /&gt;
 	mes &amp;quot;%R : &amp;quot;+ gettimestr(&amp;quot;%R&amp;quot;,19); // 16:30 (==%H:%M)&lt;br /&gt;
 	mes &amp;quot;%S : &amp;quot;+ gettimestr(&amp;quot;%S&amp;quot;,19); // 57 (second 00~59)&lt;br /&gt;
 	mes &amp;quot;%T : &amp;quot;+ gettimestr(&amp;quot;%T&amp;quot;,19); // 16:30:00 (hour:minute:sec)&lt;br /&gt;
 	mes &amp;quot;%u : &amp;quot;+ gettimestr(&amp;quot;%u&amp;quot;,19); // 2 (number of the week 1~7, Sun = 7)&lt;br /&gt;
 	mes &amp;quot;%U : &amp;quot;+ gettimestr(&amp;quot;%U&amp;quot;,19); // 29 (range 00 through 53), starting with the first Sunday as the first day of the first week. Days preceding the first Sunday in the year are considered to be in week 00.&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%V : &amp;quot;+ gettimestr(&amp;quot;%V&amp;quot;,19); // 30 (range 01 through 53). ISO weeks start with Monday and end with Sunday. Week 01 of a year is the first week which has the majority of its days in that year; this is equivalent to the week containing the year's first Thursday, and it is also equivalent to the week containing January 4. Week 01 of a year can contain days from the previous year. The week before week 01 of a year is the last week (52 or 53) of the previous year even if it contains days from the new year.&lt;br /&gt;
 	mes &amp;quot;%w : &amp;quot;+ gettimestr(&amp;quot;%w&amp;quot;,19); // 2 (number of the week 0~6, Sun = 0)&lt;br /&gt;
 	mes &amp;quot;%W : &amp;quot;+ gettimestr(&amp;quot;%W&amp;quot;,19); // 30 (The week number of the current year as a decimal number (range 00 through 53), starting with the first Monday as the first day of the first week. All days preceding the first Monday in the year are considered to be in week 00.)&lt;br /&gt;
 	mes &amp;quot;%x : &amp;quot;+ gettimestr(&amp;quot;%x&amp;quot;,19); // 07/24/07&lt;br /&gt;
 	mes &amp;quot;%X : &amp;quot;+ gettimestr(&amp;quot;%X&amp;quot;,19); // 16:40:23&lt;br /&gt;
 	close;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-23T02:15:09Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: /* General Restrictions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and both also supports arrays. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it only use to store player's information that last until player logout, since it behaved that way, without having to use OnPCLogoutEvent to clear them.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in the table called 'char_reg_num_db' for integer type, and 'char_reg_str_db' for string type. The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;{,&amp;lt;min&amp;gt;{,&amp;lt;max&amp;gt;}};&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is simulate Guild/Party Array or simulate multi-dimensional array.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
     [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2); &lt;br /&gt;
     // If your guild ID would be 204, the contents of .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
     [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
     [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
     [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
or you can just&lt;br /&gt;
     [[setd]] &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2), [[getd]](&amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2)) +1;&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 32 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Gettimestr</id>
		<title>Gettimestr</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Gettimestr"/>
				<updated>2015-12-21T21:21:49Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: add new example compile under MSVC&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Syntax ==&lt;br /&gt;
*'''gettimestr'''(&amp;lt;&amp;quot;format&amp;quot;&amp;gt;, &amp;lt;max length&amp;gt;);&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
This function returns the current system time and date as a string, according to given ''format'', which has same syntax as the one of C library function [http://www.cplusplus.com/reference/clibrary/ctime/strftime/ strftime]. The parameter ''max length'' specifies the maximum length of the string returned.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
 [[mes]] gettimestr(&amp;quot;%Y-%m/%d %H:%M:%S&amp;quot;,21);&lt;br /&gt;
Would print out the full current date and time, ex. &amp;quot;2010-10/30 07:48:37&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Example compile under MSVC ===&lt;br /&gt;
This example compile under MSVC 2010&lt;br /&gt;
 prontera,156,192,6	script	Time Sample	8W_SOLDIER,{&lt;br /&gt;
 	mes &amp;quot;System Tick : &amp;quot;+ gettimetick(0);&lt;br /&gt;
 	mes &amp;quot; Time Tick  : &amp;quot;+ gettimetick(1);&lt;br /&gt;
 	mes &amp;quot; UNIX Tick  : &amp;quot;+ gettimetick(2);&lt;br /&gt;
 	mes &amp;quot; GetTime(1) : &amp;quot;+ gettime(GETTIME_SECOND) +&amp;quot; (Sec)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(2) : &amp;quot;+ gettime(GETTIME_MINUTE) +&amp;quot; (Min)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(3) : &amp;quot;+ gettime(GETTIME_HOUR) +&amp;quot; (Hour)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(4) : &amp;quot;+ gettime(GETTIME_WEEKDAY) +&amp;quot; (WeekDay)&amp;quot;; // (day in the week 0~6)&lt;br /&gt;
 	mes &amp;quot; GetTime(5) : &amp;quot;+ gettime(GETTIME_DAYOFMONTH) +&amp;quot; (MonthDay)&amp;quot;; // (Day of the month)&lt;br /&gt;
 	mes &amp;quot; GetTime(6) : &amp;quot;+ gettime(GETTIME_MONTH) +&amp;quot; (Month)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(7) : &amp;quot;+ gettime(GETTIME_YEAR) +&amp;quot; (Year)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(8) : &amp;quot;+ gettime(GETTIME_DAYOFYEAR) +&amp;quot; (No.day in year)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTimeStr : %Y-%m/%d %H:%M:%S,40&amp;quot;;&lt;br /&gt;
 	mes gettimestr(&amp;quot;%Y-%m/%d %H:%M:%S&amp;quot;,40); // 2015-12/22 05:04:15&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%a : &amp;quot;+ gettimestr(&amp;quot;%a&amp;quot;,19); // Tue (short week)&lt;br /&gt;
 	mes &amp;quot;%A : &amp;quot;+ gettimestr(&amp;quot;%A&amp;quot;,19); // Tuesday (long week)&lt;br /&gt;
 	mes &amp;quot;%b : &amp;quot;+ gettimestr(&amp;quot;%b&amp;quot;,19); // Dec (short month)&lt;br /&gt;
 	mes &amp;quot;%B : &amp;quot;+ gettimestr(&amp;quot;%B&amp;quot;,19); // December (long month)&lt;br /&gt;
 	mes &amp;quot;%c : &amp;quot;+ gettimestr(&amp;quot;%c&amp;quot;,19); // 12/22/15 05:04:15 (== %x %X)&lt;br /&gt;
 	mes &amp;quot;%d : &amp;quot;+ gettimestr(&amp;quot;%d&amp;quot;,19); // 22 (day 01~31)&lt;br /&gt;
 	mes &amp;quot;%H : &amp;quot;+ gettimestr(&amp;quot;%H&amp;quot;,19); // 05 (hour 00~23)&lt;br /&gt;
 	mes &amp;quot;%I : &amp;quot;+ gettimestr(&amp;quot;%I&amp;quot;,19); // 05 (hour 01~12)&lt;br /&gt;
 	mes &amp;quot;%j : &amp;quot;+ gettimestr(&amp;quot;%j&amp;quot;,19); // 356 (day of the year)&lt;br /&gt;
 	mes &amp;quot;%m : &amp;quot;+ gettimestr(&amp;quot;%m&amp;quot;,19); // 12 (month 01~12)&lt;br /&gt;
 	mes &amp;quot;%M : &amp;quot;+ gettimestr(&amp;quot;%M&amp;quot;,19); // 04 (minute 00~59)&lt;br /&gt;
 	mes &amp;quot;%p : &amp;quot;+ gettimestr(&amp;quot;%p&amp;quot;,19); // AM (AM / PM)&lt;br /&gt;
 	mes &amp;quot;%S : &amp;quot;+ gettimestr(&amp;quot;%S&amp;quot;,19); // 15 (second 00~59)&lt;br /&gt;
 	mes &amp;quot;%U : &amp;quot;+ gettimestr(&amp;quot;%U&amp;quot;,19); // 51 (Week number with the first Sunday as the first day of week one (00-53))&lt;br /&gt;
 	mes &amp;quot;%w : &amp;quot;+ gettimestr(&amp;quot;%w&amp;quot;,19); // 2 (== gettime(GETTIME_WEEKDAY))&lt;br /&gt;
 	mes &amp;quot;%W : &amp;quot;+ gettimestr(&amp;quot;%W&amp;quot;,19); // 51 (Week number with the first Monday as the first day of week one (00-53))&lt;br /&gt;
 	mes &amp;quot;%x : &amp;quot;+ gettimestr(&amp;quot;%x&amp;quot;,19); // 12/22/15 (== %m/%d/%y)&lt;br /&gt;
 	mes &amp;quot;%X : &amp;quot;+ gettimestr(&amp;quot;%X&amp;quot;,19); // 05:04:15 (== %H:%M:%S)&lt;br /&gt;
 	mes &amp;quot;%y : &amp;quot;+ gettimestr(&amp;quot;%y&amp;quot;,19); // 15 (year 00~99)&lt;br /&gt;
 	mes &amp;quot;%Y : &amp;quot;+ gettimestr(&amp;quot;%Y&amp;quot;,19); // 2015 (year)&lt;br /&gt;
 	mes &amp;quot;%z : &amp;quot;+ gettimestr(&amp;quot;%z&amp;quot;,19); // cannot determine timezone, this is blank&lt;br /&gt;
 	mes &amp;quot;%Z : &amp;quot;+ gettimestr(&amp;quot;%Z&amp;quot;,19); // cannot determine timezone, this is blank&lt;br /&gt;
 	mes &amp;quot;%% : &amp;quot;+ gettimestr(&amp;quot;%%&amp;quot;,19); // print '%' sign&lt;br /&gt;
 	close;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Old Example compile under Cygwin ===&lt;br /&gt;
This example was compile under Cygwin provided by Bowiebowie. The script can be found [http://www.eathena.ws/board/index.php?s=&amp;amp;showtopic=181741&amp;amp;view=findpost&amp;amp;p=1329705 here].&lt;br /&gt;
 prontera.gat,157,181,6	script	Time Sample	105,{&lt;br /&gt;
 	mes &amp;quot;System Tick : &amp;quot;+ gettimetick(0);&lt;br /&gt;
 	mes &amp;quot; Time Tick  : &amp;quot;+ gettimetick(1);&lt;br /&gt;
 	mes &amp;quot; UNIX Tick  : &amp;quot;+ gettimetick(2);&lt;br /&gt;
 	mes &amp;quot; GetTime(1) : &amp;quot;+ gettime(1) +&amp;quot; (Sec)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(2) : &amp;quot;+ gettime(2) +&amp;quot; (Min)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(3) : &amp;quot;+ gettime(3) +&amp;quot; (Hour)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(4) : &amp;quot;+ gettime(4) +&amp;quot; (WeekDay)&amp;quot;; // (day in the week 0~6)&lt;br /&gt;
 	mes &amp;quot; GetTime(5) : &amp;quot;+ gettime(5) +&amp;quot; (MonthDay)&amp;quot;; // (Day of the month)&lt;br /&gt;
 	mes &amp;quot; GetTime(6) : &amp;quot;+ gettime(6) +&amp;quot; (Month)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(7) : &amp;quot;+ gettime(7) +&amp;quot; (Year)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTime(8) : &amp;quot;+ gettime(8) +&amp;quot; (No.day in year)&amp;quot;;&lt;br /&gt;
 	mes &amp;quot; GetTimeStr : %Y-%m/%d %H:%M:%S,40&amp;quot;;&lt;br /&gt;
 	mes gettimestr(&amp;quot;%Y-%m/%d %H:%M:%S&amp;quot;,40); // 2007-07/27 16:59:22&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%a : &amp;quot;+ gettimestr(&amp;quot;%a&amp;quot;,19); // Tue (short week)&lt;br /&gt;
 	mes &amp;quot;%A : &amp;quot;+ gettimestr(&amp;quot;%A&amp;quot;,19); // Tuesday (long week)&lt;br /&gt;
 	mes &amp;quot;%b : &amp;quot;+ gettimestr(&amp;quot;%b&amp;quot;,19); // Jul (short month)&lt;br /&gt;
 	mes &amp;quot;%B : &amp;quot;+ gettimestr(&amp;quot;%B&amp;quot;,19); // July (long month)&lt;br /&gt;
 	mes &amp;quot;%c : &amp;quot;+ gettimestr(&amp;quot;%c&amp;quot;,19); // Tue Jul 24 16:30&lt;br /&gt;
 	mes &amp;quot;%C : &amp;quot;+ gettimestr(&amp;quot;%C&amp;quot;,19); // 20 (year -&amp;gt;20&amp;lt;-07)&lt;br /&gt;
 	mes &amp;quot;%d : &amp;quot;+ gettimestr(&amp;quot;%d&amp;quot;,19); // 24 (day 01~31)&lt;br /&gt;
 	mes &amp;quot;%D : &amp;quot;+ gettimestr(&amp;quot;%D&amp;quot;,19); // 07/24/07 (month/day/year)&lt;br /&gt;
 	mes &amp;quot;%e : &amp;quot;+ gettimestr(&amp;quot;%e&amp;quot;,19); // 24 (day  1~31)&lt;br /&gt;
 	mes &amp;quot;%F : &amp;quot;+ gettimestr(&amp;quot;%F&amp;quot;,19); // 2007/07/24 (year/month/day)&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%g : &amp;quot;+ gettimestr(&amp;quot;%g&amp;quot;,19); // 07 (year 00~99)&lt;br /&gt;
 	mes &amp;quot;%G : &amp;quot;+ gettimestr(&amp;quot;%G&amp;quot;,19); // 2007 (year)&lt;br /&gt;
 	mes &amp;quot;%h : &amp;quot;+ gettimestr(&amp;quot;%h&amp;quot;,19); // Jul (short month) ( == %b )&lt;br /&gt;
 	mes &amp;quot;%H : &amp;quot;+ gettimestr(&amp;quot;%H&amp;quot;,19); // 16 (hour 00~23)&lt;br /&gt;
 	mes &amp;quot;%I : &amp;quot;+ gettimestr(&amp;quot;%I&amp;quot;,19); // 04 (hour 01~12)&lt;br /&gt;
 	mes &amp;quot;%j : &amp;quot;+ gettimestr(&amp;quot;%j&amp;quot;,19); // 205 (day of the year)&lt;br /&gt;
 	mes &amp;quot;%k : &amp;quot;+ gettimestr(&amp;quot;%k&amp;quot;,19); // 16 (hour  0~23)&lt;br /&gt;
 	mes &amp;quot;%l : &amp;quot;+ gettimestr(&amp;quot;%l&amp;quot;,19); //  4 (hour  1~12)&lt;br /&gt;
 	mes &amp;quot;%m : &amp;quot;+ gettimestr(&amp;quot;%m&amp;quot;,19); // 07 (month 01~12)&lt;br /&gt;
 	mes &amp;quot;%M : &amp;quot;+ gettimestr(&amp;quot;%M&amp;quot;,19); // 30 (minute 00~59)&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%p : &amp;quot;+ gettimestr(&amp;quot;%p&amp;quot;,19); // PM ( AM / PM )&lt;br /&gt;
 //	mes &amp;quot;%p : &amp;quot;+ gettimestr(&amp;quot;%P&amp;quot;,19); // pm ( am / pm ) &amp;lt;-- not supported !!&lt;br /&gt;
 	mes &amp;quot;%r : &amp;quot;+ gettimestr(&amp;quot;%r&amp;quot;,19); // 4:30:00 PM ( == %I:%M:%S %p )&lt;br /&gt;
 	mes &amp;quot;%R : &amp;quot;+ gettimestr(&amp;quot;%R&amp;quot;,19); // 16:30 (==%H:%M)&lt;br /&gt;
 	mes &amp;quot;%S : &amp;quot;+ gettimestr(&amp;quot;%S&amp;quot;,19); // 57 (second 00~59)&lt;br /&gt;
 	mes &amp;quot;%T : &amp;quot;+ gettimestr(&amp;quot;%T&amp;quot;,19); // 16:30:00 (hour:minute:sec)&lt;br /&gt;
 	mes &amp;quot;%u : &amp;quot;+ gettimestr(&amp;quot;%u&amp;quot;,19); // 2 (number of the week 1~7, Sun = 7)&lt;br /&gt;
 	mes &amp;quot;%U : &amp;quot;+ gettimestr(&amp;quot;%U&amp;quot;,19); // 29 (range 00 through 53), starting with the first Sunday as the first day of the first week. Days preceding the first Sunday in the year are considered to be in week 00.&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;%V : &amp;quot;+ gettimestr(&amp;quot;%V&amp;quot;,19); // 30 (range 01 through 53). ISO weeks start with Monday and end with Sunday. Week 01 of a year is the first week which has the majority of its days in that year; this is equivalent to the week containing the year's first Thursday, and it is also equivalent to the week containing January 4. Week 01 of a year can contain days from the previous year. The week before week 01 of a year is the last week (52 or 53) of the previous year even if it contains days from the new year.&lt;br /&gt;
 	mes &amp;quot;%w : &amp;quot;+ gettimestr(&amp;quot;%w&amp;quot;,19); // 2 (number of the week 0~6, Sun = 0)&lt;br /&gt;
 	mes &amp;quot;%W : &amp;quot;+ gettimestr(&amp;quot;%W&amp;quot;,19); // 30 (The week number of the current year as a decimal number (range 00 through 53), starting with the first Monday as the first day of the first week. All days preceding the first Monday in the year are considered to be in week 00.)&lt;br /&gt;
 	mes &amp;quot;%x : &amp;quot;+ gettimestr(&amp;quot;%x&amp;quot;,19); // 07/24/07&lt;br /&gt;
 	mes &amp;quot;%X : &amp;quot;+ gettimestr(&amp;quot;%X&amp;quot;,19); // 16:40:23&lt;br /&gt;
 	close;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-20T12:35:52Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: dunno why it doesn't work ... I even deleted the old one already, and yet it still shows up ?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
There are 2 guides on how to prepare your MSVC environment for a new [[HPM]] plugin. You can choose to follow either one.&lt;br /&gt;
== New Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Download the '''YourProject.c''' file in the '''\src\plugins\''' folder&lt;br /&gt;
[[File:MSVC step0.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
If using MSVC 2010, navigate to \vcproj-10\&lt;br /&gt;
[[File:MSVC step1.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Select '''plugin-sample.vcxproj''', copy paste it&lt;br /&gt;
[[File:MSVC step2.png|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Rename '''plugin-sample - Copy.vcxproj''' into '''YourProject.vcxproj'''&amp;lt;br&amp;gt;&lt;br /&gt;
While renaming, Highlight the word '''YourProject''' and Copy it by ''Ctrl+C''&lt;br /&gt;
[[File:MSVC step3.png|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right-Click on '''YourFile.vcxproj''', Select '''Edit with Notepad++''', or Microsoft Notepad&lt;br /&gt;
[[File:MSVC step4.png|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ProjectName&amp;gt;plugin-sample&amp;lt;/ProjectName&amp;gt;&lt;br /&gt;
[[File:MSVC step5.png|center|750px]]&lt;br /&gt;
Rename '''plugin-sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step5 .png|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;sample&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;YourProject&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6 .png|center|750px]]&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ClCompile Include=&amp;quot;..\src\plugins\sample.c&amp;quot; /&amp;gt;&lt;br /&gt;
[[File:MSVC step7.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step7 .png|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Press '''Ctrl+S''' to save the file.&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Open MSVC, Right-click '''Hercules-10''', Select '''Add'' -&amp;gt; '''Existing Project...'''&lt;br /&gt;
[[File:MSVC step9.png|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
Select '''YourProject.vcxproj''' in the '''\vcproj-10\''' folder&lt;br /&gt;
[[File:MSVC step10.png|center|600px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
Right-click '''Hercules-10''', Select '''Build-Solution'''&lt;br /&gt;
[[File:MSVC step11.png|center|600px]]&lt;br /&gt;
== Old Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Another method idea by hemagx, sorry for publish it first - AnnieRuru.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-20T12:34:22Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: try get the latest screenshot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
There are 2 guides on how to prepare your MSVC environment for a new [[HPM]] plugin. You can choose to follow either one.&lt;br /&gt;
== New Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Download the '''YourProject.c''' file in the '''\src\plugins\''' folder&lt;br /&gt;
[[File:MSVC step0.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
If using MSVC 2010, navigate to \vcproj-10\&lt;br /&gt;
[[File:MSVC step1.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Select '''plugin-sample.vcxproj''', copy paste it&lt;br /&gt;
[[File:MSVC step2.png|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Rename '''plugin-sample - Copy.vcxproj''' into '''YourProject.vcxproj'''&amp;lt;br&amp;gt;&lt;br /&gt;
While renaming, Highlight the word '''YourProject''' and Copy it by ''Ctrl+C''&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right-Click on '''YourFile.vcxproj''', Select '''Edit with Notepad++''', or Microsoft Notepad&lt;br /&gt;
[[File:MSVC step4.png|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ProjectName&amp;gt;plugin-sample&amp;lt;/ProjectName&amp;gt;&lt;br /&gt;
[[File:MSVC step5.png|center|750px]]&lt;br /&gt;
Rename '''plugin-sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step5 .png|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;sample&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;YourProject&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6 .png|center|750px]]&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ClCompile Include=&amp;quot;..\src\plugins\sample.c&amp;quot; /&amp;gt;&lt;br /&gt;
[[File:MSVC step7.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step7 .png|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Press '''Ctrl+S''' to save the file.&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Open MSVC, Right-click '''Hercules-10''', Select '''Add'' -&amp;gt; '''Existing Project...'''&lt;br /&gt;
[[File:MSVC step9.png|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
Select '''YourProject.vcxproj''' in the '''\vcproj-10\''' folder&lt;br /&gt;
[[File:MSVC step10.png|center|600px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
Right-click '''Hercules-10''', Select '''Build-Solution'''&lt;br /&gt;
[[File:MSVC step11.png|center|600px]]&lt;br /&gt;
== Old Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Another method idea by hemagx, sorry for publish it first - AnnieRuru.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step3.png</id>
		<title>File:MSVC step3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step3.png"/>
				<updated>2015-12-20T12:26:16Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Annieruru uploaded a new version of &amp;amp;quot;File:MSVC step3.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-20T12:13:46Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Totally forgot to tell where to paste the file =.=&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
There are 2 guides on how to prepare your MSVC environment for a new [[HPM]] plugin. You can choose to follow either one.&lt;br /&gt;
== New Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Download the '''YourProject.c''' file in the '''\src\plugins\''' folder&lt;br /&gt;
[[File:MSVC step0.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
If using MSVC 2010, navigate to \vcproj-10\&lt;br /&gt;
[[File:MSVC step1.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Select '''plugin-sample.vcxproj''', copy paste it&lt;br /&gt;
[[File:MSVC step2.png|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Rename '''plugin-sample - Copy.vcxproj''' into '''YourProject.vcxproj'''&amp;lt;br&amp;gt;&lt;br /&gt;
While renaming, Highlight the word '''YourProject''' and Copy it by ''Ctrl+C''&lt;br /&gt;
[[File:MSVC step3.png|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right-Click on '''YourFile.vcxproj''', Select '''Edit with Notepad++''', or Microsoft Notepad&lt;br /&gt;
[[File:MSVC step4.png|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ProjectName&amp;gt;plugin-sample&amp;lt;/ProjectName&amp;gt;&lt;br /&gt;
[[File:MSVC step5.png|center|750px]]&lt;br /&gt;
Rename '''plugin-sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step5 .png|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;sample&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;YourProject&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6 .png|center|750px]]&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ClCompile Include=&amp;quot;..\src\plugins\sample.c&amp;quot; /&amp;gt;&lt;br /&gt;
[[File:MSVC step7.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step7 .png|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Press '''Ctrl+S''' to save the file.&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Open MSVC, Right-click '''Hercules-10''', Select '''Add'' -&amp;gt; '''Existing Project...'''&lt;br /&gt;
[[File:MSVC step9.png|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
Select '''YourProject.vcxproj''' in the '''\vcproj-10\''' folder&lt;br /&gt;
[[File:MSVC step10.png|center|600px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
Right-click '''Hercules-10''', Select '''Build-Solution'''&lt;br /&gt;
[[File:MSVC step11.png|center|600px]]&lt;br /&gt;
== Old Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Another method idea by hemagx, sorry for publish it first - AnnieRuru.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step0.png</id>
		<title>File:MSVC step0.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step0.png"/>
				<updated>2015-12-20T12:08:55Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-20T11:45:05Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: sorry there is no step 12, that message is from Notepad++ wahahaha&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
There are 2 guides on how to prepare your MSVC environment for a new [[HPM]] plugin. You can choose to follow either one.&lt;br /&gt;
== New Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
If using MSVC 2010, navigate to \vcproj-10\&lt;br /&gt;
[[File:MSVC step1.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Select '''plugin-sample.vcxproj''', copy paste it&lt;br /&gt;
[[File:MSVC step2.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Rename '''plugin-sample - Copy.vcxproj''' into '''YourProject.vcxproj'''&amp;lt;br&amp;gt;&lt;br /&gt;
While renaming, Highlight the word '''YourProject''' and Copy it by ''Ctrl+C''&lt;br /&gt;
[[File:MSVC step3.png|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Right-Click on '''YourFile.vcxproj''', Select '''Edit with Notepad++''', or Microsoft Notepad&lt;br /&gt;
[[File:MSVC step4.png|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ProjectName&amp;gt;plugin-sample&amp;lt;/ProjectName&amp;gt;&lt;br /&gt;
[[File:MSVC step5.png|center|750px]]&lt;br /&gt;
Rename '''plugin-sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step5 .png|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;sample&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;YourProject&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6 .png|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ClCompile Include=&amp;quot;..\src\plugins\sample.c&amp;quot; /&amp;gt;&lt;br /&gt;
[[File:MSVC step7.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step7 .png|center|750px]]&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
Press '''Ctrl+S''' to save the file.&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Open MSVC, Right-click '''Hercules-10''', Select '''Add'' -&amp;gt; '''Existing Project...'''&lt;br /&gt;
[[File:MSVC step9.png|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Select '''YourProject.vcxproj''' in the '''\vcproj-10\''' folder&lt;br /&gt;
[[File:MSVC step10.png|center|600px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
Right-click '''Hercules-10''', Select '''Build-Solution'''&lt;br /&gt;
[[File:MSVC step11.png|center|600px]]&lt;br /&gt;
'''You are Done !'''&lt;br /&gt;
&lt;br /&gt;
== Old Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Another method idea by hemagx, sorry for publish it first - AnnieRuru.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-20T11:40:54Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: found out copy paste the word is even faster&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
There are 2 guides on how to prepare your MSVC environment for a new [[HPM]] plugin. You can choose to follow either one.&lt;br /&gt;
== New Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
If using MSVC 2010, navigate to \vcproj-10\&lt;br /&gt;
[[File:MSVC step1.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Select '''plugin-sample.vcxproj''', copy paste it&lt;br /&gt;
[[File:MSVC step2.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Rename '''plugin-sample - Copy.vcxproj''' into '''YourProject.vcxproj'''&amp;lt;br&amp;gt;&lt;br /&gt;
While renaming, Highlight the word '''YourProject''' and Copy it by ''Ctrl+C''&lt;br /&gt;
[[File:MSVC step3.png|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Right-Click on '''YourFile.vcxproj''', Select '''Edit with Notepad++''', or Microsoft Notepad&lt;br /&gt;
[[File:MSVC step4.png|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ProjectName&amp;gt;plugin-sample&amp;lt;/ProjectName&amp;gt;&lt;br /&gt;
[[File:MSVC step5.png|center|750px]]&lt;br /&gt;
Rename '''plugin-sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step5 .png|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;sample&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;YourProject&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6 .png|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ClCompile Include=&amp;quot;..\src\plugins\sample.c&amp;quot; /&amp;gt;&lt;br /&gt;
[[File:MSVC step7.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject''' by ''Ctrl+V''&lt;br /&gt;
[[File:MSVC step7 .png|center|750px]]&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
Press '''Ctrl+S''' to save the file.&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Open MSVC, Right-click '''Hercules-10''', Select '''Add'' -&amp;gt; '''Existing Project...'''&lt;br /&gt;
[[File:MSVC step9.png|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Select '''YourProject.vcxproj''' in the '''\vcproj-10\''' folder&lt;br /&gt;
[[File:MSVC step10.png|center|600px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
Right-click '''Hercules-10''', Select '''Build-Solution'''&lt;br /&gt;
[[File:MSVC step11.png|center|600px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
You are Done !&lt;br /&gt;
After a while, after running '''run-server.bat''', and come back to MSVC, this message pops up, Select '''Yes'''&lt;br /&gt;
[[File:MSVC step12.png|center|400px]]&lt;br /&gt;
&lt;br /&gt;
== Old Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Another method idea by hemagx, sorry for publish it first - AnnieRuru.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-20T11:09:07Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
There are 2 guides on how to prepare your MSVC environment for a new [[HPM]] plugin. You can choose to follow either one.&lt;br /&gt;
== New Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
If using MSVC 2010, navigate to \vcproj-10\&lt;br /&gt;
[[File:MSVC step1.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Select '''plugin-sample.vcxproj''', copy paste it&lt;br /&gt;
[[File:MSVC step2.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Rename '''plugin-sample - Copy.vcxproj''' into '''YourProject.vcxproj'''&lt;br /&gt;
[[File:MSVC step3.png|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Right-Click on '''YourFile.vcxproj''', Select '''Edit with Notepad++''', or Microsoft Notepad&lt;br /&gt;
[[File:MSVC step4.png|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ProjectName&amp;gt;plugin-sample&amp;lt;/ProjectName&amp;gt;&lt;br /&gt;
[[File:MSVC step5.png|center|750px]]&lt;br /&gt;
Rename '''plugin-sample''' to '''YourProject'''&lt;br /&gt;
[[File:MSVC step5 .png|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;sample&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject'''&lt;br /&gt;
 &amp;lt;TargetName Condition=&amp;quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&amp;quot;&amp;gt;YourProject&amp;lt;/TargetName&amp;gt;&lt;br /&gt;
[[File:MSVC step6 .png|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Find this line&lt;br /&gt;
 &amp;lt;ClCompile Include=&amp;quot;..\src\plugins\sample.c&amp;quot; /&amp;gt;&lt;br /&gt;
[[File:MSVC step7.png|center|750px]]&lt;br /&gt;
Rename '''sample''' to '''YourProject'''&lt;br /&gt;
[[File:MSVC step7 .png|center|750px]]&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
Press '''Ctrl+S''' to save the file.&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Open MSVC, Right-click '''Hercules-10''', Select '''Add'' -&amp;gt; '''Existing Project...'''&lt;br /&gt;
[[File:MSVC step9.png|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Select '''YourProject.vcxproj''' in the '''\vcproj-10\''' folder&lt;br /&gt;
[[File:MSVC step10.png|center|600px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
Right-click '''Hercules-10''', Select '''Build-Solution'''&lt;br /&gt;
[[File:MSVC step11.png|center|600px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
You are Done !&lt;br /&gt;
After a while, after running '''run-server.bat''', and come back to MSVC, this message pops up, Select '''Yes'''&lt;br /&gt;
[[File:MSVC step12.png|center|400px]]&lt;br /&gt;
&lt;br /&gt;
== Old Method ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Another method idea by hemagx, sorry for publish it first - AnnieRuru.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step7_.png</id>
		<title>File:MSVC step7 .png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step7_.png"/>
				<updated>2015-12-20T11:01:01Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step6_.png</id>
		<title>File:MSVC step6 .png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step6_.png"/>
				<updated>2015-12-20T11:00:43Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step5_.png</id>
		<title>File:MSVC step5 .png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step5_.png"/>
				<updated>2015-12-20T11:00:24Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step11.png</id>
		<title>File:MSVC step11.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step11.png"/>
				<updated>2015-12-20T10:59:13Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Annieruru uploaded a new version of &amp;amp;quot;File:MSVC step11.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step12.png</id>
		<title>File:MSVC step12.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step12.png"/>
				<updated>2015-12-20T10:28:43Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step11.png</id>
		<title>File:MSVC step11.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step11.png"/>
				<updated>2015-12-20T10:28:26Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step10.png</id>
		<title>File:MSVC step10.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step10.png"/>
				<updated>2015-12-20T10:27:54Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step9.png</id>
		<title>File:MSVC step9.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step9.png"/>
				<updated>2015-12-20T10:27:21Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step7.png</id>
		<title>File:MSVC step7.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step7.png"/>
				<updated>2015-12-20T10:26:36Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step6.png</id>
		<title>File:MSVC step6.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step6.png"/>
				<updated>2015-12-20T10:26:17Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step5.png</id>
		<title>File:MSVC step5.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step5.png"/>
				<updated>2015-12-20T10:25:42Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step4.png</id>
		<title>File:MSVC step4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step4.png"/>
				<updated>2015-12-20T10:25:25Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step3.png</id>
		<title>File:MSVC step3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step3.png"/>
				<updated>2015-12-20T10:25:04Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step2.png</id>
		<title>File:MSVC step2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step2.png"/>
				<updated>2015-12-20T10:24:17Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:MSVC_step1.png</id>
		<title>File:MSVC step1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:MSVC_step1.png"/>
				<updated>2015-12-20T10:23:50Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-13T05:34:13Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
&amp;lt;br&amp;gt;This step can prevent errors like ''sscanf'' or ''sprintf'' that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-13T05:33:16Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Add explanation in-case some members don't understand what this step does ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
This step can prevent errors like sscanf or sprintf that only happen with Microsoft compiler.&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-13T05:13:42Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: This step-18 should prevent member says sscanf throw error on microsoft builds, found in sample property page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Advanced''', on '''Disable Specific Warnings''' add '''4996;%(DisableSpecificWarnings)'''&lt;br /&gt;
[[File:step18.png|center|750px]]&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 20 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:Step18.png</id>
		<title>File:Step18.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:Step18.png"/>
				<updated>2015-12-13T05:01:06Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Found this in sample property page.
It's time to disable these stupid warnings from stupid Microsoft builds.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Found this in sample property page.&lt;br /&gt;
It's time to disable these stupid warnings from stupid Microsoft builds.&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-13T04:45:34Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Remove the PCRE_SUPPORT sub-section as Haru already did the correct fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Add additional steps for PCRE_SUPPORT, credit to hemagx for the info, which he claimed that came from Haru&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Hercules_Hierarchy</id>
		<title>Hercules Hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Hercules_Hierarchy"/>
				<updated>2015-12-13T04:41:45Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Add Frost @ Jedzkie, lol he is soo active in github&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Staff Titles =&lt;br /&gt;
Ordered alphabetically.&amp;lt;br/&amp;gt;All staff titles, regardless of their description, possesses full moderation powers.&lt;br /&gt;
&lt;br /&gt;
== Administrators ==&lt;br /&gt;
They administrate.&lt;br /&gt;
* [http://herc.ws/board/user/307-haru/ Haru] ([http://herc.ws/board/index.php?app=members&amp;amp;filter=4 Development Administrator])&lt;br /&gt;
* [http://herc.ws/board/user/43-mysterious/ Mysterious] ([http://herc.ws/board/index.php?app=members&amp;amp;filter=4 Community Administrator])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Core Developers ==&lt;br /&gt;
The kings of the code hill.&lt;br /&gt;
* [http://herc.ws/board/user/7100-4144/ 4144]&lt;br /&gt;
* [http://herc.ws/board/user/45-hemagx/ hemagx]&lt;br /&gt;
* [http://herc.ws/board/user/20-malufett/ malufett]&lt;br /&gt;
* [http://herc.ws/board/user/49-mkbu95/ mkbu95]&lt;br /&gt;
* [http://herc.ws/board/user/4055-pan/ Pan]&lt;br /&gt;
* [http://herc.ws/board/user/50-michieru/ Michieru]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script Developers ==&lt;br /&gt;
Usually the members with the fastest key/second typing ratio.&lt;br /&gt;
* [http://herc.ws/board/user/48-dastgir/ Dastgir]&lt;br /&gt;
* [http://herc.ws/board/user/1664-kisuka/ Kisuka]&lt;br /&gt;
* [http://herc.ws/board/user/82-frost/ Frost]&lt;br /&gt;
&lt;br /&gt;
== Scripting Moderators ==&lt;br /&gt;
* [http://herc.ws/board/user/4102-annieruru/ AnnieRuru]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Global Moderators ==&lt;br /&gt;
Global Moderators are individuals who moderate all of the forums excluding International Communities, however, may still moderate.&amp;lt;br/&amp;gt;&lt;br /&gt;
Global Moderator ensure that all of the forums are cleaned by removing duplicate topics, ensuring posts/topics don't have spam, moving topics where need be, and locking topics.&amp;lt;br/&amp;gt;&lt;br /&gt;
Global Moderators also provide support to support topics, however, not to an extent as Support Leaders. This is not a position one can apply to, but be promoted to from other moderation position thanks to one's efforts and commitment to moderation.&lt;br /&gt;
* [http://herc.ws/board/user/387-jabote/ jaBote]&lt;br /&gt;
* [http://herc.ws/board/user/83-mumbles/ Mumbles]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Support Leaders ==&lt;br /&gt;
In charge of all the main supporting areas.&lt;br /&gt;
* [http://herc.ws/board/user/4149-aeromesi/ Aeromesi]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics Moderators ==&lt;br /&gt;
In charge of all the main graphics areas.&lt;br /&gt;
* [http://herc.ws/board/user/1460-uzieal/ Uzieal]&lt;br /&gt;
* [http://herc.ws/board/user/11-olrox/ Orlox]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Int'l Moderators ==&lt;br /&gt;
International Moderators are individuals who moderate their respective International Community.&amp;lt;br/&amp;gt;&lt;br /&gt;
They are solely responsible in making sure their respective community is cleaned by moving, locking, removing, and cleaning topics of spams.&amp;lt;br/&amp;gt;&lt;br /&gt;
International Moderators don't have sole responsibility of other forums outside their community and they must provide support to individuals in their community.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Filipino====&lt;br /&gt;
* [http://herc.ws/board/user/1582-mhalicot/ Mhalicot]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Portuguese====&lt;br /&gt;
* [http://herc.ws/board/user/63-juliocf/ JulioCF]&lt;br /&gt;
* [http://herc.ws/board/user/192-wolf/ Wolf]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Spanish====&lt;br /&gt;
* [http://herc.ws/board/user/125-m45t3r/ M45T3R]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== High Council ==&lt;br /&gt;
They're an upgrade from the [[#Community_Contributor | Community Contributor]] title.&lt;br /&gt;
* [http://herc.ws/board/user/59-beret/ Beret]&lt;br /&gt;
* [http://herc.ws/board/user/6674-csnv/ csnv]&lt;br /&gt;
* [http://herc.ws/board/user/6-eiphes/ Eiphes]&lt;br /&gt;
* [http://herc.ws/board/user/8-eurydice/ Eurydice]&lt;br /&gt;
* [http://herc.ws/board/user/1160-gepard/ Gepard]&lt;br /&gt;
* [http://herc.ws/board/user/88-kyeme/ kyeme]&lt;br /&gt;
* [http://herc.ws/board/user/99-muad_dib/ Muad_Dib]&lt;br /&gt;
* [http://herc.ws/board/user/456-rytech/ Rytech]&lt;br /&gt;
* [http://herc.ws/board/user/409-yommy/ Yommy]&lt;br /&gt;
* [http://herc.ws/board/user/67-xgear/ Xgear]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Former Staff Members =&lt;br /&gt;
Former staff members who've contributed throughout Hercules.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Administrators ==&lt;br /&gt;
* [http://herc.ws/board/user/1-ind/ Ind]&lt;br /&gt;
* [http://herc.ws/board/user/2-jman/ Jman]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Core Developers ==&lt;br /&gt;
* [http://herc.ws/board/user/28-greenbox/ GreenBox] &lt;br /&gt;
* [http://herc.ws/board/user/725-susu/ Susu]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Script Developers ==&lt;br /&gt;
* [http://herc.ws/board/user/756-joseph/ Joseph]&lt;br /&gt;
* [http://herc.ws/board/user/5-kenpachi/ Kenpachi]&lt;br /&gt;
* [http://herc.ws/board/user/23-martin/ Martin]&lt;br /&gt;
* [http://herc.ws/board/user/757-masao/ Masao]&lt;br /&gt;
* [http://herc.ws/board/user/7-nameless2you/ Nameless2you]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Scripting Moderators ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Global Moderators ==&lt;br /&gt;
* [http://herc.ws/board/user/10-judas/ Judas]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Support Leaders ==&lt;br /&gt;
* [http://herc.ws/board/user/4-emistry/ Emistry]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former Graphic Moderators ==&lt;br /&gt;
* [http://herc.ws/board/user/129-adel/ Adel]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Former International Moderators ==&lt;br /&gt;
==== Filipino ====&lt;br /&gt;
* [http://herc.ws/board/user/25-jaypee/ JayPee]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Community Contributors =&lt;br /&gt;
This title is awarded to community members for their outstanding support of Hercules. For more information, [http://herc.ws/board/topic/376-hercules-cc-program/ read the thread about it on the forum.]&lt;br /&gt;
* [http://herc.ws/board/user/137-bgamez23/ bgamez23]&lt;br /&gt;
* [http://herc.ws/board/user/1352-evilpuncker/ evilpuncker]&lt;br /&gt;
* [http://herc.ws/board/user/5970-gmocean/ GmOcean]&lt;br /&gt;
* [http://herc.ws/board/user/118-mleo1/ mleo1]&lt;br /&gt;
* [http://herc.ws/board/user/315-neo/ Neo]&lt;br /&gt;
* [http://herc.ws/board/user/87-ossi0110/ ossi0110]&lt;br /&gt;
* [http://herc.ws/board/user/449-patskie/ Patskie]&lt;br /&gt;
* [http://herc.ws/board/user/303-ryuuzaki/ Ryuuzaki]&lt;br /&gt;
* [http://herc.ws/board/user/297-shakto/ Shakto]&lt;br /&gt;
&lt;br /&gt;
[[Category:Hercules]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-11T14:49:43Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: I just noticed the step2 is outdated format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;common/hercules.h&amp;quot; // Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces)&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;map/pc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;common/HPMDataCheck.h&amp;quot; // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo = {&lt;br /&gt;
	&amp;quot;dance&amp;quot;,		// Plugin name&lt;br /&gt;
	SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
	&amp;quot;0.2&amp;quot;,			// Plugin version&lt;br /&gt;
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance) {&lt;br /&gt;
	if (!message || !*message) {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( atoi(message) == 1 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 2 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 3 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 4 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 5 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 6 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 7 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 8 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
	} else if ( atoi(message) == 9 ) {&lt;br /&gt;
		clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
	} else {&lt;br /&gt;
		clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void) {&lt;br /&gt;
	addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== PCRE_SUPPORT ==&lt;br /&gt;
Although previously on step-17 has included PCRE_SUPPORT, but it was just to prevent the error message on map-server if the plugin has included npc.h. To properly make use of the PCRE interface, there are 2 additional steps.&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''Input''', On '''Additional Dependencies''', Add '''pcre.lib;''' at the beginning.&lt;br /&gt;
[[File:Pcre support step1.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', On '''Additional Library Directory''', Add '''..\3rdparty\pcre\lib;'''&lt;br /&gt;
[[File:Pcre support step2.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
And don't forget to include pcre.h in your plugin&lt;br /&gt;
 #include &amp;quot;../3rdparty/pcre/include/pcre.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Add additional steps for PCRE_SUPPORT, credit to hemagx for the info, which he claimed that came from Haru&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-11T14:42:20Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: forgot to include pcre.h&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;../common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;../map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;../map/pc.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;../common/HPMDataCheck.h&amp;quot;    //Should always be the last include file.&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo =&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;@dance&amp;quot;,		// Plugin name&lt;br /&gt;
    SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
    &amp;quot;0.1a&amp;quot;,			// Plugin version&lt;br /&gt;
    HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      if (!message || !*message) {&lt;br /&gt;
		  clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
return -1;&lt;br /&gt;
   }&lt;br /&gt;
   if ( atoi(message) == 1 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 2 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 3 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 4 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 5 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 6 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 7 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 8 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 9 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
   }&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
	clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
   return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void)&lt;br /&gt;
{&lt;br /&gt;
    clif = GET_SYMBOL(&amp;quot;clif&amp;quot;);&lt;br /&gt;
    script = GET_SYMBOL(&amp;quot;script&amp;quot;);&lt;br /&gt;
    skill = GET_SYMBOL(&amp;quot;skill&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== PCRE_SUPPORT ==&lt;br /&gt;
Although previously on step-17 has included PCRE_SUPPORT, but it was just to prevent the error message on map-server if the plugin has included npc.h. To properly make use of the PCRE interface, there are 2 additional steps.&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''Input''', On '''Additional Dependencies''', Add '''pcre.lib;''' at the beginning.&lt;br /&gt;
[[File:Pcre support step1.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', On '''Additional Library Directory''', Add '''..\3rdparty\pcre\lib;'''&lt;br /&gt;
[[File:Pcre support step2.png|center|750px]]&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
And don't forget to include pcre.h in your plugin&lt;br /&gt;
 #include &amp;quot;../3rdparty/pcre/include/pcre.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Add additional steps for PCRE_SUPPORT, credit to hemagx for the info, which he claimed that came from Haru&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC</id>
		<title>Building HPM Plugin for MSVC</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Building_HPM_Plugin_for_MSVC"/>
				<updated>2015-12-11T14:27:17Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: Change step by step into sub-header, and add support of PCRE_SUPPORT interface&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Guide =&lt;br /&gt;
This is a guide on how to prepare your MSVC environment for a new [[HPM]] plugin.&lt;br /&gt;
== Installation ==&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Go to '''src/plugins/''' folder, create a new '''.c''' file, e.g. '''dance.c''' (this name will be used throughout this guide)&lt;br /&gt;
[[File:step1.JPG|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Open dance.c and paste this code&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;../common/HPMi.h&amp;quot;&lt;br /&gt;
#include &amp;quot;../map/script.h&amp;quot;&lt;br /&gt;
#include &amp;quot;../map/pc.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;../common/HPMDataCheck.h&amp;quot;    //Should always be the last include file.&lt;br /&gt;
&lt;br /&gt;
HPExport struct hplugin_info pinfo =&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;@dance&amp;quot;,		// Plugin name&lt;br /&gt;
    SERVER_TYPE_MAP,// Which server types this plugin works with?&lt;br /&gt;
    &amp;quot;0.1a&amp;quot;,			// Plugin version&lt;br /&gt;
    HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
ACMD(dance)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      if (!message || !*message) {&lt;br /&gt;
		  clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;);&lt;br /&gt;
return -1;&lt;br /&gt;
   }&lt;br /&gt;
   if ( atoi(message) == 1 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 413, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 2 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 414, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 3 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 415, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 4 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 426, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 5 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 458, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 6 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 466, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 7 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 501, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 8 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 540, ALL_CLIENT);&lt;br /&gt;
   } else if ( atoi(message) == 9 ) {&lt;br /&gt;
clif-&amp;gt;specialeffect(&amp;amp;sd-&amp;gt;bl, 550, ALL_CLIENT);&lt;br /&gt;
   }&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
	clif-&amp;gt;message(fd, &amp;quot;usage: @dance 1-9&amp;quot;); &lt;br /&gt;
	}&lt;br /&gt;
   return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Server Startup */&lt;br /&gt;
HPExport void plugin_init (void)&lt;br /&gt;
{&lt;br /&gt;
    clif = GET_SYMBOL(&amp;quot;clif&amp;quot;);&lt;br /&gt;
    script = GET_SYMBOL(&amp;quot;script&amp;quot;);&lt;br /&gt;
    skill = GET_SYMBOL(&amp;quot;skill&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    addAtcommand(&amp;quot;dance&amp;quot;,dance);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
Open your MSVC project (e.g. '''Hercules-10.sln'')&lt;br /&gt;
[[File:step2.JPG|center|750px]]&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
Go to the '''Solution Explorer'''&lt;br /&gt;
[[File:step3.JPG|center|750px]]&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
Right click the Hercules project (first item in '''Solution Explorer'''), and click '''Add-&amp;gt;New Project'''&lt;br /&gt;
[[File:step4.JPG|center|750px]]&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
Select '''General''', and pick '''Empty Project'''.&lt;br /&gt;
[[File:step5.JPG|center|750px]]&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
Enter the name of your plugin in the '''Name''' field, and click OK.&lt;br /&gt;
=== Step 8 ===&lt;br /&gt;
In the solution explorer it'll display the new project.&lt;br /&gt;
[[File:step6.JPG|center|750px]]&lt;br /&gt;
=== Step 9 ===&lt;br /&gt;
Right click the new project, and open '''Add-&amp;gt;Existing Item'''&lt;br /&gt;
[[File:step7.JPG|center|750px]]&lt;br /&gt;
=== Step 10 ===&lt;br /&gt;
Browse to '''src/plugins/''' and select the '''dance.c''' file, and hit OK.&lt;br /&gt;
[[File:step8.JPG|center|750px]]&lt;br /&gt;
=== Step 11 ===&lt;br /&gt;
It will place the '''dance.c''' file under the '''Source Files''' folder, drag it to the project you created and drop it (in a manner it be placed out of the source files folder.)&lt;br /&gt;
[[File:step9.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step10.JPG|center|750px]]&lt;br /&gt;
=== Step 12 ===&lt;br /&gt;
With the '''dance.c''' out of the folders, delete the 3 of them (select the 3, hit delete, hit ok)&lt;br /&gt;
[[File:step11.JPG|center|750px]]&lt;br /&gt;
(It should look like the image below)&lt;br /&gt;
[[File:step12.JPG|center|750px]]&lt;br /&gt;
=== Step 13 ===&lt;br /&gt;
Right click the project you created, open '''Properties'''&lt;br /&gt;
[[File:step13.JPG|center|750px]]&lt;br /&gt;
=== Step 14 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''General''', change '''Output Directory''' to '''..\plugins\''', '''Intermediate Directory''' to '''$(ProjectName)\$(ConfigurationName)\''' and  '''Configuration Type''' to '''Dynamic Library (.dll)'''&lt;br /&gt;
[[File:step14.JPG|center|750px]]&lt;br /&gt;
=== Step 15 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''General''', change '''Additional Include Directories''' to '''..\src;..\3rdparty;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)'''&lt;br /&gt;
[[File:step15.JPG|center|750px]]&lt;br /&gt;
=== Step 16 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', change '''Output File''' to '''$(OutDir)\$(ProjectName).dll'''&lt;br /&gt;
[[File:step16.JPG|center|750px]]&lt;br /&gt;
=== Step 17 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''C/C++''' and open '''Preprocessor''', change '''Preprocessor Definitions''' to '''_WINDLL;PCRE_SUPPORT;%(PreprocessorDefinitions)'''&lt;br /&gt;
[[File:step17.jpg|center|750px]]&lt;br /&gt;
=== Step 18 ===&lt;br /&gt;
Add your code to the '''dance.c''' file, and then right-click the project you created, and select '''Build'''&lt;br /&gt;
=== Step 19 ===&lt;br /&gt;
Add it to ''' /conf/plugins.conf'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plugins_list: [&lt;br /&gt;
	/* Enable HPMHooking when plugins in use rely on Hooking */&lt;br /&gt;
	//&amp;quot;HPMHooking&amp;quot;,&lt;br /&gt;
	//&amp;quot;db2sql&amp;quot;,&lt;br /&gt;
	//&amp;quot;sample&amp;quot;,&lt;br /&gt;
	//&amp;quot;other&amp;quot;,&lt;br /&gt;
	&amp;quot;dance&amp;quot;, // loads dance plugin&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== PCRE_SUPPORT ==&lt;br /&gt;
Although previously on step-17 has included PCRE_SUPPORT, but it was just to prevent the error message on map-server if the plugin has included npc.h. To properly make use of the PCRE interface, there are 2 additional steps.&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''Input''', On '''Additional Dependencies''', Add '''pcre.lib;''' at the beginning.&lt;br /&gt;
[[File:Pcre support step1.png|center|750px]]&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
Under '''Configuration Properties''' click '''Linker''' and open '''General''', On '''Additional Library Directory''', Add '''..\3rdparty\pcre\lib;'''&lt;br /&gt;
[[File:Pcre support step2.png|center|750px]]&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
* This guide is probably the worst I've ever written, if you can do better please hit the 'Edit' button, will be most welcome. - Ind&lt;br /&gt;
* I used MSVC 2008 when testing this guide.&lt;br /&gt;
&lt;br /&gt;
= New Note =&lt;br /&gt;
* Sorry for editing this page, I added step by step images for other people to follow so they can easily follow one of the best feature Hercules have, the HPM. - Thanna&lt;br /&gt;
* The tutorial is tested on MSVC 2010.&lt;br /&gt;
* Add additional steps for PCRE_SUPPORT, credit to hemagx for the info, which he claimed that came from Haru&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:Pcre_support_step2.png</id>
		<title>File:Pcre support step2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:Pcre_support_step2.png"/>
				<updated>2015-12-11T14:00:07Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: plugin with PCRE_SUPPORT for windows MSVC, additional step 2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;plugin with PCRE_SUPPORT for windows MSVC, additional step 2&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:Pcre_support_step1.png</id>
		<title>File:Pcre support step1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:Pcre_support_step1.png"/>
				<updated>2015-12-11T13:59:02Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: plugin with PCRE_SUPPORT for windows MSVC, additional step 1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;plugin with PCRE_SUPPORT for windows MSVC, additional step 1&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/OnTouch</id>
		<title>OnTouch</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/OnTouch"/>
				<updated>2015-12-10T20:37:16Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: add description for OnUnTouch: label&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Syntax=&lt;br /&gt;
 Map,X,Y,facing%tab%script%tab%NPCName%TABID,&amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;,&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;,{CODE}&lt;br /&gt;
 &lt;br /&gt;
 OnTouch:&lt;br /&gt;
 OnTouchNPC:&lt;br /&gt;
 OnUnTouch:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Defines an area that when walked into will trigger one of two event labels. If it is a Player, trigger OnTouch: label. If it is a monster, trigger OnTouchNPC: label.&lt;br /&gt;
The OnUnTouch: label works opposite way. This label trigger when a player leave the area.&lt;br /&gt;
==Calculating spawned area==&lt;br /&gt;
[[File:Ontouch.jpg|thumbnail|A 7*7 area spawned by X:3 Y:3]]&lt;br /&gt;
These triggers will define an area, centered on the NPC and spanning &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt; cells in every direction across X coordinate axis and &amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt; cells in every direction across Y coordinate axis. Thus each one will have N*2 cells, where N is &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;, plus the one that the NPC is.&amp;lt;br&amp;gt;&lt;br /&gt;
Unlike in arithmetics X and Y will also be taken into account when calculating the area that will trigger the NPC. There are four quadrants, each with &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;*&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt; cells plus both axes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;u&amp;gt;Note that each coordinate is a &amp;lt;b&amp;gt;cell&amp;lt;/b&amp;gt; and does not represent map coordinates!&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 4*(x*y) + 2*x + 2*y + 1&lt;br /&gt;
A simple way to measure the area of any polygon that will be covered by OnTouch is &amp;lt;u&amp;gt;(&amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;*2+1)*(&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;*2+1)&amp;lt;/u&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Trick''': Using &amp;quot;end;&amp;quot; at the beginning of the script stops players from executing the script by clicking on the NPC, so they can only execute it if they walk into the specified area.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Event labels==&lt;br /&gt;
Two event labels are defined and each one handles one of two block types BL_PC or BL_MOB &amp;lt;i&amp;gt;id est&amp;lt;/i&amp;gt; a player or a mob.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 OnTouch:&lt;br /&gt;
Handles player types (BL_PC)&lt;br /&gt;
 OnTouchNPC:&lt;br /&gt;
Handles mob types (BL_MOB)&amp;lt;br&amp;gt;&lt;br /&gt;
If no trigger label is defined the code will execute from the beginning of the script, the same way that it would if someone clicked on the NPC.&lt;br /&gt;
==Example==&lt;br /&gt;
 prontera,147,153,3	script	Mary	71,3,3,{&lt;br /&gt;
 	end;&lt;br /&gt;
 &lt;br /&gt;
 OnTouch:&lt;br /&gt;
 	mes &amp;quot;[Mary]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Have you seen my lamb?&amp;quot;;&lt;br /&gt;
 	close;&lt;br /&gt;
 OnTouchNPC: // NO ONE IS ATTACHED!&lt;br /&gt;
 	announce &amp;quot;A mob passed here&amp;quot;,bc_blue|bc_all;&lt;br /&gt;
 	end;&lt;br /&gt;
 }&lt;br /&gt;
This script will spawn 3 cells in each direction plus a cell in the center.&lt;br /&gt;
 4*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+2*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+2*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+1 = 49&lt;br /&gt;
Or&lt;br /&gt;
 (&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*2+1) * (&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*2+1) =&lt;br /&gt;
 7*7 = 49&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/OnTouch</id>
		<title>OnTouch</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/OnTouch"/>
				<updated>2015-12-10T20:33:12Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: missing OnUnTouch&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Syntax=&lt;br /&gt;
 Map,X,Y,facing%tab%script%tab%NPCName%TABID,&amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;,&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;,{CODE}&lt;br /&gt;
 &lt;br /&gt;
 OnTouch:&lt;br /&gt;
 OnTouchNPC:&lt;br /&gt;
 OnUnTouch:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Defines an area that when walked into will trigger one of two event labels depending on block type (BL_MOB or BL_PC)&lt;br /&gt;
==Calculating spawned area==&lt;br /&gt;
[[File:Ontouch.jpg|thumbnail|A 7*7 area spawned by X:3 Y:3]]&lt;br /&gt;
These triggers will define an area, centered on the NPC and spanning &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt; cells in every direction across X coordinate axis and &amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt; cells in every direction across Y coordinate axis. Thus each one will have N*2 cells, where N is &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;, plus the one that the NPC is.&amp;lt;br&amp;gt;&lt;br /&gt;
Unlike in arithmetics X and Y will also be taken into account when calculating the area that will trigger the NPC. There are four quadrants, each with &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;*&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt; cells plus both axes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;u&amp;gt;Note that each coordinate is a &amp;lt;b&amp;gt;cell&amp;lt;/b&amp;gt; and does not represent map coordinates!&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 4*(x*y) + 2*x + 2*y + 1&lt;br /&gt;
A simple way to measure the area of any polygon that will be covered by OnTouch is &amp;lt;u&amp;gt;(&amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;*2+1)*(&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;*2+1)&amp;lt;/u&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Trick''': Using &amp;quot;end;&amp;quot; at the beginning of the script stops players from executing the script by clicking on the NPC, so they can only execute it if they walk into the specified area.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Event labels==&lt;br /&gt;
Two event labels are defined and each one handles one of two block types BL_PC or BL_MOB &amp;lt;i&amp;gt;id est&amp;lt;/i&amp;gt; a player or a mob.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 OnTouch:&lt;br /&gt;
Handles player types (BL_PC)&lt;br /&gt;
 OnTouchNPC:&lt;br /&gt;
Handles mob types (BL_MOB)&amp;lt;br&amp;gt;&lt;br /&gt;
If no trigger label is defined the code will execute from the beginning of the script, the same way that it would if someone clicked on the NPC.&lt;br /&gt;
==Example==&lt;br /&gt;
 prontera,147,153,3	script	Mary	71,3,3,{&lt;br /&gt;
 	end;&lt;br /&gt;
 &lt;br /&gt;
 OnTouch:&lt;br /&gt;
 	mes &amp;quot;[Mary]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Have you seen my lamb?&amp;quot;;&lt;br /&gt;
 	close;&lt;br /&gt;
 OnTouchNPC: // NO ONE IS ATTACHED!&lt;br /&gt;
 	announce &amp;quot;A mob passed here&amp;quot;,bc_blue|bc_all;&lt;br /&gt;
 	end;&lt;br /&gt;
 }&lt;br /&gt;
This script will spawn 3 cells in each direction plus a cell in the center.&lt;br /&gt;
 4*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+2*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+2*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+1 = 49&lt;br /&gt;
Or&lt;br /&gt;
 (&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*2+1) * (&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*2+1) =&lt;br /&gt;
 7*7 = 49&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Timers_(Scripting)</id>
		<title>Timers (Scripting)</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Timers_(Scripting)"/>
				<updated>2015-12-10T19:37:35Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: fix the link so it will show the correct line forever even if some dev update it, thx to angelmelody&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here I will try to better explain timers.  To understand half of what's going on here, I suggest you already know how the basics of [[scripting]].&lt;br /&gt;
&lt;br /&gt;
Many people are confused as to the use of timers, and this guide aims to lend a helping hand.  So you might be wondering  &amp;quot;What do we use timers for?&amp;quot;  Well, my friend, this guide shall explain some of the many uses of timers. &amp;quot;&amp;lt;a&amp;gt;&amp;quot; would mean an actual tab.  I am not keeping to my usual neatness or else there would be too many &amp;quot;&amp;lt;TAB&amp;gt;&amp;quot;s.&lt;br /&gt;
Also, I will explain the usage and format of different kinds of timers in detail.&lt;br /&gt;
&lt;br /&gt;
= Use Number 1: NPC Speech =&lt;br /&gt;
&lt;br /&gt;
NPC Speech can be triggered using timers, and can make NPCs partition a long paragraph instead of spamming 3 instant lines.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here's an example of it in proccess.&amp;lt;br&amp;gt;&lt;br /&gt;
We'll take this apart after we look at it.&lt;br /&gt;
&lt;br /&gt;
 prontera,23,20,2	script	Non-spamming-NPC-Talker	1_M_JOBGUIDER,{&lt;br /&gt;
     end;&lt;br /&gt;
 &lt;br /&gt;
 [[OnInit]]:&lt;br /&gt;
     [[startnpctimer]];&lt;br /&gt;
     end; &lt;br /&gt;
  &lt;br /&gt;
 [[OnTimer]]1000:&lt;br /&gt;
     [[npctalk]] &amp;quot;Y hallo dar lol.&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 &lt;br /&gt;
 OnTimer3000:&lt;br /&gt;
     [[npctalk]] &amp;quot;Lawl I'm not spamming.&amp;quot;;&lt;br /&gt;
     end;&lt;br /&gt;
 &lt;br /&gt;
 OnTimer4000:&lt;br /&gt;
     [[setnpctimer]] 0;&lt;br /&gt;
     end;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, let's take a look at this script.&amp;lt;br&amp;gt;&lt;br /&gt;
We'll start with &amp;quot;OnInit:&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What is &amp;quot;OnInit:&amp;quot;? &amp;lt;br&amp;gt;&lt;br /&gt;
A: &amp;quot;OnInit:&amp;quot; is the commands you wish the NPC to execute right after the NPC is loaded.  &lt;br /&gt;
&lt;br /&gt;
 [[OnInit]]:&lt;br /&gt;
     [[set]] $GlobalVariable,10;&lt;br /&gt;
     [[end]];&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Would set the variable (integer) &amp;quot;$GlobalVariable&amp;quot; to 10 when the server starts.&amp;lt;br&amp;gt;&lt;br /&gt;
''also see: [[Variables | More About Variables]]''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Let's move on to the next item, shall we?&lt;br /&gt;
&lt;br /&gt;
     [[end]];&lt;br /&gt;
&lt;br /&gt;
&amp;quot;end;&amp;quot; is always needed to show that a label starting with &amp;quot;On&amp;quot;,&amp;lt;br&amp;gt;&lt;br /&gt;
''(and is a valid label that the server sees other functions for than just a custom label)'' &amp;lt;br&amp;gt;&lt;br /&gt;
has ended.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''If you do not end the &amp;quot;On&amp;quot; label with &amp;quot;end;&amp;quot;, horrible things will happen, such as running through other labels.'''&lt;br /&gt;
&lt;br /&gt;
 OnInit:&lt;br /&gt;
     set $GlobalVariable,32;&lt;br /&gt;
 &lt;br /&gt;
 LOtherLabel:&lt;br /&gt;
     set $GlobalVariable,$GlobalVariable + 3;&lt;br /&gt;
     end;&lt;br /&gt;
&lt;br /&gt;
When the NPC is run, the variable &amp;quot;$GlobalVariable&amp;quot; would be 35, since 32 + 3 = 35&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note that the initiation label is executed, and proceedes to run through &amp;quot;LOtherLabel&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
This is because I did not insert an &amp;quot;end;&amp;quot; after &amp;quot;OnInit&amp;quot; ended, but instead, after LOtherLabel.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Sometimes this is usefull too... &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;...&amp;gt;&lt;br /&gt;
 [[OnClock]]2100:	&lt;br /&gt;
 OnClock2300:&lt;br /&gt;
     &amp;lt;your script here&amp;gt;&lt;br /&gt;
     end;&lt;br /&gt;
 &amp;lt;...&amp;gt;&lt;br /&gt;
This Script will run at 21:00 AND at 23:00 (c&amp;amp;p from the woe-starting-script)&lt;br /&gt;
&lt;br /&gt;
= Use Number 2: Delayed Warp =&lt;br /&gt;
Delayed warping is a feature you can put in your script to add more drama, or to automatically warp someone from a room when the player has exceeded the allotted time for being there. Here is an example of a delayed warp:&lt;br /&gt;
&lt;br /&gt;
 prontera,23,20,2	script	Bomb Squad	1_M_JOBGUIDER,{&lt;br /&gt;
     [[mes]] &amp;quot;[Dismantler]&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Where is the bomb? WHERE IS IT??&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Please help me find it before it explodes.&amp;quot;;&lt;br /&gt;
     [[close2]];&lt;br /&gt;
     [[addtimer]] 15000, &amp;quot;Bomb Squad::OnWarn&amp;quot;;&lt;br /&gt;
     [[addtimer]] 30000, &amp;quot;Bomb Squad::OnBoom&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;Dismantler : The bomb will detonate in 30 seconds!&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 &lt;br /&gt;
 OnWarn:&lt;br /&gt;
     [[dispbottom]] &amp;quot;Dismantler : OH MY GOD! ONLY 15 SECONDS LEFT - HURRY!!!!&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 &lt;br /&gt;
 OnBoom:&lt;br /&gt;
     [[dispbottom]] &amp;quot;*time slows down as suddenly the ticking stops*&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;....&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;BOOOOOOOM&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;The blast flings you away.&amp;quot;;&lt;br /&gt;
     [[warp]] &amp;quot;prontera&amp;quot;,0,0;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
First thing that probably comes to your mind is: How can I find the bomb? The answer is simple, you cannot. I didn't include that NPC *evil grin*&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Now, let's walk over this script in more detail. The start is nothing new, just a simple NPC header with a text box. Then there appears to be a close2;. This is not a typo. Close2; behaves a bit like close;, it displays a close button. However, the script will keep on running in the background, after the close button has been pushed. So, after the player presses the close button, it continues with the next line.&lt;br /&gt;
For you lazy bums, here is an outtake of the script to prevent your scrolling finger from getting tired.&lt;br /&gt;
     [[addtimer]] 15000, &amp;quot;Bomb Squad::OnWarn&amp;quot;;&lt;br /&gt;
     [[addtimer]] 30000, &amp;quot;Bomb Squad::OnBoom&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;Dismantler : The bomb will detonate in 30 seconds!&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
&lt;br /&gt;
Addtimer creates a player tagged timer. It is really simple to work with, although it can be inaccurate.&lt;br /&gt;
* addtimer &amp;lt;ticks&amp;gt;,&amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
So, in our case, we start a timer that lasts for 15000ms, converted, 15 seconds. When the timer ends, it triggers &amp;quot;Bomb Squad::OnWarn&amp;quot;. In human language: It jumps to the label named OnWarn: within the NPC called &amp;quot;Bomb Squad&amp;quot;.&lt;br /&gt;
We also create another timer, that lasts for 30 seconds, and will trigger the label OnBoom:&lt;br /&gt;
Then a simple dispbottom, to display some text in the player's chat, and an end; to terminate the script.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Q: Why not use NPC timers?&amp;lt;br&amp;gt;&lt;br /&gt;
A: NPC timers do not remember which player triggered the script, and addtimer does remember the so called RID. Since we need to manipulate the player later on, we need the script to remember the RID.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Anyway, after 15 seconds, if the player hasn't logged out, the script will restart at the following point:&lt;br /&gt;
 OnWarn:&lt;br /&gt;
     [[dispbottom]] &amp;quot;Dismantler : OH MY GOD! ONLY 15 SECONDS LEFT - HURRY!!!!&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
&lt;br /&gt;
What it does here, is another text display in the chat of the player, and then end the script again. So, we wait, and we wait, and then, after another 15 seconds, the second timer triggers the label OnBoom:, and starts this piece of code:&lt;br /&gt;
 OnBoom:&lt;br /&gt;
     [[dispbottom]] &amp;quot;*time slows down as suddenly the ticking stops*&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;....&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;BOOOOOOOM&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;The blast flings you away.&amp;quot;;&lt;br /&gt;
     [[warp]] &amp;quot;prontera&amp;quot;,0,0;&lt;br /&gt;
     [[end]];&lt;br /&gt;
Again the dispbottoms, and then, a random warp, because the bomb exploded. Then another end; terminates the script again.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
If you would have done this all with NPC timers, your mapserver would have smacked you and perhaps even tackled itself. Why? Well, the dispbottom and the warp command can only be executed on a player. To execute something on a player, the script needs to have a so called RID. Addtimer remembers this RID, a NPC timer does not.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What if I click the NPC before both timers run out.&amp;lt;br&amp;gt;&lt;br /&gt;
A: This can be done by setting a player variable @boom before the close2; See [[Variables#Player_Variables]]. Temporary player variable works well along with addtimer command, as they both behave the same.&lt;br /&gt;
* they are attached to the player&lt;br /&gt;
* both will disappear when player log out&lt;br /&gt;
so the Bomb Squad npc script now look like this&lt;br /&gt;
 prontera,155,188,2	script	Bomb Squad	1_M_JOBGUIDER,{&lt;br /&gt;
     [[mes]] &amp;quot;[Dismantler]&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Where is the bomb? WHERE IS IT??&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Please help me find it before it explodes.&amp;quot;;&lt;br /&gt;
     [[if]] ( @boom == 1 ) [[close]];&lt;br /&gt;
     [[close2]];&lt;br /&gt;
     [[set]] @boom, 1;&lt;br /&gt;
     [[addtimer]] 15000, &amp;quot;Bomb Squad::OnWarn&amp;quot;;&lt;br /&gt;
     [[addtimer]] 30000, &amp;quot;Bomb Squad::OnBoom&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;Dismantler : The bomb will detonate in 30 seconds!&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 OnWarn:&lt;br /&gt;
     [[dispbottom]] &amp;quot;Dismantler : OH MY GOD! ONLY 15 SECONDS LEFT - HURRY!!!!&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 OnBoom:&lt;br /&gt;
     [[dispbottom]] &amp;quot;*time slows down as suddenly the ticking stops*&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;....&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;BOOOOOOOM&amp;quot;;&lt;br /&gt;
     [[dispbottom]] &amp;quot;The blast flings you away.&amp;quot;;&lt;br /&gt;
     [[warp]] &amp;quot;prontera&amp;quot;,0,0;&lt;br /&gt;
     [[set]] @boom, 0;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 }&lt;br /&gt;
''someone please help explain properly about this script''&lt;br /&gt;
{{Incomplete|type=section}}&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Now, on to the bomb npc.&lt;br /&gt;
 prontera,50,50,2	script	Bomb	HIDDEN_NPC,{&lt;br /&gt;
     [[if]] ( @boom == 0 ) [[end]];&lt;br /&gt;
     [[mes]] &amp;quot;*The bomb has been disarm*&amp;quot;;&lt;br /&gt;
     [[deltimer]] &amp;quot;Bomb Squad::OnWarn&amp;quot;;&lt;br /&gt;
     [[deltimer]] &amp;quot;Bomb Squad::OnBoom&amp;quot;;&lt;br /&gt;
     [[set]] @boom, 0;&lt;br /&gt;
     [[close]];&lt;br /&gt;
 }&lt;br /&gt;
deltimer command will remove the timer that has previously attached to the player. So if the player previously talk to the Bomb Squad, will able to disarm the bomb. This will prevent the addtimer from invoking the OnWarn: and OnBoom: label.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What happens if the player click on the Bomb after 15 seconds, will the server throw error for OnWarn: label already executed ?&amp;lt;br&amp;gt;&lt;br /&gt;
A: Nope, the server doesn't seem to care about that. This means you can put as many addtimer command, and deltimer all of them without additional checks. Neat, isn't it?&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''Note''' : addtimer can only attached to the up to 31 instances on that player. This means, if you have more than a number of scripts using addtimer command on that player, on 32th queue will throw an error on the server to notify some of your script has over abuse this command. To lift off this limit, simply increase the MAX_EVENTTIMER in src\map\map.h, and recompile your server.&lt;br /&gt;
&lt;br /&gt;
= Use Number 3: Deny Usage =&lt;br /&gt;
Let's start with another example:&lt;br /&gt;
 prontera,23,20,2	script	Daily Healer	1_M_JOBGUIDER,{&lt;br /&gt;
     [[mes]] &amp;quot;[Healer]&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;I am a special healer, who will fully restore your HP and SP.&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;However, my powers are limited, and I need to rest for a full day after healing you, before I can help you again.&amp;quot;;&lt;br /&gt;
     [[next]];&lt;br /&gt;
     [[mes]] &amp;quot;[Healer]&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Do you want me to heal you?&amp;quot;;&lt;br /&gt;
     [[next]];&lt;br /&gt;
     [[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
          [[mes]] &amp;quot;[Healer]&amp;quot;;&lt;br /&gt;
          [[mes]] &amp;quot;Ok, good bye then.&amp;quot;;&lt;br /&gt;
          [[close]];&lt;br /&gt;
     }&lt;br /&gt;
     [[if]] (TimeHealed + 86400 &amp;gt; [[gettimetick]](2)) { // 86400 is one day in seconds.&lt;br /&gt;
          [[mes]] &amp;quot;[Healer]&amp;quot;;&lt;br /&gt;
          [[mes]] &amp;quot;I am sorry, but I am not a robot.&amp;quot;;&lt;br /&gt;
          [[mes]] &amp;quot;I am still exhausted from the last time I healed you.&amp;quot;;&lt;br /&gt;
          [[close]];&lt;br /&gt;
     }&lt;br /&gt;
     [[mes]] &amp;quot;[Healer]&amp;quot;;&lt;br /&gt;
     [[mes]] &amp;quot;Ok, here goes!&amp;quot;;&lt;br /&gt;
     [[close2]];&lt;br /&gt;
     [[percentheal]] 100,100;&lt;br /&gt;
     [[set]] TimeHealed, [[gettimetick]](2);&lt;br /&gt;
     [[dispbottom]] &amp;quot;Healer : Please give me at least a day to recover.&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
 }&lt;br /&gt;
Q: I see no timers?&amp;lt;br&amp;gt;&lt;br /&gt;
A: That is correct. This NPC uses what I would like to call a Static Timer. We will review it in detail below.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Ok, at a first glance, this is a normal healer NPC that fully heals your HP and SP. The interesting part though is at the bottom. Let's start with the bottom most part:&lt;br /&gt;
     [[close2]];&lt;br /&gt;
     [[percentheal]] 100,100;&lt;br /&gt;
     [[set]] TimeHealed, [[gettimetick]](2);&lt;br /&gt;
     [[dispbottom]] &amp;quot;Healer : Please give me at least a day to recover.&amp;quot;;&lt;br /&gt;
     [[end]];&lt;br /&gt;
The NPC does the healing here, but after the healing, it sets a weird value to TimeHealed. First, it gets a value from gettimetick(2). This command returns the amount of seconds elapsed since 1/1/1970, based on your server current time.&lt;br /&gt;
&lt;br /&gt;
     [[if]] (TimeHealed + 86400 &amp;gt; [[gettimetick]](2)) {&lt;br /&gt;
When the player wants to use the NPC again, the NPC first checks if the player is still allowed to be healed. How? Well, remember, in TimeHealed, we stored the time when the player last used the NPC. With gettimetick(2) we get the current time in seconds that has elapsed since 1/1/1970, and by adding 86400, which is the amount of seconds that goes in a day (24 * 60 * 60). Those two combined give us the next time the player is allowed to use the NPC again. If the player is allowed to use the NPC again, the combined value should be in the past, so it should be less than what gettimetick(2) will return to us. If it is the other way around, the player is not allowed to use the NPC yet, and it will jump inside the if-statement.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Please note, that using a Static Timer comes with some disadvantages. First, it uses a player variable.&lt;br /&gt;
Second, the more dynamic you make it, the more resources it will cost. Although it should be less CPU intensive than a normal timer, making it dynamic means.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
By turning that numbers into a Global variable,&lt;br /&gt;
     [[if]] ((TimeHealed + $HealInterval)&amp;gt; [[gettimetick]](2)) {&lt;br /&gt;
$HealInterval will be a variable that you can set as a GM through another NPC, to determine the time between two heal possibilities in seconds.&lt;br /&gt;
&lt;br /&gt;
= Difference between Timers =&lt;br /&gt;
&lt;br /&gt;
First, let's give an overview of the different kinds of timers or time triggered labels.&lt;br /&gt;
* [[#NPC_Timers|NPC Timers]]&lt;br /&gt;
* [[#Player_Timers|Player Timers]]&lt;br /&gt;
* [[#Label_Timers|Label Timers]]&lt;br /&gt;
* [[#Other_Timers|Other Timers]]&lt;br /&gt;
&lt;br /&gt;
== NPC Timers ==&lt;br /&gt;
NPC timers are timers that are executed from the NPC's point of view. This means that it does not require a player to initiate it, nor a player to use it. A perfect example of this is the Speaking NPC at the start of this article.&lt;br /&gt;
NPC timers use the following seven commands:&lt;br /&gt;
* initnpctimer {&amp;quot;NPC Name&amp;quot;},{&amp;lt;Player RID&amp;gt;};&lt;br /&gt;
* startnpctimer {&amp;quot;NPC Name&amp;quot;},{&amp;lt;Player RID&amp;gt;};&lt;br /&gt;
* stopnpctimer {&amp;quot;NPC Name&amp;quot;},{&amp;lt;flag&amp;gt;};&lt;br /&gt;
* getnpctimer &amp;lt;type&amp;gt;{,&amp;quot;NPC Name&amp;quot;};&lt;br /&gt;
* setnpctimer &amp;lt;amount&amp;gt;{,&amp;quot;NPC Name&amp;quot;};&lt;br /&gt;
* attachnpctimer {&amp;lt;Player RID&amp;gt;};&lt;br /&gt;
* detachnpctimer {&amp;quot;NPC Name&amp;quot;};&lt;br /&gt;
&lt;br /&gt;
== Player Timers ==&lt;br /&gt;
Player timers are used for NPCs that can interact with players, and need to have a specific count down or up per player. Unlike a NPC timer, a Player timer remembers which player started the timer. In other words, it remembers the RID and reattaches it again when needed. This allows you to alter a player's variable later on in the script, where this is not possible with a NPC timer.&lt;br /&gt;
Player timers use similar commands as NPC timers. However, there are only three of them: &lt;br /&gt;
* addtimer &amp;lt;ticks&amp;gt;,&amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
* addtimercount &amp;lt;ticks&amp;gt;,&amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
* deltimer &amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Label Timers ==&lt;br /&gt;
Label Timers aren't timers actually. They are labels that are triggered depending on the current time of the server. There are several different kinds of them, but they all almost work in the same way. You simply put them in your script as a label, and they look like this:&lt;br /&gt;
* OnClockXXXX:&lt;br /&gt;
* OnDayXXXX:&lt;br /&gt;
* OnHourXX:&lt;br /&gt;
* OnMinuteXX:&lt;br /&gt;
Where XX is a two digit number and XXXX is a four digit number. SSSXXXX is three letters followed by four digits.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How they work? Relatively easy. OnClock is already explained in the first part of this article, but here is the recap in case you forgot. To make it work, you replace XXXX by an actual time in the 24 hour format. The time you put there, is when the label is triggered. So, for example:&lt;br /&gt;
 OnClock0700: // This label is triggered at 7 AM servertime.&lt;br /&gt;
 OnClock1414: // This label is triggered at 2:14 PM servertime.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Just like normal labels, you can use the same OnClock label in different NPCs, but, it cannot occur twice in the same NPC. You can have different OnClocks in the same NPC though.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OnDayXXXX works a bit like OnClock. The XXXX here stands for a specific day in a specific month. The first XX is the month, the second XX is the day of that month. When it is that day, it will be triggered. Assumed is, that this happens only once at the start of that day, or the first time that your server is up during that day. Here are a couple of examples:&lt;br /&gt;
 OnDay0101: // This label is triggered on the first day of January.&lt;br /&gt;
 OnDay0515: // This one is triggered on the fifteenth day of May.&lt;br /&gt;
 OnDay1231: // This one is triggered on the last day of December.&lt;br /&gt;
 OnDay0229: // This label is only triggered when it is February 29th, so once every four years.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OnHourXX and OnMinuteXX are similar in use. With OnHour, the XX stands for a specific hour during the day when it is triggered. The XX within OnMinute stands for a specific minute per hour. Some examples to make it clear:&lt;br /&gt;
 OnHour01: // Triggers at 1 AM every day.&lt;br /&gt;
 OnHour20: // Triggers at 8 PM every day.&lt;br /&gt;
 OnMinute00: // Triggers at each new hour, so 1:00, 2:00, 3:00, 4:00 etc.&lt;br /&gt;
 OnMinute17: // Triggers each hour at 17 minutes past. So, 8:17, 9:17, 10:17 etc.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Last, and probably the least known is OnSSSXXXX. The best way to describe this one is an OnWeekday label. (OnWeekday does not exist.)&lt;br /&gt;
In this label, SSS is replaced by one of the following: Sun, Mon, Tue, Wed, Thu, Fri, Sat.&lt;br /&gt;
XXXX is replaced by a number in the same way as the XXXX in OnClockXXXX. It notes a specific time of the day.&lt;br /&gt;
This label is triggered on the specified day of the week (SSS) at the specified time in 24 hour format (XXXX). At least, that is the theory. Here are some examples you can work with:&lt;br /&gt;
 OnSat1200: // Triggers at noon on each Saturday.&lt;br /&gt;
 OnTue0707: // Triggers at 7 past 7 AM on Tuesday.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note:&lt;br /&gt;
Although there is no OnSecondXX or OnMillisecondXXXX label, you can simulate this. Be aware though, this causes a heavy load on your server. To do this, you will have to use a NPC. Here is a short example simulating OnSecond30 using a NPC timer:&lt;br /&gt;
 -	script	Annoying Announcer	FAKE_NPC,{&lt;br /&gt;
 [[OnInit]]:&lt;br /&gt;
     [[initnpctimer]];&lt;br /&gt;
     [[end]];&lt;br /&gt;
 &lt;br /&gt;
 [[OnTimer]]1000:&lt;br /&gt;
     if ([[gettime]](GETTIME_SECOND) != 30) [[end]];&lt;br /&gt;
     [[announce]] &amp;quot;I'm very annoying.&amp;quot;, bc_all;&lt;br /&gt;
     [[initnpctimer]];&lt;br /&gt;
     [[end]];&lt;br /&gt;
 }&lt;br /&gt;
And one that triggers every 40 milliseconds:&lt;br /&gt;
 -	script	Flooder	FAKE_NPC,{&lt;br /&gt;
 [[OnInit]]:&lt;br /&gt;
     [[initnpctimer]];&lt;br /&gt;
     [[end]];&lt;br /&gt;
 &lt;br /&gt;
 [[OnTimer]]40:&lt;br /&gt;
     [[announce]] &amp;quot;Flood!&amp;quot;, bc_all;&lt;br /&gt;
     [[initnpctimer]];&lt;br /&gt;
     [[end]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Timers ==&lt;br /&gt;
These timers are actually nowhere related to timers. To be exact, they are event triggered labels, but let's go over them anyway, because they are useful. The timers I'm referring to are the following:&lt;br /&gt;
* [[OnInit]]:               - Is triggered on server start up.&lt;br /&gt;
* [[OnInterIfInit]]:        - Is triggered when the mapserver connects to the charserver.&lt;br /&gt;
* [[OnInterIfInitOnce]]:    - Is only triggered on the first time the map server connects to the char server. If it loses connection after that, and gets a connection again, these labels are no longer triggered (unless the map server is really restarted).&lt;br /&gt;
* [[OnAgitInit]]:           - Is triggered when WoE is initiated.&lt;br /&gt;
* [[OnAgitStart]]:          - Is triggered when WoE is started.&lt;br /&gt;
* [[OnAgitEnd]]:            - Is triggered when WoE ends.&lt;br /&gt;
* [[OnTimer]]X:             - Is triggered when a player or NPC timer reaches the value X in milliseconds.&lt;br /&gt;
&lt;br /&gt;
There are many more of these kinds of special event triggered labels, like the login event, but these, with the exception of OnTimerX, are all triggered without the need of a player.&lt;br /&gt;
With OnTimerX, the X should be replaced by a time in milliseconds, for example:&lt;br /&gt;
 OnTimer100: // Triggers 100ms after a player timer or NPC timer is started in the same NPC.&lt;br /&gt;
 OnTimer3600000: // Triggers 1 hour after a player timer or NPC timer is started in the same NPC.&lt;br /&gt;
&lt;br /&gt;
== Recap ==&lt;br /&gt;
The above information should help you make a decission on what timertype to use. For example, if you do not need to do anything with the player who starts it, or don't need a player to start it, use a NPC timer. When you want to do stuff related to a player, or which needs an RID, use a player timer. When you want something to happen at a specific moment in time, use one of the On labels. And when you want your server to lag badly, simulate OnMillisecondXXXX.&lt;br /&gt;
&lt;br /&gt;
= NPC Timers in detail =&lt;br /&gt;
In this section, we will explain how each NPC Timer command works in detail. First another quick list of the available NPC Timers:&lt;br /&gt;
* [[initnpctimer]] {&amp;quot;NPC Name&amp;quot;},{&amp;lt;Player RID&amp;gt;};&lt;br /&gt;
* [[startnpctimer]] {&amp;quot;NPC Name&amp;quot;},{&amp;lt;Player RID&amp;gt;};&lt;br /&gt;
* [[stopnpctimer]] {&amp;quot;NPC Name&amp;quot;},{&amp;lt;flag&amp;gt;};&lt;br /&gt;
* [[getnpctimer]] &amp;lt;type&amp;gt;{,&amp;quot;NPC Name&amp;quot;};&lt;br /&gt;
* [[setnpctimer]] &amp;lt;amount&amp;gt;{,&amp;quot;NPC Name&amp;quot;};&lt;br /&gt;
* [[attachnpctimer]] {&amp;lt;Player RID&amp;gt;};&lt;br /&gt;
* [[detachnpctimer]] {&amp;quot;NPC Name&amp;quot;};&lt;br /&gt;
Now that you know the commands, you will have to know how NPC Timers actually work. It is quite easy to be honest. A NPC can have one timer attached to it, which basically is a stopwatch. When you start a timer, a kind of NPC like variable will start running, often from 0. Every millisecond (1 second is 1000 milliseconds or 1000 ms), 1 is added to this variable. So, after 1 second, the variable will be 1000. After 12.5 seconds, the variable will be 12500.&amp;lt;br&amp;gt;&lt;br /&gt;
Now, on each tick (tick means every increment of this variable), the timer will check if inside the NPC it is running from or attached to, if there is a label that matches his current value. The labels have a special format, and look like this:&lt;br /&gt;
 OnTimerXXXXX:&lt;br /&gt;
Where XXXXX is a number that can be as small as 0, or as big as 2,147,483,647 (roughly 24 days). If the value of the timer matches one of those labels, then the NPC will start running at that specific label. So, let's say you have a label OnTimer1000: (1 second), and you have started a NPC timer, then one second later, the script will jump to that label, and start executing the code underneath it.&amp;lt;br&amp;gt;&lt;br /&gt;
Often, when using NPC Timers, you want to stop them at some point, or reset them, to make the NPC start over again. For this purpose, the [[Developers|developers]] have written several commands that are now at our disposal, which allow us to manipulate this NPC based timer.&amp;lt;br&amp;gt;&lt;br /&gt;
A last thing you need to know, before we go into detail on the specific commands, is that by default a NPC Timer will run in the same NPC as where the command is found, and that there is no player attached. The last part means, that you will be unable by default to manipulate the player, variable wise or command wise.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== InitNPCTimer ==&lt;br /&gt;
This command allows you create a new NPC timer, if it doesn't already exist, and have it start counting from 0. The NPC timer is attached to a NPC, normally the one you start it from. This means, that it will look for certain OnTimer labels inside that NPC alone. However, you can also make the command start a NPC Timer in another NPC. To do this, you will have to specify a NPC Name.&lt;br /&gt;
You can even attach a player to the NPC Timer. To do this, you must specify the RID when using '''initnpctimer'''. This will allow your timer to execute commands that require a player's RID, like warp or countitem.&amp;lt;br&amp;gt;&lt;br /&gt;
On top of that, you can also specify both a NPC Name and a Player RID. For that, put the NPC Name first, then a comma, and then the player's RID.&amp;lt;br&amp;gt;&lt;br /&gt;
For those unfamiliar of what an RID is, the RID is a kind of hook with which online players are recognized. When coming online, the player's RID will be set equal to his account ID (getcharid(3)).&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
 initnpctimer; // Start a new NPC timer and make it count from 0.&lt;br /&gt;
 initnpctimer &amp;quot;My Other NPC&amp;quot;; // Start a new NPC timer in the NPC named &amp;quot;My Other NPC&amp;quot; and make it count from 0.&lt;br /&gt;
 initnpctimer getcharid(3); // Start a new NPC timer and make it count from 0. Also, attach the current player to the timer.&lt;br /&gt;
 initnpctimer &amp;quot;My Other NPC&amp;quot;,getcharid(3); // Start a new NPC timer in the NPC named &amp;quot;My Other NPC&amp;quot; &lt;br /&gt;
                                              and make it count from 0. Also, attach the current player to the timer.&lt;br /&gt;
&lt;br /&gt;
== StartNPCTimer ==&lt;br /&gt;
This command almost works the same as [[Initnpctimer|InitNPCTimer]]. The only major difference is that it doesn't set the counter, or if you like, the timer variable, to 0. It simply continues where it was. So, if you started the NPC Timer with '''initnpctimer''', and stopped it later on, but want it to start again where it left off, then you use this command. If you like you can read '''continuenpctimer instead of '''startnpctimer'''.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Again, for the various options, you might want to look at [[Initnpctimer|InitNPCTimer]]. We will just show some examples here:&amp;lt;br&amp;gt;&lt;br /&gt;
 startnpctimer; // Continues the NPC timer where it left off, or start a new one if there isn't a timer already.&lt;br /&gt;
 startnpctimer &amp;quot;My Other NPC&amp;quot;; // Same as above, but starts it in the NPC named &amp;quot;My Other NPC&amp;quot;.&lt;br /&gt;
 startnpctimer getcharid(3); // Same as the first one, but attaches the current player to the timer.&lt;br /&gt;
 startnpctimer &amp;quot;My Other NPC&amp;quot;,getcharid(3); // Combination of the two above.&lt;br /&gt;
&lt;br /&gt;
== StopNPCTimer ==&lt;br /&gt;
This command is the counterpart of [[Startnpctimer|StartNPCTimer]]. What it does, you've guessed it, it stops (or pauses) the timer. As for the parameters, the NPC Name part is exactly the same as with [[Initnpctimer|InitNPCTimer]]. If you specify a flag value (can be any non-zero value, zero will simply be ignored), then '''stopnpctimer''' will also detach the player, if any was attached to it.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some examples again:&lt;br /&gt;
 stopnpctimer; // Pauses the NPC timer in the current NPC.&lt;br /&gt;
 stopnpctimer &amp;quot;My Other NPC&amp;quot;; // Pauses the NPC timer in the NPC named &amp;quot;My Other NPC&amp;quot;&lt;br /&gt;
 stopnpctimer 1; // Pauses the NPC timer in the current NPC and detaches any attached player.&lt;br /&gt;
 stopnpctimer &amp;quot;My Other NPC&amp;quot;,1; // Combination of the two above.&lt;br /&gt;
&lt;br /&gt;
== GetNPCTimer ==&lt;br /&gt;
[[Getnpctimer|GetNPCtimer]] is a bit of a tricky command. Basically it can be used to read out the statistics on a certain NPC Timer. (Either the one in the current NPC, or the one defined by the parameter &amp;quot;NPC Name&amp;quot;.) There are three different statistics for a NPC Timer, which are:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* 0 - Current Tick Count&lt;br /&gt;
* 1 - Remaining OnTimer labels&lt;br /&gt;
* 2 - Already executed OnTimer labels&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The first one (0), basically is a variable which holds the amount of milliseconds that the timer is on.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The second one (1), holds the amount of labels that the timer will still have to do in the NPC, if it is not reset or stopped prematurely.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The third one (2), holds the amount of OnTimer labels which the timer already has executed. Most likely, '''initnpctimer''' resets this counter. What '''startnpctimer''' does to this statistic, is unknown at the moment.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Getnpctimer|GetNPCimer]] always needs to have a type (one of the three above) specified when being used. For the second stat of the three, when there was originally a player attached, then it will still need this player to be attached, or it will give you back an error and return 0.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
 getnpctimer 0; // Returns the current amount of ticks.&lt;br /&gt;
 getnpctimer 0,&amp;quot;My Other NPC&amp;quot;; // Does the same, only for the NPC named &amp;quot;My Other NPC&amp;quot;.&lt;br /&gt;
 getnpctimer 1; // Returns the amount of OnTimer labels that are still untriggered.&lt;br /&gt;
 getnpctimer 1,&amp;quot;My Other NPC&amp;quot;; // Same as above, but for the NPC named &amp;quot;My Other NPC&amp;quot;.&lt;br /&gt;
 getnpctimer 2; // Returns the amount of OnTimer labels that have already been triggered.&lt;br /&gt;
 getnpctimer 2,&amp;quot;My Other NPC&amp;quot;; // Same as above, but for the NPC named &amp;quot;My Other NPC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently there is no way to retrieve the value of getnpctimer(0) with attachnpctimer;. It's still mark as a [https://github.com/HerculesWS/Hercules/blob/e711753b9d584845e385ada29780b9ed216c4f55/src/map/npc.c#L771 TODO] in the source code ;-)&lt;br /&gt;
&lt;br /&gt;
== SetNPCTimer ==&lt;br /&gt;
[[Setnpctimer|SetNPCTimer]] is the counterpart of [[Getnpctimer|GetNPCTimer]]. However, it only allows you to change the current amount of ticks (elapsed milliseconds) of a specific timer. If you define a NPC Name with it, it will use the timer in that NPC, otherwise, it will try to alter the timer in the NPC where the command is in. The amount you set the NPC Timer to, should be given in ticks, or milliseconds. The command theoritically works even when a NPC timer is stopped, but probably does not work when no NPC Timer has ever started in the NPC. This is about all there is to this command. It works, no matter if there is a player attached to it or not.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some examples again:&lt;br /&gt;
 setnpctimer 10000; // Sets the NPC Timer of the current NPC to 10 seconds.&lt;br /&gt;
 setnpctimer 2345,&amp;quot;My Other NPC&amp;quot;; // Sets the NPC Timer in the NPC named &amp;quot;My Other NPC&amp;quot; to 2345 ticks or ms.&lt;br /&gt;
 setnpctimer 0; // Sets the current NPC Timer to 0.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note:&amp;lt;br&amp;gt;&lt;br /&gt;
In the current revisions, '''setnpctimer''' also pauses the timer when changing the value. So, do not forget to use '''startnpctimer'''; after using '''setnpctimer''', or your timer will not continue to run. (This might be changed in later revisions)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AttachNPCTimer ==&lt;br /&gt;
[[Attachnpctimer|AttachNPCTimer]] allows you to attach a player to a NPC later on. This can only be done to the NPC Timer that is in the same NPC as where this command is used. To attach a player, you will simply have to give his account id or RID (or UID/GID in some devs words) as a parameter.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
 attachnpctimer getcharid(3); // Attaches current player to the NPC Timer.&lt;br /&gt;
 attachnpctimer 2000000; // Attaches the player with account id 2000000 to the NPC Timer, if he is online.&lt;br /&gt;
&lt;br /&gt;
== DetachNPCTimer ==&lt;br /&gt;
[[Detachnpctimer|DetachNPCTimer]] is the opposite of [[Attachnpctimer|AttachNPCTimer]]. Unlike its counterpart however, you can use it outside its current NPC. To do this, simply specify the name of the other NPC as parameter. This is optional of course.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Examples:&lt;br /&gt;
 detachnpctimer; // Detaches the attached player from the NPC Timer, if anyone was attached.&lt;br /&gt;
 detachnpctimer &amp;quot;My Other NPC&amp;quot;; // Does the same, only for the NPC named &amp;quot;My Other NPC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Pro's and Cons ==&lt;br /&gt;
Using NPC Timers have specific advantages and disadvantages. These will be listed in a compact way next.&amp;lt;br&amp;gt;&lt;br /&gt;
Advantages:&lt;br /&gt;
* Can be specific bound to any NPC.&lt;br /&gt;
* No need for a player, but can be attached.&lt;br /&gt;
* Can be used on start up or time triggered labels.&lt;br /&gt;
* Can be looped/resetted easily.&lt;br /&gt;
* Can be manipulated/read out in various ways.&lt;br /&gt;
Disadvantages:&lt;br /&gt;
* NPC bound, so, if multiple players use the NPC, the timer will restart each time. (Can cause unexpected results.)&lt;br /&gt;
* Only one NPC Timer can run per NPC.&lt;br /&gt;
&lt;br /&gt;
= Player Timers in detail =&lt;br /&gt;
In this section, we will explain how each Player Timer command works in detail. First another quick list of the available Player Timers:&lt;br /&gt;
* [[addtimer]] &amp;lt;ticks&amp;gt;,&amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
* [[addtimercount]] &amp;lt;ticks&amp;gt;,&amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
* [[deltimer]] &amp;quot;NPC::OnEvent&amp;quot;;&lt;br /&gt;
The list of player timer commands is significally shorter than the list of NPC Timers. This is right away one of the well.., downsides of the player timer. It has less flexibility. However, player timers are easier to work with for the same reason.&amp;lt;br&amp;gt;&lt;br /&gt;
Player timers work in a reverse way from NPC Timers. Basically you enter a number in milliseconds (1 second is 1000 milliseconds), and a timer attached to the player who triggered it, will run down from that number to 0. When it reaches 0, it will jump to the eventlabel specified in the second parameter of addtimer.&amp;lt;br&amp;gt;&lt;br /&gt;
Besides starting a timer, and let it run it's course, you can also delay it, and even delete it before it reaches 0. Also, a player timer, is like the word indicates, unique for each player for each label. So, a player will not influence the timer of another player in normal circumstances, and you can even start different timers for the same player, as long as the event label is different each time.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AddTimer ==&lt;br /&gt;
Addtimer allows you to start a new timer for the player who is currently interacting with the script. It has two parameters, which are not optional:&lt;br /&gt;
* ticks&lt;br /&gt;
* &amp;quot;NPC::OnEvent&amp;quot;&lt;br /&gt;
Ticks is a number which you specify, which is the starting time, in milliseconds. The timer will start to run immediately after this line, substracing 1 from the tickcount each millisecond, until it reaches 0.&amp;lt;br&amp;gt;&lt;br /&gt;
The NPC::OnEvent, is an event label which you must specify. It must be for the following format: &amp;quot;NPC NAME::OnYourLabel&amp;quot;, where OnYourLabel is an existing label that starts with On, in the NPC named NPC NAME. When the timer runs down to 0, it will jump to that label in that NPC. For easiness sake, let's call the &amp;quot;NPC::OnEvent&amp;quot; part of the command, and the upcoming commands, also the name of the player timer.&amp;lt;br&amp;gt;&lt;br /&gt;
Well, that is all there is to the addtimer command, so some last examples:&lt;br /&gt;
 addtimer 1000,&amp;quot;My NPC::OnMyLabel&amp;quot;; // Starts a timer that runs out after 1000 ms (1 second), and then jumps to OnMyLabel in My NPC.&lt;br /&gt;
 addtimer 60000,&amp;quot;NPC1::OnLoser&amp;quot;; // After 60 seconds, this timer runs out, and jumps to OnLoser in the NPC named NPC1.&lt;br /&gt;
&lt;br /&gt;
== AddTimerCount ==&lt;br /&gt;
Addtimercount allows you to 'delay' a previously started timer. It takes the current amount of ticks left, and add the amount specified by the parameter ticks. So, in essence, this delays the timer by &amp;lt;ticks&amp;gt; amount of milliseconds. For which timer it does this, is up to you and the player who is currently attached to the script. Which timer you want to alter, is what you specify with the second parameter, &amp;quot;NPC::OnEvent&amp;quot; (or as said earlier, the name of the timer).&amp;lt;br&amp;gt;&lt;br /&gt;
Some examples:&lt;br /&gt;
 addtimercount 5000,&amp;quot;My NPC::OnMyLabel&amp;quot;; // Adds 5 seconds to the timer with the name &amp;quot;My NPC::OnMyLabel&amp;quot;.&lt;br /&gt;
 addtimercount -10000,&amp;quot;NPC1::OnLoser&amp;quot;; // Removes 10 seconds from the timer with the name &amp;quot;NPC1::OnLoser&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== DelTimer ==&lt;br /&gt;
Deltimer is the counterpart of [[Addtimer]]. It stops and deletes a previously created timer that had the same event label/name as specified in the parameter. Of course, it only does this for the timer of the player that is currently attached to the script, but well, that is all it does.&amp;lt;br&amp;gt;&lt;br /&gt;
Some examples:&lt;br /&gt;
 deltimer &amp;quot;My NPC::OnMyLabel&amp;quot;; // Erases the timer that was supposed to jump to OnMyLabel in the NPC named My NPC.&lt;br /&gt;
 deltimer &amp;quot;NPC1::OnLoser&amp;quot;; // Erases the timer named NPC1::OnLoser. (Name == Event label)&lt;br /&gt;
&lt;br /&gt;
== Pro's and Cons ==&lt;br /&gt;
Using Player Timers have specific advantages and disadvantages. These will be listed in a compact way next.&amp;lt;br&amp;gt;&lt;br /&gt;
Advantages:&lt;br /&gt;
* Multiple Player Timers can run per NPC.&lt;br /&gt;
* Multiple Player Timers can be run per player.&lt;br /&gt;
* Can be manipulated easily.&lt;br /&gt;
Disadvantages:&lt;br /&gt;
* You always need a player attached to the script to use this.&lt;br /&gt;
* The timer is erased on log out. (Can be an advantage as well.)&lt;br /&gt;
* Cannot be read out without abusing a variable.&lt;br /&gt;
* Cannot be used when server start up or npc only triggered labels, otherwise the server will throw ''Player not Attached!'' error&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]] [[Category:Script_Command]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T08:12:09Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: I wonder should I link to Ind's script engine update topic?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and both also supports arrays. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it only use to store player's information that last until player logout, since it behaved that way, without having to use OnPCLogoutEvent to clear them.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in the table called 'char_reg_num_db' for integer type, and 'char_reg_str_db' for string type. The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;{,&amp;lt;min&amp;gt;{,&amp;lt;max&amp;gt;}};&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is simulate Guild/Party Array or simulate multi-dimensional array.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
     [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2); &lt;br /&gt;
     // If your guild ID would be 204, the contents of .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
     [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
     [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
     [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
or you can just&lt;br /&gt;
     [[setd]] &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2), [[getd]](&amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2)) +1;&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:35:55Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;{,&amp;lt;min&amp;gt;{,&amp;lt;max&amp;gt;}};&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is simulate Guild/Party Array or simulate multi-dimensional array.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
     [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2); &lt;br /&gt;
     // If your guild ID would be 204, the contents of .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
     [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
     [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
     [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
or you can just&lt;br /&gt;
     [[setd]] &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2), [[getd]](&amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2)) +1;&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:33:25Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: NO WONDER why people always did that 'setd &amp;quot;$var&amp;quot;+ getcharid(0)' last time, so that FALSE information comes from here&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is simulate Guild/Party Array or simulate multi-dimensional array.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
     [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2); &lt;br /&gt;
     // If your guild ID would be 204, the contents of .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
     [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
     [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
     [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
or you can just&lt;br /&gt;
     [[setd]] &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2), [[getd]](&amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2)) +1;&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:29:51Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: bad example ... but still need a little explanation for it I guess&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
     [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2); &lt;br /&gt;
     // If your guild ID would be 204, the contents of .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
     [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
     [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
     [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
or you can just&lt;br /&gt;
     [[setd]] &amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2), [[getd]](&amp;quot;$CastCapt&amp;quot;+ [[getcharid]](2)) +1;&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:25:17Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: there is no more 128 element limit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
 [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+[[getcharid]](2); &lt;br /&gt;
 // If your guild ID would be 204, the contents of &lt;br /&gt;
 // .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
 [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
 [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
 [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[freeloop]] true;&lt;br /&gt;
 [[for]] ([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]] (set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]] (set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]] ([[getd]](.@varname$) == 5)&lt;br /&gt;
 				[[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;, bc_all;&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:20:24Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: /* Getvariableofnpc */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
 [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+[[getcharid]](2); &lt;br /&gt;
 // If your guild ID would be 204, the contents of &lt;br /&gt;
 // .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
 [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
 [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
 [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[for]]([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]](set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]](set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]]([[getd]](.@varname$) == 5) [[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;,bc_all;&lt;br /&gt;
&lt;br /&gt;
Of course, getd and setd can also be used to overcome the 128 element limit of an array, like the guild variable example already demonstrated.&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]] ([[getvariableofnpc]](.unlocked, &amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			[[mes]] &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			[[mes]] &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]] (.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]] ([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	[[mes]] &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:16:48Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: oops ... I just tested using label name will make server throw error on me&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
 [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+[[getcharid]](2); &lt;br /&gt;
 // If your guild ID would be 204, the contents of &lt;br /&gt;
 // .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
 [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
 [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
 [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[for]]([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]](set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]](set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]]([[getd]](.@varname$) == 5) [[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;,bc_all;&lt;br /&gt;
&lt;br /&gt;
Of course, getd and setd can also be used to overcome the 128 element limit of an array, like the guild variable example already demonstrated.&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]]([[getvariableofnpc]](.unlocked,&amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			mes &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]](.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]]([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:13:40Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: except the using script command as variable, I did almost everything here LOL, and never getting any error. So there are no such thing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
 [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+[[getcharid]](2); &lt;br /&gt;
 // If your guild ID would be 204, the contents of &lt;br /&gt;
 // .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
 [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
 [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
 [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[for]]([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]](set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]](set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]]([[getd]](.@varname$) == 5) [[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;,bc_all;&lt;br /&gt;
&lt;br /&gt;
Of course, getd and setd can also be used to overcome the 128 element limit of an array, like the guild variable example already demonstrated.&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]]([[getvariableofnpc]](.unlocked,&amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			mes &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]](.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]]([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:11:02Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
 [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+[[getcharid]](2); &lt;br /&gt;
 // If your guild ID would be 204, the contents of &lt;br /&gt;
 // .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
 [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
 [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
 [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[for]]([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]](set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]](set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]]([[getd]](.@varname$) == 5) [[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;,bc_all;&lt;br /&gt;
&lt;br /&gt;
Of course, getd and setd can also be used to overcome the 128 element limit of an array, like the guild variable example already demonstrated.&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]]([[getvariableofnpc]](.unlocked,&amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			mes &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]](.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]]([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Special Restrictions ====&lt;br /&gt;
Like said above, there are some special restrictions. Here is the short overview:&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
* To be safe, never use the same variable name for different prefixes.&lt;br /&gt;
* Never use the same variable name to store an integer or a string.&lt;br /&gt;
&lt;br /&gt;
A short explanation of this is in order.&lt;br /&gt;
When you name your variable: &amp;quot;mes&amp;quot; (the message command), then this will override any mes command. The server will think that in all those cases, mes is not a command but a variable name. This will result in roughly, uhm, 88120+ errors (no kidding). The problem with this is though, that those errors aren't the real errors. The real error, set mes, 1; for example, isn't even shown.&lt;br /&gt;
The exact same thing occurs when the name of your variable matches the name of a label, function or subroutine.&lt;br /&gt;
When you use the same name, but with a different prefix, your server can start acting weird, and can give unexpected results. This is not always, but it can be common. So, when you are using a variable like $@temp and @temp, it is wise to change one of the two names. Just to be sure.&lt;br /&gt;
If you have two variables named the same, only one has the $-postfix (string), then the mapserver might give some errors. In any way, results will be unexpected and thus weird. So, if you use for example $PartyWon to store the party id and $PartyWon$ to store the party name, then things will go bad. It is best to change one of the two in something else. Perhaps like this: $PartyWon_Id and $PartyWon_Name$.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Variables</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Variables"/>
				<updated>2015-12-06T03:08:10Z</updated>
		
		<summary type="html">&lt;p&gt;Annieruru: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
When you are writing a new script, or altering a current script, it is very likely that you will need to store values and also look them up. Variables do exactly this. They are commonly compared to the files and folders in a filing cabinet. You can store a value or text in a variable, and look it up later again, or even change it.&lt;br /&gt;
This article will cover the different kinds of variables which exist in the Athena Scripting Language. It will also process their common use, their scopes and limits. Also, each variable will be accompanied by a small example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Variables ==&lt;br /&gt;
[[Hercules]] uses different kind of variables for different kinds of situations. Variables come in different forms and sizes. Each variable type has a different scope, from temporal player and NPC variables all up to global system variables. Integer values (Integer values are whole numbers, like 0, 1, 2, 1487, -73452) are stored in a different way than String values (String means text or a single letter, like &amp;quot;I love you!&amp;quot; or &amp;quot;x&amp;quot;). Some types of script variables even support a single dimension array. But if this all is too much for you, it will all become clear in time. First, the overview of which variables are allowed and which aren't.&lt;br /&gt;
&lt;br /&gt;
=== Allowed Variables ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Prefix&lt;br /&gt;
!Type&lt;br /&gt;
!Normal&lt;br /&gt;
!Array&lt;br /&gt;
!Exceptions&lt;br /&gt;
|-&lt;br /&gt;
|''none''&lt;br /&gt;
|Character&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|temporary version allows arrays&lt;br /&gt;
|-&lt;br /&gt;
|#&lt;br /&gt;
|Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|##&lt;br /&gt;
|Global Account&lt;br /&gt;
|OK!&lt;br /&gt;
|FAIL!&lt;br /&gt;
|no temporary version&lt;br /&gt;
|-&lt;br /&gt;
|.&lt;br /&gt;
|NPC&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|-&lt;br /&gt;
|$&lt;br /&gt;
|Global&lt;br /&gt;
|OK!&lt;br /&gt;
|OK!&lt;br /&gt;
|''none''&lt;br /&gt;
|}&lt;br /&gt;
The schema shown above goes for each type of variable, no matter if it is temporary or permanent, integer or a string variable.&lt;br /&gt;
&lt;br /&gt;
=== Format of Variables ===&lt;br /&gt;
&lt;br /&gt;
Unlike C, Java or any coding language, with scripting, the type of variable is determined by the name, not by the declaration. For example, to make a variable in C an Integer variable, you will have to declare it by typing: &amp;quot;int var;&amp;quot;. Athena Scripting, is like the name already implies, a Scripting language. There is no need to declare a variable before using it, it is all done by the name of variable.&lt;br /&gt;
The most basic variable is the permanent integer player variable. It looks like this:&lt;br /&gt;
 var&lt;br /&gt;
To make it a string variable, all you have to do is put a $ after it, like this:&lt;br /&gt;
 var$&lt;br /&gt;
You can also make it a temporal variable. This means that the value is stored until the next reboot or crash of the map server. All you need to do is add the prefix @. (Prefix means, something that is put in front.) So that makes the variable look like this:&lt;br /&gt;
 @var&lt;br /&gt;
And for a temporal player string variable, it looks like this:&lt;br /&gt;
 @var$&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the array option fails for permanent player variables. However, it does work for the temporal version. To make a variable behave like an array, all you have to do is add [] after the variable. We will get into it later on in detail, but here is how it would look for a temporal player integer array variable and a temporal player string variable:&lt;br /&gt;
 @var[]&lt;br /&gt;
 @var$[]&lt;br /&gt;
As you can see, it is placed even after the string postfix when it is present. (Postfix means something at the end of something. So, the string postfix is $ and the array postfix is [].)&lt;br /&gt;
&lt;br /&gt;
Now, for a different type of variable, like global or account, you will have to use a different prefix. Kind of like the temporal prefix @, only this gets even placed in front of that. The prefixes are noted in the schematic at the start of the previous section. But, let's make an example list to show you all possible things:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! rowspan=&amp;quot;3&amp;quot; scope=&amp;quot;col&amp;quot; | Type&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Normal&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Array&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Integer&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | String&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Player&lt;br /&gt;
| @var || var || @var$ || var$ || @var[] || N/A || @var$[] || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Account&lt;br /&gt;
| N/A || #var || N/A || #var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global Account&lt;br /&gt;
| N/A || ##var || N/A || ##var$ || N/A || N/A || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | NPC&lt;br /&gt;
| .@var || .var || .@var$ || .var$ || .@var[] || .var[] || .@var$[] || .var$[]&lt;br /&gt;
|-&lt;br /&gt;
| scope=&amp;quot;row&amp;quot; | Global&lt;br /&gt;
| $@var || $var || $@var$ || $var$ || $@var[] || $var[] || $@var$[] || $var$[]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Variables ==&lt;br /&gt;
&lt;br /&gt;
Now that we know which variables exist, it is time to elaborate on how you exactly use them.&lt;br /&gt;
&lt;br /&gt;
=== Setting/Modifying/Deleting Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
&lt;br /&gt;
You set a variable by using the command set. The format is: &lt;br /&gt;
* [[set]] &amp;lt;variable&amp;gt;,&amp;lt;value&amp;gt;; &lt;br /&gt;
or&lt;br /&gt;
* &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt;;&lt;br /&gt;
Examples:&lt;br /&gt;
 set var, 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 set $var$, &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 set .@var[5], 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
or&lt;br /&gt;
 var = 5; // Setting a permanent integer player variable to 5.&lt;br /&gt;
 $var$ = &amp;quot;Hello&amp;quot;; // Setting a global string variable to &amp;quot;Hello&amp;quot;.&lt;br /&gt;
 .@var[5] = 10; // Setting the sixth element (5 + 1) of the temporal integer NPC variable to 10.&lt;br /&gt;
 #var = #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again. &lt;br /&gt;
&lt;br /&gt;
You can also unset a variable, which is not needed per se, but saves memory. To unset an integer value, you need to store 0 in it, so like this:&lt;br /&gt;
 set var, 0;&lt;br /&gt;
 var = 0;&lt;br /&gt;
To unset a string variable, you will have to set the variable to &amp;quot;&amp;quot;. (An empty string.) Another example:&lt;br /&gt;
 set @var$, &amp;quot;&amp;quot;;&lt;br /&gt;
 @var$ = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Other possible examples&lt;br /&gt;
 @i = 1;&lt;br /&gt;
 @i++;&lt;br /&gt;
 @i *= 2;&lt;br /&gt;
 @i = @j = 1;&lt;br /&gt;
 @i -= @j;&lt;br /&gt;
 &lt;br /&gt;
 for( @i = 0; 10 &amp;gt; @i; ++@i ) { }&lt;br /&gt;
 while( (.@j = .@i++) &amp;lt; 20 ) { }&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
An array is a variable that references consecutive memory blocks of the same type. In C or any other programming / scripting language, an array has no limitation as in how many indexes (how many consecutive blocks of memory it references to) it can hold, nor its dimensions (how many arrays can an array hold. It's like a matrix of 2x3, for example). &lt;br /&gt;
&lt;br /&gt;
In Hercules, The limitation is (int)2147483647 elements held by a single array, and a single dimension (mostly because strings can use a full index regardless of the length of the string it references to).&lt;br /&gt;
&lt;br /&gt;
Arrays can be set and unset using the default set. They also come with a special set of commands, to quickly set multiple values, or cleaning them. These are the Array related commands. &lt;br /&gt;
*[[cleararray]]&lt;br /&gt;
*[[copyarray]]&lt;br /&gt;
*[[deletearray]]&lt;br /&gt;
*[[getarraysize]]&lt;br /&gt;
*[[getelementofarray]]&lt;br /&gt;
*[[setarray]]&lt;br /&gt;
To quickly set multiple values in an array, you need to use setarray. It will look like this:&lt;br /&gt;
 setarray @array[0],100,200,300;&lt;br /&gt;
This will result in this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 200&lt;br /&gt;
 @array[2] == 300&lt;br /&gt;
&lt;br /&gt;
Deletearray is used to quickly erase a specified amount of elements of an array. It can also be used to completely unset it.&lt;br /&gt;
 deletearray @array[0],1; // Deletes element 0 of the array, and moves every other entry up.&lt;br /&gt;
Result using the previous array:&lt;br /&gt;
 @array[0] == 200&lt;br /&gt;
 @array[1] == 300&lt;br /&gt;
To completely erase an array using this command, you can do this:&lt;br /&gt;
 deletearray @array[0];&lt;br /&gt;
&lt;br /&gt;
Another way to quickly set or unset an array is the cleararray command. Cleararray is actually better than setarray if you want to fill an array with the same values, like this:&lt;br /&gt;
 cleararray @array[0],100,57;&lt;br /&gt;
The result is this:&lt;br /&gt;
 @array[0] == 100&lt;br /&gt;
 @array[1] == 100&lt;br /&gt;
 ...&lt;br /&gt;
 @array[56] == 100&lt;br /&gt;
Taking the previous @array as example variable, to clear it partially, you can use the command in this way:&lt;br /&gt;
 cleararray @array[1],0,8;&lt;br /&gt;
Please note, that unlike deletearray, it will not shift the remaining values. The result will be this:&lt;br /&gt;
 @array[0], @array[9] ~ @array[56] == 100&lt;br /&gt;
 @array[1] ~ @array[8] == 0&lt;br /&gt;
&lt;br /&gt;
=== Reading out Variables ===&lt;br /&gt;
==== Normal Variables ====&lt;br /&gt;
Storing and unsetting variables is one thing. Reading them out is something else. Thankfully, it is an easy something else. We already actually read out a variable before, at the modifying part:&lt;br /&gt;
 set #var, #var * 2; // Multiplying the value that is in #var by 2 and store it in #var again.&lt;br /&gt;
As you can see, all you need to do to read out a variable, is only typing the variable name.&lt;br /&gt;
It works the same for any command like the if statement:&lt;br /&gt;
 if(#var &amp;gt; 2) close; // If #var contains a value bigger than 2, then show a close button.&lt;br /&gt;
If you are using the mes command, or another text displaying command, it works a bit differently:&lt;br /&gt;
 mes #var +&amp;quot;&amp;quot;; // Will display a line with only the value of #var.&lt;br /&gt;
 mes &amp;quot;You have killed &amp;quot; + dead_porings + &amp;quot; Porings.&amp;quot;;  // Will display this: &lt;br /&gt;
 						      // &amp;quot;You have killed &amp;lt;value of dead_porings&amp;gt;&lt;br /&gt;
 						      // Porings.&amp;quot;&lt;br /&gt;
 mes @name$; // If @name$ contains &amp;quot;[Kafra]&amp;quot;, it will display &amp;quot;[Kafra]&amp;quot;&lt;br /&gt;
 mes &amp;quot;My name is &amp;quot;+@name$; // If @name$ contains &amp;quot;Trevor&amp;quot;, it will display: &amp;quot;My name is Trevor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===== Other ways to check variables =====&lt;br /&gt;
There are other ways to check the value of a variable, as in if it has been declared or not.&lt;br /&gt;
&lt;br /&gt;
You can check if a variable has been declared, different from 0, or not,equal to 0. A variable that has been declared and set to 0 is said to be &amp;quot;undeclared&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To do so, you do:&lt;br /&gt;
&amp;lt;pre&amp;gt;if (foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is different from 0 (declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo != 0) ...	// Same as above&lt;br /&gt;
&lt;br /&gt;
if (!foo) ...		// this will check if 'foo' has been declared or not. If the value 'foo'&lt;br /&gt;
			// holds is equal to 0 (not declared), it will return true. Otherwise it &lt;br /&gt;
			// will return false.&lt;br /&gt;
&lt;br /&gt;
if (foo == 0) ...	// Same as above&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
! is a Logical Not operator. If you use it on the number 0 it will return 1. If you use it on anything other than 0 it will return 0.&lt;br /&gt;
&lt;br /&gt;
Note : ! doesn't support string variable&lt;br /&gt;
&lt;br /&gt;
==== Array Variables ====&lt;br /&gt;
To read out a value of an array, you will have to specify which element of the array you want to see. Let's say, we have the following array:&lt;br /&gt;
 @array[0] == 41&lt;br /&gt;
 @array[1] == 12&lt;br /&gt;
 @array[2] == 54&lt;br /&gt;
 @array[3] == 4&lt;br /&gt;
 @array[4] == 22&lt;br /&gt;
 @array[5] == 30&lt;br /&gt;
 @array[6] == 21&lt;br /&gt;
And we have the following script:&lt;br /&gt;
 mes &amp;quot;[Lotto]&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And today's numbers are:&amp;quot;;&lt;br /&gt;
 mes @array[0]+&amp;quot;, &amp;quot;+@array[1]+&amp;quot;, &amp;quot;+@array[2]+&amp;quot;, &amp;quot;+@array[3]+&amp;quot;, &amp;quot;+@array[4]+&amp;quot; and &amp;quot;+@array[5]+&amp;quot;.&amp;quot;;&lt;br /&gt;
 mes &amp;quot;And the bonus number is &amp;quot;+@array[6]+&amp;quot;.&amp;quot;;&lt;br /&gt;
Then it will display this:&lt;br /&gt;
 [Lotto]&lt;br /&gt;
 And today's numbers are:&lt;br /&gt;
 41, 12, 54, 4, 22 and 30.&lt;br /&gt;
 And the bonus number is 21.&lt;br /&gt;
&lt;br /&gt;
=== Temporal vs Permanent ===&lt;br /&gt;
When you use a variable, you can choose between making it temporal or permanent, with the exception of account variables. Permanent variables survive everything, even a reboot of the server. Temporal variables however, do not survive a reboot and are cleaned out when the map server is killed. This is useful when you only want to store simple things, like a random number or the name of a NPC.&lt;br /&gt;
Please note that the temporal NPC variable actually works a bit different. It ceases to exist when the script encounters the close; command or the end; command.&lt;br /&gt;
&lt;br /&gt;
== Variables in Detail ==&lt;br /&gt;
This section will cover each variable indepth, including examples of how and when to use them.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global variables support the temporal option, the string option and the array option.&lt;br /&gt;
The advantage of a global variable is that they can be accessed by any NPC, function or subroutine. They also do not require the interaction of a player, and can thus be used by time triggered events, or during start up events. When used without the @-prefix (Temporal prefix), this variable survives a server restart, and thus can be used to store important information like announcement messages.&lt;br /&gt;
&lt;br /&gt;
Global permanent variables are stored in 'mapreg' table. Changing the value of a global variable while the server is up, should only be done by using set, setd or one of the array commands. Altering the value of it in 'mapreg' table while the server is running, will be ignored and overwritten by the next save sweep.&lt;br /&gt;
If you want to alter the value of a global variable manually, so without any of the NPC commands, then you must make sure that your server is completely down.&lt;br /&gt;
The temporal global variable is stored directly in the memory, and thus not accessible through any other way besides the default NPC commands.&lt;br /&gt;
&lt;br /&gt;
Another special thing about the way Global Variables are saved, is that they are always treated as if they are an Array. In 'mapreg' table, the format is this:&lt;br /&gt;
&amp;lt;variable name&amp;gt;,&amp;lt;index&amp;gt;,&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prefix of a global variable is $&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global variables are perfect to enable/disable NPCs on command. For example, if you want to host an event and you made a warper for it, then you want the warper to do nothing, until a GM starts hosting the event. You will also want the NPC to automatically be closed when the server crashes or reboots. This will prevent any players to go to the event before the GM is online.&lt;br /&gt;
Here is how you could code such a simple warper:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Event Warper	116,{&lt;br /&gt;
 	[[if]] ([[getgmlevel]]() &amp;gt;= 60) [[goto]] L_GMMenu; // If the player is a GM, go to the GM Menu.&lt;br /&gt;
 	if (!$@EW_Enable) { // If the event is disabled, tell the player.&lt;br /&gt;
 		[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Sorry, but the event arena is closed for the moment.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you want to go to the event?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] ([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 1) {&lt;br /&gt;
 		[[warp]] $@event_map$,$@event_x,$@event_y; // Warp to the map stored in $@event_map$, at the coords $@event_x and $@event_y&lt;br /&gt;
 	}&lt;br /&gt;
 	close;&lt;br /&gt;
 	&lt;br /&gt;
 L_GMMenu:&lt;br /&gt;
 	mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Please choose an option.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;View Settings&amp;quot;,&amp;quot;Set Destination&amp;quot;,&amp;quot;Enable Warper&amp;quot;,&amp;quot;Disable Warper&amp;quot;,&amp;quot;Leave&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // View Settings&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] ($@EW_Enable) mes &amp;quot;I am currently enabled.&amp;quot;;&lt;br /&gt;
 		[[else]] mes &amp;quot;I am currently disabled.&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;The current destination is: &amp;quot;+$@event_map$+&amp;quot; at &amp;quot;+$@event_x+&amp;quot;, &amp;quot;+$@event_y+&amp;quot;.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Set Destination&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the destination map.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_map$; // Setting the event map in $@event_map$&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the x coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_x; // Setting the x coordinate in $@event_x&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Please enter the y coordinate.&amp;quot;;&lt;br /&gt;
 		next;&lt;br /&gt;
 		[[input]] $@event_y; // Setting the y coordinate in $@event_y&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Destination set.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 3: // Enable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		if ($@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already enabled.&amp;quot;;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			[[set]] $@EW_Enable, 1; // Setting $@EW_Enable to 1, to enable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 4: // Disable Warper&lt;br /&gt;
 		mes &amp;quot;[Event Warper]&amp;quot;;&lt;br /&gt;
 		[[if]] (!$@EW_Enable) {&lt;br /&gt;
 			mes &amp;quot;I am already disabled.&amp;quot;;&lt;br /&gt;
 		} [[else]] {&lt;br /&gt;
 			[[set]] $@EW_Enable, 0; // Setting $@EW_Enable to 0, to disable the NPC.&lt;br /&gt;
 			mes &amp;quot;It has been done.&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 5: // Leave&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[goto]] L_GMMenu;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you want a warper that is enabled for several days, like a special event that is always open in this period, then you should use permanent global variables. This will allow the NPC to be active even after a server crash, so that the people can access the special map right away, without having to wait for a GM to come online.&lt;br /&gt;
So, instead of $@EW_Enable, you should use $EW_Enable. And the map, x and y variables should become $event_map$, $event_x and $event_y.&lt;br /&gt;
&lt;br /&gt;
=== Global Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Global Account Variables aren't really of any use unless you run a server which has multiple map servers and only one login server. This is why it is a rarely used variable. In theory, it is exactly the same as a normal account variable, with one slight difference.&lt;br /&gt;
It is kind of hard to explain if this is your first time using variables, but in essence, a global account variable is stored by the login server instead of the char server. This makes it so that the value of the account variable is the same for the player's account in each of the map servers of your server. The normal account variable is unique on each map server.&lt;br /&gt;
The global account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the normal account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 1 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a global variable without using NPC commands. However, the entire account needs to be offline and out of the memory on ALL the login, char and mapservers, to make it so that changing it has any effect. If you change the value of a global account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of a global account variable is ##&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Global account variables are useful when you use a voting NPC. If you want it so that each account can only vote once, and you have multiple mapservers, then you want all the other mapservers to know if an account has already voted or not. This will prevent a certain account to vote more than once.&lt;br /&gt;
The script below is an example of such a voting NPC.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (##AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] ##AlreadyVoted, 1; // Player has already voted. Setting global account variable ##AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Account Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Account variables work in a similar way as global account variables, and also have the same restrictions. It connects a value to a player's account, which can be useful for a Vote NPC, or a quest NPC that a player is only allowed to do once.&lt;br /&gt;
Whereas a global account variable is the same for each mapserver, if you have a setup with multiple mapservers and a single login server, a normal account variable will contain different values for each mapserver.&lt;br /&gt;
The account variable does not support the temporal prefix (@) nor the array. This means that they are less dynamic and always survive a server restart.&lt;br /&gt;
&lt;br /&gt;
The global account variable is stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 2 and that the 'char_id' field will contain a 0.&lt;br /&gt;
&lt;br /&gt;
The rumours are that it is possible to alter a variable without using NPC commands. However, the entire account needs to be offline and out of the memory to make it so that changing it has any effect. If you change the value of a account variable and there is a character online of that account, then your new value will be overwritten in time by the saving routine of the server.&lt;br /&gt;
&lt;br /&gt;
The prefix of an account variable is #&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The account variable is, just like the global account variable, very suited for a voting NPC. Especially when you only have one mapserver tied to your login server. Because this setup is very common, the normal account variable is often used. &lt;br /&gt;
Also, even if you have multiple mapservers, then you might want to allow players to do the same quest on each mapserver, so that they can have the reward(s) on all the mapservers.&lt;br /&gt;
To keep it easy, here is the voting NPC again, only with normal account variables.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Poll	116,{&lt;br /&gt;
 	[[if]] (#AlreadyVoted) { // Account has already voted on a mapserver.&lt;br /&gt;
 		[[mes]] &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	mes &amp;quot;Poll of today:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you like this server?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[switch]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;)) {&lt;br /&gt;
 	[[case]] 1: // Voted Yes.&lt;br /&gt;
 		[[set]] $Poll_Yes, $Poll_Yes + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	[[case]] 2: // Voted No.&lt;br /&gt;
 		[[set]] $Poll_No, $Poll_No + 1;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	set #AlreadyVoted, 1; // Player has already voted. Setting account variable #AlreadyVoted to 1.&lt;br /&gt;
 	mes &amp;quot;Thank you for your vote.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;These are the current results:&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_Yes+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_Yes * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Yes : &amp;quot;+$Poll_No+&amp;quot;/&amp;quot;+ ($Poll_Yes + $Poll_No) +&amp;quot; votes (&amp;quot;+ (($Poll_No * 100)/($Poll_Yes + $Poll_No)) +&amp;quot;%).&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Player Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
Player variables are a type of variable that can only be accessed by the player who is using the script. The player variable supports the temporal tag, and also supports arrays, but only in combination with the temporal tag. So, var[] will not work, but @var[] will work. When you store a value in var$ for PlayerA, it will have a different value than the contents of var$ for PlayerB. This comes in handy when you are writing a quest and need to keep track of the progress. For example, when a player accepted a quest, you can set a variable named quest_progress to 1. When he finishes the next part, you can set it to 2, etc. etc.&lt;br /&gt;
Permanent player variables are also the way to deny future access to a NPC or quest. Simply set a permanent player variable to a certain value at the end of the NPC or quest, and check for that value at the start of the quest.&lt;br /&gt;
Temporal player variables used to be widely used, and still are in the older revisions. Nowadays it has become almost completely obselete though, due to the temporal NPC variable. There are still some uses for it though. For example, if you temporarely want to store a value for a player and use it at another NPC as well.&lt;br /&gt;
&lt;br /&gt;
Permanent player variables are stored in &amp;quot;save\account.txt&amp;quot; for a TXT server, and for the SQL server it is stored in the table called 'global_reg_value'. These locations are used for mixed storage. This means, that also the global account variable and the player variable is stored here. You can recognize a global account variable by the fact that the 'type' field is set to 3 and that the 'account_id' field will contain a 0. &lt;br /&gt;
The temporal player variable is directly stored in the memory.&lt;br /&gt;
&lt;br /&gt;
You are able to manipulate the value of a permanent player variable without using script commands. Simply make sure the character of which the variable is, is offline. Of course, this does not apply for a temporal player variable.&lt;br /&gt;
&lt;br /&gt;
Player variables have no prefix&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
A simple example of the usage of a permanent player variable, is a one time freebee giver. After the freebee has been given, the variable is set and when the player talks to the NPC again, it will check for this and denies access.&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Freebee Giver	116,{&lt;br /&gt;
 	[[if]] (GotFreebee) { // If the permanent player variable GotFreebee is not 0, then do what is inside the { }.&lt;br /&gt;
 		[[mes]] &amp;quot;You have already gotten the freebee.&amp;quot;;&lt;br /&gt;
 	} [[else]] {&lt;br /&gt;
 		[[mes]] &amp;quot;Welcome to hour server.&amp;quot;;&lt;br /&gt;
 		[[mes]] &amp;quot;To show our gratitude, here is a one time free item.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[getitem]] 999,1;&lt;br /&gt;
 		[[set]] GotFreebee, 1; // Item given, sets permanent player variable GotFreebee to 1.&lt;br /&gt;
 		[[mes]] &amp;quot;Have fun.&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
An example of using a temporal variable, is an interactive NPC system, responding to a random mood of a player. It can look like this:&lt;br /&gt;
&lt;br /&gt;
 -	script	mood	-1,{&lt;br /&gt;
 OnPCLoginEvent:&lt;br /&gt;
 	[[set]] @mood, [[rand]](3); // 0 == happy, 1 == sad, 2 == grumpy, 3 == in love.&lt;br /&gt;
 	[[setarray]] @moodtxt$[0], &amp;quot;happy&amp;quot;, &amp;quot;sad&amp;quot;, &amp;quot;grumpy&amp;quot;, &amp;quot;in love&amp;quot;;&lt;br /&gt;
 	[[dispbottom]] &amp;quot;You feel &amp;quot;+@moodtxt$[@mood]+&amp;quot; today.&amp;quot;;&lt;br /&gt;
 	[[end]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[switch]](@mood) { // Determine the setting of @mood.&lt;br /&gt;
 	[[case]] 0: // happy&lt;br /&gt;
 		[[mes]] &amp;quot;Oh my, we are cheerful today, aren't we!&amp;quot;;&lt;br /&gt;
 		break;&lt;br /&gt;
 	case 1: // sad&lt;br /&gt;
 		mes &amp;quot;Why are you so sad?&amp;quot;;&lt;br /&gt;
 		mes &amp;quot;Here, this might cheer you up.&amp;quot;;&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[percentheal]] 100,100;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 2: // grumpy&lt;br /&gt;
 		mes &amp;quot;Come on, cheer up. It's a nice day today.&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	case 3: // in love&lt;br /&gt;
 		mes &amp;quot;Wow, did you find that one person? Cool!&amp;quot;;&lt;br /&gt;
 		[[break]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	Grumpy Person	116,{&lt;br /&gt;
 	[[if]] (@mood != 2) { // Only wants to talk to another grumpy person.&lt;br /&gt;
 		[[mes]] &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;What are you doing here?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[mes]] [[strcharinfo]](0);&lt;br /&gt;
 	mes &amp;quot;Go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes &amp;quot;No, you go away!&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	// ... (rest of NPC)&lt;br /&gt;
 	[[close]]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== NPC Variables ===&lt;br /&gt;
==== Details ====&lt;br /&gt;
NPC variables support, just like global variables, the temporal prefix as well as the array postfix. They aren't in existence for that long yet, but are already widely used. The reason for this, is that the temporal NPC variable is a true temporal variable. It is unique per player per NPC, until the close; or end; command. This means it can be used to temporary store a value, or an array or whatever to make coding easier for you.&lt;br /&gt;
The permanent NPC variable is not as permanent as it may sound at first. It is used to store a variable per NPC. This variable is accessible by any player that uses that NPC. However, on server restart, the value of that variable is lost. NPCs are capable of requesting the value of a permanent NPC variable owned by another NPC. For this, the getvariableofnpc command is used, which will be explained further down in this article.&lt;br /&gt;
Permanent NPC variables can be used in logging systems or for example a racing event. That is, if you do not want to waste global variables.&lt;br /&gt;
Note that if you duplicate the NPC, all those NPC share the same NPC variable. But this might subject to change in the future.&lt;br /&gt;
&lt;br /&gt;
All the NPC variables are directly stored in the memory, and are therefor not editable by anything else besides script commands.&lt;br /&gt;
&lt;br /&gt;
The prefix for a NPC variable is .&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Temporal NPC variables are widely used to temporary save a value. This can make customizing your script easier. For example, you can store the NPC name in a temporal NPC variable, like shown in the script beneath:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[set]] .@name$, &amp;quot;^FF0000&amp;quot;; // Setting the color, red in this case.&lt;br /&gt;
 	set .@name$, .@name$ + &amp;quot;Sir Eduard&amp;quot;; // Setting the name of the NPC&lt;br /&gt;
 	set .@name$, &amp;quot;[&amp;quot;+.@name$+&amp;quot;^000000]&amp;quot;; // Finalizing the name. It will now show: &amp;quot;[Sir Eduard]&amp;quot;, where Sir Eduard is written in red.&lt;br /&gt;
 	[[mes]] .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;Hello there.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Welcome to our server.&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;I hope you will enjoy your stay here.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;We have a lovely fountain at the center, as well as some beautiful kafra spread out through the town.&amp;quot;;&lt;br /&gt;
 	next;&lt;br /&gt;
 	mes .@name$; // Display Name&lt;br /&gt;
 	mes &amp;quot;So, feel free to look around.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;And have a nice day.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you have to do now to change the name being displayed is changing &amp;quot;Sir Eduard&amp;quot; into something else. In larger scripts, this means that you do not have to edit the name at 100+ places. The same applies for the color, which can be changed in the first line.&lt;br /&gt;
&lt;br /&gt;
A short example of a permanent variable might be this 'logging' NPC:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	Random Person	116,{&lt;br /&gt;
 	[[mes]] &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Do you have any gossip?&amp;quot;;&lt;br /&gt;
 	[[next]];&lt;br /&gt;
 	[[if]] (.LastPerson$ != &amp;quot;&amp;quot;) { // If there is a name stored, do what is inside the { }&lt;br /&gt;
 		[[mes]] .LastPerson$ + &amp;quot; had some really nice gossip.&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[set]] .LastPerson$, [[strcharinfo]](0); // Set the current player's name as the last player's name.&lt;br /&gt;
 	[[mes]] &amp;quot;Aha, I see.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Thank you for this new info.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I should tell it to my friends right away.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Special Commands ==&lt;br /&gt;
=== Input ===&lt;br /&gt;
Input is the most basic command to get a player to input a value and store it in a variable. Input itself has some safeguards placed inside that prevent entering faulty data.&lt;br /&gt;
The format for input is:&lt;br /&gt;
*[[input]] &amp;lt;variable&amp;gt;;&lt;br /&gt;
Despite it seems that you can enter anything in the input box as a player, this is not the case. Let's review the following two cases:&lt;br /&gt;
 1. input @name$;&lt;br /&gt;
 2. input @number;&lt;br /&gt;
The first one allows you to enter a string. A person can still input a number, but it will be stored as if it was a string.&lt;br /&gt;
The second one allows you to enter a number. If a person enters a negative number, it will store 0. If the person tries to enter a string, or a letter, it will also store 0.&lt;br /&gt;
&lt;br /&gt;
=== Getd &amp;amp; Setd ===&lt;br /&gt;
Getd and Setd are a couple of special commands. They allow the use of dynamically named variables, as well as a way to cheat and make multi-dimensional variables.&lt;br /&gt;
Their format is like this:&lt;br /&gt;
* [[getd]] &amp;quot;Variable Name&amp;quot;;&lt;br /&gt;
* [[setd]] &amp;quot;variable name&amp;quot;,&amp;lt;value&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The most common use of getd and setd is in combination with global variables. This is because you have an infinite amount of global variables, whereas account and player variables are limited in their number. Also, global variables can survive a restart of the server of course. Let's just use some examples to make it clear what their power is.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Guild Variables ====&lt;br /&gt;
Guild Variables do not exist, and since an array is limited upto 128 elements, it is not adviced to use that for storage. Yet it can be needed to store guild variables, when you want to do a ranking of some sort. The following example is a snippet from gldfunc_ev_agit.txt, and stores the amount of times a guild has captured a castle.&lt;br /&gt;
&lt;br /&gt;
 [[set]] .@NameOfGuildVar$, &amp;quot;$CastCapt&amp;quot;+[[getcharid]](2); &lt;br /&gt;
 // If your guild ID would be 204, the contents of &lt;br /&gt;
 // .@NameOfGuildVar$ would be: &amp;quot;$CastCapt204&amp;quot;&lt;br /&gt;
 [[set]] .@Score, [[getd]](.@NameOfGuildVar$); // Retreive the current score.&lt;br /&gt;
 [[set]] .@Score, .@Score + 1; // Add one to it.&lt;br /&gt;
 [[setd]] .@NameOfGuildVar$, .@Score; // Put in the new score.&lt;br /&gt;
&lt;br /&gt;
Of course, the same can be done to simulate Party Variables, which also officially do not exist.&lt;br /&gt;
&lt;br /&gt;
==== Simulating Multidimensional Arrays ====&lt;br /&gt;
Now, let's say you know your stuff, and really are used to using arrays. Then you might want to consider simulating multi-dimensional arrays. This snippet will use the for command. If you do not know how to use it, it is best to skip this example.&lt;br /&gt;
&lt;br /&gt;
 // Example of iterating the 3-dimensional array $@array[100,100,100].&lt;br /&gt;
 [[for]]([[set]] .@i, 0; .@i &amp;lt; 100; [[set]] .@i, .@i + 1) {&lt;br /&gt;
 	[[for]](set .@j, 0; .@j &amp;lt; 100; set .@j, .@j + 1) {&lt;br /&gt;
 		[[for]](set .@k, 0; .@k &amp;lt; 100; set .@k, .@k + 1) {&lt;br /&gt;
 			[[set]] .@varname$, &amp;quot;$@array&amp;quot;+.@i+&amp;quot;_&amp;quot;+.@j+&amp;quot;[&amp;quot;+.@k+&amp;quot;]&amp;quot;; &lt;br /&gt;
 			// Let's say .@i is 50, .@j is 22 and .@k is 95. Then this will be in .@varname$:&lt;br /&gt;
 			// $@array50_22[95]&lt;br /&gt;
 			[[if]]([[getd]](.@varname$) == 5) [[set]] .@FivesFound, .@FivesFound + 1;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 [[announce]] &amp;quot;I have found &amp;quot;+.@FivesFound+&amp;quot; occurances of 5 in your multidimensional array.&amp;quot;,bc_all;&lt;br /&gt;
&lt;br /&gt;
Of course, getd and setd can also be used to overcome the 128 element limit of an array, like the guild variable example already demonstrated.&lt;br /&gt;
&lt;br /&gt;
=== Getvariableofnpc ===&lt;br /&gt;
Getvariableofnpc is a method to get the value of a permanent NPC variable of another NPC.&lt;br /&gt;
The official format is like this:&lt;br /&gt;
* [[getvariableofnpc]] &amp;lt;Variable Name&amp;gt;,&amp;quot;NPC Name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
It's uses can vary, but from what I've seen until now is that it is mainly used to sync several NPCs or to make checks in a global temporal unlocking quest.&lt;br /&gt;
To sync a variable NPC with the value of a variable of another NPC, you could use this line:&lt;br /&gt;
 set .v,getvariableofnpc(.var,&amp;quot;A NPC&amp;quot;); &lt;br /&gt;
 // Retreives value of .var of the NPC called &amp;quot;A NPC&amp;quot;&lt;br /&gt;
 // and puts the found value in .v of this NPC.&lt;br /&gt;
&lt;br /&gt;
A global temporal unlocking quest can be like this:&lt;br /&gt;
&lt;br /&gt;
 prontera,147,177,7	script	PvP Warper	116,{&lt;br /&gt;
 	[[if]]([[getvariableofnpc]](.unlocked,&amp;quot;PvP Unlocker&amp;quot;)) {&lt;br /&gt;
 		[[mes]] &amp;quot;Want to go to the PvP room?&amp;quot;;&lt;br /&gt;
 		[[next]];&lt;br /&gt;
 		[[if]]([[select]](&amp;quot;Yes&amp;quot;,&amp;quot;No&amp;quot;) == 2) {&lt;br /&gt;
 			mes &amp;quot;Ok, guess not.&amp;quot;;&lt;br /&gt;
 			mes &amp;quot;Good bye.&amp;quot;;&lt;br /&gt;
 			[[close]];&lt;br /&gt;
 		}&lt;br /&gt;
 		[[close2]];&lt;br /&gt;
 		[[warp]] &amp;quot;pvp_n_1-1&amp;quot;,0,0;&lt;br /&gt;
 		[[end]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[mes]] &amp;quot;No one has opened the PvP room yet.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;At least one person needs to visit the ^FF0000PvP Unlocker^000000, and help him to open up PvP.&amp;quot;;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prontera,147,175,7	script	PvP Unlocker	116,{&lt;br /&gt;
 	[[if]](.unlocked) {&lt;br /&gt;
 		[[mes]] &amp;quot;To enter the PvP room, talk to the ^FF0000PvP Warper^000000.&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[if]]([[countitem]](512) &amp;lt; 1) {&lt;br /&gt;
 		[[mes]] &amp;quot;I will not open the PvP room until I get an apple!&amp;quot;;&lt;br /&gt;
 		[[close]];&lt;br /&gt;
 	}&lt;br /&gt;
 	[[delitem]] 512, 1;&lt;br /&gt;
 	[[mes]] &amp;quot;Thank you for that juicy apple.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;I will open the PvP room now.&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Enjoy.&amp;quot;;&lt;br /&gt;
 	[[set]] .unlocked, 1;&lt;br /&gt;
 	[[close]];&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Other Important Info ==&lt;br /&gt;
=== Naming your Variables ===&lt;br /&gt;
==== General Restrictions ====&lt;br /&gt;
Just like any other scripting or coding language, variable names have certain restrictions. Some things are simply not accepted, and some things are accepted, but really bad to do.&lt;br /&gt;
* Permanent Character variable name must  start with a letter after any prefix, if it is there. &lt;br /&gt;
* It also cannot have any arithmetic operators. (This means, none of the following signs: +, -, /, * and any other math sign.)&lt;br /&gt;
* Brackets of any kind are also not allowed, excluding the array postfix of course.&lt;br /&gt;
* Other restrictions to the variable are the length of the name, it is not allowed to succeed 31 characters.&lt;br /&gt;
Basically, this all means, that the name part can only contain the following characters: a~z, A~Z, 0~9 and _&lt;br /&gt;
&lt;br /&gt;
Lot's of restrictions, huh? Well, most of the above restrictions cause your mapserver to be mad at you.&lt;br /&gt;
&lt;br /&gt;
==== Special Restrictions ====&lt;br /&gt;
Like said above, there are some special restrictions. Here is the short overview:&lt;br /&gt;
* Never use a command name as a variable name.&lt;br /&gt;
* Never use a label, subroutine or function name as a variable name.&lt;br /&gt;
* To be safe, never use the same variable name for different prefixes.&lt;br /&gt;
* Never use the same variable name to store an integer or a string.&lt;br /&gt;
&lt;br /&gt;
A short explanation of this is in order.&lt;br /&gt;
When you name your variable: &amp;quot;mes&amp;quot; (the message command), then this will override any mes command. The server will think that in all those cases, mes is not a command but a variable name. This will result in roughly, uhm, 88120+ errors (no kidding). The problem with this is though, that those errors aren't the real errors. The real error, set mes, 1; for example, isn't even shown.&lt;br /&gt;
The exact same thing occurs when the name of your variable matches the name of a label, function or subroutine.&lt;br /&gt;
When you use the same name, but with a different prefix, your server can start acting weird, and can give unexpected results. This is not always, but it can be common. So, when you are using a variable like $@temp and @temp, it is wise to change one of the two names. Just to be sure.&lt;br /&gt;
If you have two variables named the same, only one has the $-postfix (string), then the mapserver might give some errors. In any way, results will be unexpected and thus weird. So, if you use for example $PartyWon to store the party id and $PartyWon$ to store the party name, then things will go bad. It is best to change one of the two in something else. Perhaps like this: $PartyWon_Id and $PartyWon_Name$.&lt;br /&gt;
&lt;br /&gt;
==== Reserved Names ====&lt;br /&gt;
Some variable names are reserved by default. You should not touch these unless you know what you are doing. Why? Well, changing them, may mean changing things to the invoking player, depending on the kind of reserved name.&lt;br /&gt;
&lt;br /&gt;
===== Constants =====&lt;br /&gt;
One kind of reserved names are constants. These values are loaded upon start-up of the map-server and remain constant during their entire life-time, means, they cannot be changed by any means during run-time. Constants are stored inside '''db/const.txt''' and are all lines, where a constant name is followed by only one number, whether decimal or hexadecimal.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Job_Archer&lt;br /&gt;
 EAJ_SUPER_NOVICE&lt;br /&gt;
 cell_chkreach&lt;br /&gt;
 bUnstripableShield&lt;br /&gt;
&lt;br /&gt;
===== Parameter Constants =====&lt;br /&gt;
These behave almost like variables with side-effect. They are called constants, because they correspond to an constant internal value, which describes their effect. Like-wise the constants, these values are loaded upon start-up of the map-server from '''db/const.txt'''. They are defined by lines with the constant name being followed by two numbers, the latter of them being always being 1.&lt;br /&gt;
&lt;br /&gt;
When used inside scripts, their value is not always constant, but can change depending in context and time. Some of them can be written as well, such as [[Zeny#Scripting|Zeny]].&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
 Zeny&lt;br /&gt;
 BaseLevel&lt;br /&gt;
 Class&lt;br /&gt;
 Weight&lt;br /&gt;
&lt;br /&gt;
==== Word of Advice ====&lt;br /&gt;
When using permanent variables, and even with temporal variables, it is very wise to use some sort of tag. This will make sure that your variable name is unique. For example, if you have a godly equip quest, it is adviced to store the status in a variable named like: GEQ_Status. GEQ_ is the tag, and stands for Godly Equip Quest. This will make it unique compared to other variables. Your variable names will become longer, yes, but it will prevent unknown or unexpected results. Another example of tagging. Let's say you have a capture the flag event, run through NPCs, then prefix your variable names with CTF_. So, some variables might be: $CTF_ScoreTeam1, $CTF_ScoreTeam2, etc. etc.&lt;br /&gt;
Also, please, keep in mind. Variables are case sensitive, just like labels! So, $dummy is not the same as $Dummy. Using both are possible, as they are declare as 2 different variables.&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
Some examples of good and bad names.&lt;br /&gt;
Good:&lt;br /&gt;
 $CTF_Winner$ // Winner of capture the flag&lt;br /&gt;
 $CTF_Loser$ // Loser of capture the flag&lt;br /&gt;
 $GQ_Winner$ // Winner of capture the flag&lt;br /&gt;
 .npcname$ // Name of NPC. Using a permanent NPC variable will save memory space. (Increases CPU though.)&lt;br /&gt;
 #SH_Item1 // Scavenger hunt, item 1.&lt;br /&gt;
 #SH_Item2 // Scavenger hunt, item 2.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
 @Zeny // Zeny is a reserved name.&lt;br /&gt;
 rand // Rand is a command.&lt;br /&gt;
 @h-uy // - is an arithmetic operator, not allowed.&lt;br /&gt;
 $winner and $winner$ // Mixed use of string and integer, bad.&lt;br /&gt;
&lt;br /&gt;
=== Minima and Maxima of Variables ===&lt;br /&gt;
Variables are restricted in the amounts that they can store, as well as how many variables you can have of a certain kind. This section will deal with those restrictions, and even some ways to alter them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Values'''&amp;lt;br&amp;gt;&lt;br /&gt;
*Integer: Can contain a value from -2147483648 to 2147483647 (Signed integer)&lt;br /&gt;
*String: Permanent Global = 255. Permanent Char/Account/Global Account = 254. Others = Unlimited.&lt;br /&gt;
*Array: Can have a maximum of 2147483648 elements (0~2147483647)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;'''Maximum Different Variables'''&amp;lt;br&amp;gt;&lt;br /&gt;
All types are unlimited. Please note, that ''unlimited'' is actually still limited; by available memory and disk capacity (permanent variables).&lt;br /&gt;
&lt;br /&gt;
=== Alive Time ===&lt;br /&gt;
Some variables are never erased, others are cleaned up after certain events. A rule of thumb is, that variables that are only stored in memory are always erased on server restart or crash. Variables which are written to the SQL database or the save folder, survive restarting the mapserver. When it comes to the alive time of a variable, there is no difference between integer, string or array variables. There is only a difference between temporal and permanent.&amp;lt;br&amp;gt;&lt;br /&gt;
The following scedule displays when a variable gets erased from memory and is unrecoverable. Please note, that if a variable is set to 0 (integer) or &amp;quot;&amp;quot; (string), that the variable is unset as well, and in a sense, erased as well.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Prefix&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Alive Time&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Temporary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;text-align:center;&amp;quot; | Permanent&lt;br /&gt;
|-&lt;br /&gt;
| ''none'' || Player || Erased on Server Restart || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| # || Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| ## || Global Account || N/A || Always Survives&lt;br /&gt;
|-&lt;br /&gt;
| . || NPC || Erased on End/Close || Erased on Server Restart&lt;br /&gt;
|-&lt;br /&gt;
| $ || Global || Erased on Server Restart || Always Survives&lt;br /&gt;
|}&lt;br /&gt;
Notes:&lt;br /&gt;
* Server Restart is equal to anything that makes the mapserver stop it's current session, including crashes.&lt;br /&gt;
* Global Account and Account variables do not have a Temporal version.&lt;br /&gt;
* Always Survives can still mean loss of data, if the server crashes/stops after such a variable was altered, but the periodical save process hasn't been executed yet.&lt;br /&gt;
* Erased on End/Close, means that the value of this variable is lost when the script finds the command &amp;quot;end;&amp;quot; or &amp;quot;close;&amp;quot;.&lt;br /&gt;
* Like said above, unset a variable will also erase it from existence.&lt;br /&gt;
&lt;br /&gt;
== Variable Related Errors ==&lt;br /&gt;
=== Str&amp;amp;Int and Int&amp;amp;Str Errors ===&lt;br /&gt;
This specific error happens when you are comparing a String variable with an Integer variable, or when you want to add a String to an Integer variable.&lt;br /&gt;
This is often caused by a simply typo. Just go over your code, and make sure that you didn't make any typos, and it should be fixed.&lt;br /&gt;
&lt;br /&gt;
Examples of what can cause this error:&lt;br /&gt;
 if(.@value == .@name$) // Will error, because .@value is an Integer. .@name$ is a String.&lt;br /&gt;
 set .@value, &amp;quot;Blaat&amp;quot;; // Might error, because .@value is an Integer. &amp;quot;Blaat&amp;quot; is a String.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== No RID attached Error ===&lt;br /&gt;
You get this error, when you want to change a player or account variable, while the player is not attached anymore to the NPC or script.&lt;br /&gt;
A script requires a so called RID to change a value that is connected to a player or an account. You can manually attach an RID to a script, but you need to have an account id to do this. To get an account id, you need to do a getcharid(3,&amp;quot;Player's Name&amp;quot;) and use the result with attachrid. Of course, for this, you will have to get a player name.&lt;br /&gt;
&lt;br /&gt;
If there is no way for you to have an RID attached, then it means that you are using the wrong variables. The following example demonstrates this:&lt;br /&gt;
 OnInit: // Runs when the server starts&lt;br /&gt;
    set StartUpTime, gettimetick(2); // This will give the no RID attached error.&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
The reason this gives the error is that you want to store the current time in a player variable. But on the start up, there is no way for a player to be online, and even if, this script is triggered without invoking a player. The solution to this is to change StartUpTime into .StartUpTime, $StartUpTime or $@StartUpTime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attachrid giving unexpected values ===&lt;br /&gt;
This is a common mistake, but not a real error as detected by the mapserver. This problem can occur when using attachrid. Let's take the following snippet taken from an OnPCKillEvent as example:&lt;br /&gt;
 set Killer$, strcharinfo(0); // Setting Killers Name in Killer$&lt;br /&gt;
 attachrid killedrid; // Attach to the person who got killed.&lt;br /&gt;
 dispbottom &amp;quot;You were killed by &amp;quot;+ Killer$;&lt;br /&gt;
&lt;br /&gt;
Q: What this part is supposed to do? &amp;lt;br&amp;gt;&lt;br /&gt;
A: It should send a message to the person who got killed, saying who killed them.&amp;lt;br&amp;gt;&lt;br /&gt;
Q: What goes wrong here?&amp;lt;br&amp;gt;&lt;br /&gt;
A: The script will not display the name of the killer, or the player's own name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you see the error, you might laugh at this, but it is a very common mistake. The person who scripted this made a faulty assumption. He thought that Killer$ before the attachrid is the same as Killer$ after the attachrid. This is not the case.&lt;br /&gt;
The Killer$ before the attachrid is stored in player 1's character.&lt;br /&gt;
The Killer$ after the attachrid is stored in player 2's character.&lt;br /&gt;
This means that they are not the same.&lt;br /&gt;
&lt;br /&gt;
Q: So what is the solution? &amp;lt;br&amp;gt;&lt;br /&gt;
A: Use the NPC variable -&amp;gt; .@var. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Variable keeps displaying 0 or &amp;quot;&amp;quot; ===&lt;br /&gt;
Also a common error with new scripters. Take the following snippet:&lt;br /&gt;
 set @name$, Patrick;&lt;br /&gt;
A new scripter often types this when he/she wants to put the String &amp;quot;Patrick&amp;quot; inside @name$. However, he/she forgot to put Patrick between a &amp;quot; and a &amp;quot;. So, instead of storing the string &amp;quot;Patrick&amp;quot; inside @name$, the server will look up the value of the variable named Patrick, and stores that value inside @name$. This can result in a 0 being stored in @name$.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Annieruru</name></author>	</entry>

	</feed>