<?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=GmOcean</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=GmOcean"/>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Special:Contributions/GmOcean"/>
		<updated>2026-05-01T10:11:05Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.21.11</generator>

	<entry>
		<id>https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)</id>
		<title>Tips and Tricks (Scripting)</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)"/>
				<updated>2014-11-25T03:34:18Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Dynamic Menu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
This article will go indepth on various ways to script smartly and optimize your scripts. There is no real manual to use this article, besides reading it all, and trying to remember.&lt;br /&gt;
&lt;br /&gt;
= Tips =&lt;br /&gt;
== If-Statements ==&lt;br /&gt;
There are several ways to make your if-statements function better and faster, and make them more readable at the same time. &lt;br /&gt;
=== Use the switch statement: ===&lt;br /&gt;
Let's say we had the following code:&lt;br /&gt;
 if(getarg(1) == 0) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 1) cutin &amp;quot;kafra_05&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 2) cutin &amp;quot;kafra_04&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 3) cutin &amp;quot;kafra_03&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 4) cutin &amp;quot;kafra_02&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 5) cutin &amp;quot;kafra_01&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 6) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 7) cutin &amp;quot;kafra_08&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 8) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
We could replace that entire block by the switch command. This commands looks up the value that is provided, and jumps to the according case. Don't worry, if it isn't clear yet, let's go to the replacement code first:&lt;br /&gt;
 switch(getarg(1)){&lt;br /&gt;
    case 1: cutin &amp;quot;kafra_05&amp;quot;,2; break;&lt;br /&gt;
    case 2: cutin &amp;quot;kafra_04&amp;quot;,2; break;&lt;br /&gt;
    case 3: cutin &amp;quot;kafra_03&amp;quot;,2; break;&lt;br /&gt;
    case 4: cutin &amp;quot;kafra_02&amp;quot;,2; break;&lt;br /&gt;
    case 5: cutin &amp;quot;kafra_01&amp;quot;,2; break;&lt;br /&gt;
    case 6: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    case 7: cutin &amp;quot;kafra_08&amp;quot;,2; break;&lt;br /&gt;
    case 8: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    default: cutin &amp;quot;kafra_06&amp;quot;,2; break;&lt;br /&gt;
 }&lt;br /&gt;
As you can see, each if-line has been replaced by a case-line. The command switch looks up the value of getarg(1). If this would be 5, then it would jump to &amp;quot;case 5&amp;quot;, do the cutin, and then break. Break makes it jump to after the right curly bracket ('}').&amp;lt;br&amp;gt;&lt;br /&gt;
If it finds getarg(1) to be 8, it jumps to &amp;quot;case 8&amp;quot;, and does the same there. And the best part of the switch statement might be the default one. It kind of replaces the following really unoptimized line:&lt;br /&gt;
 if(getarg(1) != 1 &amp;amp;&amp;amp; getarg(1) != 2 &amp;amp;&amp;amp; getarg(1) != 3 .... &amp;amp;&amp;amp; getarg(1) != 8) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
In English, this means, if the value of getarg(1) does not have an accompanied case, it will jump to the default label.&lt;br /&gt;
&lt;br /&gt;
=== Use the brackets if you're executing more than 1 statement in 'if' statements. ===&lt;br /&gt;
If you have a piece of code, that needs to check for a condition, and do multiple things, then you can make it so, that you only have to use one if-line, instead of 4, 5, 1000 or something else. To do this, you will have to use the curly brackets. They tell the script engine that everything between the curly brackets belongs to the command before the left curly bracket. For example, take the following unoptimized code:&lt;br /&gt;
 if(@var == 1) mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
This can be replaced by the following:&lt;br /&gt;
 if(@var == 1){&lt;br /&gt;
    mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
What is so optimized about this? Well, in this case, you can easily see that each if-statement is completely the same, but keep in mind, that the script engine needs to do each if-statement each time it sees one. So, in the top part, it needs to do 5 checks. In the replacement, it only has to do one single check. Based on that check, it either executes the code between the { and } or skips to right after the }.&amp;lt;br&amp;gt;&lt;br /&gt;
Also, from a writer's point of view, this is exactly the same for you. You see in one glance that the entire part between the curly brackets belongs to the if(@var == 1) statement, so you do not have to check each if-statement individually to see that they are all the same.&lt;br /&gt;
&lt;br /&gt;
=== Use if...else if you're not expecting more than 2 values. ===&lt;br /&gt;
When you evaluate if a variable meets a certain condition, and you need to do something when that condition is true, and something differently when the condition is false, then you really want to use the if...else combination. This does not only make it more clear for yourself, but also faster for the script engine, because it only needs to evaluate one if-statement instead of two. Take this unoptimized piece of code for example:&lt;br /&gt;
 @win = rand(2); // Generates 1 or 0&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 if(@win == 0){&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This can be replaced by the following piece of code:&lt;br /&gt;
 @win = rand(2);&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 } else {&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Variable Use ==&lt;br /&gt;
A lot of people do not pay any attention when it comes to using variables. They randomly choose a type of variable and use it, or even use a variable when it isn't needed. You must keep in mind though, that Hercules has a limited amount of variables it can use, for (global) account and permanent player variables. Therefor, you want to minimize the use of it. This section will contain some examples of how to minimize that use.&lt;br /&gt;
&lt;br /&gt;
=== Use binary methods to store large number of flags (1 and 0). ===&lt;br /&gt;
What a lot of people do not know, is that a single variable can store up to 32 different flags, or values. And with this, I do not mean the use of an array, but really a single variable. This comes in very handy when you are only using a 1 or 0, for example: &amp;quot;@win = 1;&amp;quot;. In a normal situation, you can only win or lose, so it can only be a 1 or 0.&amp;lt;br&amp;gt;&lt;br /&gt;
But, let's see how this translates into normal code:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bad code -&lt;br /&gt;
 flag1 = 1;&lt;br /&gt;
 flag2 = 1;&lt;br /&gt;
 flag3 = 0;&lt;br /&gt;
 flag4 = 1;&lt;br /&gt;
 flag5 = 0;&lt;br /&gt;
 if (flag1) mes &amp;quot;flag1 is checked&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Good code -&lt;br /&gt;
 flags = 26; // (equivalent to: 16|8|0|2|0 [binary 11010])&lt;br /&gt;
 if (flags&amp;amp;16) mes &amp;quot;flag1 is checked&amp;quot;; // 11010 &amp;amp; 10000 &amp;gt; 0 (10000)&lt;br /&gt;
As you can see, only one variable used instead of 5, and it contains all the values of those five variables. (In this case, it is also a lot shorter, but that doesn't have to be the case.)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&amp;lt;br&amp;gt;&lt;br /&gt;
Using binary methods to store variables require that you have at least some knowledge on how to use binary values. This is what you may call advanced scripting, so it is quite normal if you do not understand it right away.&lt;br /&gt;
&lt;br /&gt;
== Infinite For Loops ==&lt;br /&gt;
By nature, the Athena Scripting Engine has a limit on the amount of loops that can go through in a specific amount of time, thus halting the script to eliminate the ever dreadful 'Infinite Loop'. However, there is a way around this:&lt;br /&gt;
&lt;br /&gt;
This script below, would actually halt around 682 give or take a few loops, due to preventions on infinite loops. &lt;br /&gt;
 for (.@a = 0; .@a &amp;lt; 10000; .@a++) {&lt;br /&gt;
   debugmes .@a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This method used below slows the processes down by a millisecond. This works because each time 'sleep' or 'sleep2' is used, the script's gotocount is reset.&lt;br /&gt;
 // Supposing you have 10,000 entries... let .@b = Total Entries, .@a is your splicing filter every 500 entries&lt;br /&gt;
 while (.@b &amp;lt; 10000) {&lt;br /&gt;
   for (.@a = .@b; .@a &amp;lt; (.@b + 500); .@a++) {&lt;br /&gt;
     debugmes .@a;&lt;br /&gt;
   }&lt;br /&gt;
   .@b = .@a;&lt;br /&gt;
   sleep 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
See Also: [[freeloop]]&lt;br /&gt;
&lt;br /&gt;
== While (!getmapxy()) ==&lt;br /&gt;
The standard getmapxy() returns 0 if the player is found, and 1 if the player is offline.&lt;br /&gt;
By using the !getmapxy() feature, while the value does NOT have a value aka it's 0, loop (player still online and active)&lt;br /&gt;
This can also be written while (getmapxy() == 0) { }&lt;br /&gt;
&lt;br /&gt;
 while ( !getmapxy(.@map$, .@x, .@y, 0 ) ) {&lt;br /&gt;
   if ( .@map$ != &amp;quot;prontera&amp;quot; ) { // check the player has warped to other map or not&lt;br /&gt;
     dispbottom &amp;quot;gone&amp;quot;; &lt;br /&gt;
     end; &lt;br /&gt;
   }&lt;br /&gt;
   dispbottom .@x +&amp;quot; &amp;quot;+ .@y; // report the position every N second&lt;br /&gt;
   sleep2 1000; // pause the script&lt;br /&gt;
 }&lt;br /&gt;
 end; // when the player logout, the loops break&lt;br /&gt;
&lt;br /&gt;
== Dynamic Menu ==&lt;br /&gt;
These menu's help in many different ways. Perhaps you have an unknown list of items and you want the user to select one. How do you know which item it was? What if you have a menu based on certain criteria? This menu can then change based on the information per player. This is where a dynamic menu can come into play.&lt;br /&gt;
&lt;br /&gt;
The basis of a Dynamic menu is as follows: Knowing what option a player chooses, even though the option chosen may be random.&lt;br /&gt;
&lt;br /&gt;
This is easily done with a small example of a simple (Item Required Warper)&lt;br /&gt;
&lt;br /&gt;
 prontera,158,174,4	script	MyDynWarper	4_M_ORIENT01,{&lt;br /&gt;
 &lt;br /&gt;
 // Take Locations&lt;br /&gt;
 setarray .@maps$[0],&amp;quot;Prontera&amp;quot;,&amp;quot;Morocc&amp;quot;,&amp;quot;Geffen&amp;quot;,&amp;quot;Izlude&amp;quot;;&lt;br /&gt;
 setarray .@mapx[0],158,100,200,300;&lt;br /&gt;
 setarray .@mapy[0],174,100,200,300;&lt;br /&gt;
 &lt;br /&gt;
 // Set Items Needed&lt;br /&gt;
 setarray .@items,501,502,503,504; &lt;br /&gt;
 &lt;br /&gt;
 // Generate Menu&lt;br /&gt;
 for (.@a = 0; .@a &amp;lt; getarraysize(.@maps$); .@a++) {&lt;br /&gt;
   if (countitem(.@items[.@a])) {&lt;br /&gt;
     .@menu_maps$[getarraysize(.@menu_maps$)] = .@maps$[.@a];&lt;br /&gt;
     .@menu_index[getarraysize(.@menu_index)] = .@a;&lt;br /&gt;
   }&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 // Generate the Menu String&lt;br /&gt;
 .@menu$ = .@menu_maps$[0];&lt;br /&gt;
 for (.@a = 1; .@a &amp;lt; getarraysize(.@menu_maps$); .@a++) {&lt;br /&gt;
   .@menu$ = .@menu$ + &amp;quot;:&amp;quot; + .@menu_maps$[.@a];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // Query Selection&lt;br /&gt;
 .@a = select(.@menu$) - 1; &lt;br /&gt;
 &lt;br /&gt;
 warp .@menu_maps$[.@a], .@mapx[.@a], .@mapy[.@a];&lt;br /&gt;
 end;&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Compact IF Statement ==&lt;br /&gt;
While, it looks messy, it can help shorten and quicken simplifed IF/ELSE statements. Example below includes a before and after.&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
 if ( team == 1 )&lt;br /&gt;
     mes &amp;quot;You are team Red&amp;quot;;&lt;br /&gt;
 else&lt;br /&gt;
     mes &amp;quot;You are team Blue&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
 mes &amp;quot;You are team &amp;quot;+( ( team == 1 )?&amp;quot;Red&amp;quot;:&amp;quot;Blue&amp;quot; );&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)</id>
		<title>Tips and Tricks (Scripting)</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)"/>
				<updated>2014-11-25T03:31:29Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Infinite For Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
This article will go indepth on various ways to script smartly and optimize your scripts. There is no real manual to use this article, besides reading it all, and trying to remember.&lt;br /&gt;
&lt;br /&gt;
= Tips =&lt;br /&gt;
== If-Statements ==&lt;br /&gt;
There are several ways to make your if-statements function better and faster, and make them more readable at the same time. &lt;br /&gt;
=== Use the switch statement: ===&lt;br /&gt;
Let's say we had the following code:&lt;br /&gt;
 if(getarg(1) == 0) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 1) cutin &amp;quot;kafra_05&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 2) cutin &amp;quot;kafra_04&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 3) cutin &amp;quot;kafra_03&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 4) cutin &amp;quot;kafra_02&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 5) cutin &amp;quot;kafra_01&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 6) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 7) cutin &amp;quot;kafra_08&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 8) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
We could replace that entire block by the switch command. This commands looks up the value that is provided, and jumps to the according case. Don't worry, if it isn't clear yet, let's go to the replacement code first:&lt;br /&gt;
 switch(getarg(1)){&lt;br /&gt;
    case 1: cutin &amp;quot;kafra_05&amp;quot;,2; break;&lt;br /&gt;
    case 2: cutin &amp;quot;kafra_04&amp;quot;,2; break;&lt;br /&gt;
    case 3: cutin &amp;quot;kafra_03&amp;quot;,2; break;&lt;br /&gt;
    case 4: cutin &amp;quot;kafra_02&amp;quot;,2; break;&lt;br /&gt;
    case 5: cutin &amp;quot;kafra_01&amp;quot;,2; break;&lt;br /&gt;
    case 6: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    case 7: cutin &amp;quot;kafra_08&amp;quot;,2; break;&lt;br /&gt;
    case 8: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    default: cutin &amp;quot;kafra_06&amp;quot;,2; break;&lt;br /&gt;
 }&lt;br /&gt;
As you can see, each if-line has been replaced by a case-line. The command switch looks up the value of getarg(1). If this would be 5, then it would jump to &amp;quot;case 5&amp;quot;, do the cutin, and then break. Break makes it jump to after the right curly bracket ('}').&amp;lt;br&amp;gt;&lt;br /&gt;
If it finds getarg(1) to be 8, it jumps to &amp;quot;case 8&amp;quot;, and does the same there. And the best part of the switch statement might be the default one. It kind of replaces the following really unoptimized line:&lt;br /&gt;
 if(getarg(1) != 1 &amp;amp;&amp;amp; getarg(1) != 2 &amp;amp;&amp;amp; getarg(1) != 3 .... &amp;amp;&amp;amp; getarg(1) != 8) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
In English, this means, if the value of getarg(1) does not have an accompanied case, it will jump to the default label.&lt;br /&gt;
&lt;br /&gt;
=== Use the brackets if you're executing more than 1 statement in 'if' statements. ===&lt;br /&gt;
If you have a piece of code, that needs to check for a condition, and do multiple things, then you can make it so, that you only have to use one if-line, instead of 4, 5, 1000 or something else. To do this, you will have to use the curly brackets. They tell the script engine that everything between the curly brackets belongs to the command before the left curly bracket. For example, take the following unoptimized code:&lt;br /&gt;
 if(@var == 1) mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
This can be replaced by the following:&lt;br /&gt;
 if(@var == 1){&lt;br /&gt;
    mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
What is so optimized about this? Well, in this case, you can easily see that each if-statement is completely the same, but keep in mind, that the script engine needs to do each if-statement each time it sees one. So, in the top part, it needs to do 5 checks. In the replacement, it only has to do one single check. Based on that check, it either executes the code between the { and } or skips to right after the }.&amp;lt;br&amp;gt;&lt;br /&gt;
Also, from a writer's point of view, this is exactly the same for you. You see in one glance that the entire part between the curly brackets belongs to the if(@var == 1) statement, so you do not have to check each if-statement individually to see that they are all the same.&lt;br /&gt;
&lt;br /&gt;
=== Use if...else if you're not expecting more than 2 values. ===&lt;br /&gt;
When you evaluate if a variable meets a certain condition, and you need to do something when that condition is true, and something differently when the condition is false, then you really want to use the if...else combination. This does not only make it more clear for yourself, but also faster for the script engine, because it only needs to evaluate one if-statement instead of two. Take this unoptimized piece of code for example:&lt;br /&gt;
 @win = rand(2); // Generates 1 or 0&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 if(@win == 0){&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This can be replaced by the following piece of code:&lt;br /&gt;
 @win = rand(2);&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 } else {&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Variable Use ==&lt;br /&gt;
A lot of people do not pay any attention when it comes to using variables. They randomly choose a type of variable and use it, or even use a variable when it isn't needed. You must keep in mind though, that Hercules has a limited amount of variables it can use, for (global) account and permanent player variables. Therefor, you want to minimize the use of it. This section will contain some examples of how to minimize that use.&lt;br /&gt;
&lt;br /&gt;
=== Use binary methods to store large number of flags (1 and 0). ===&lt;br /&gt;
What a lot of people do not know, is that a single variable can store up to 32 different flags, or values. And with this, I do not mean the use of an array, but really a single variable. This comes in very handy when you are only using a 1 or 0, for example: &amp;quot;@win = 1;&amp;quot;. In a normal situation, you can only win or lose, so it can only be a 1 or 0.&amp;lt;br&amp;gt;&lt;br /&gt;
But, let's see how this translates into normal code:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bad code -&lt;br /&gt;
 flag1 = 1;&lt;br /&gt;
 flag2 = 1;&lt;br /&gt;
 flag3 = 0;&lt;br /&gt;
 flag4 = 1;&lt;br /&gt;
 flag5 = 0;&lt;br /&gt;
 if (flag1) mes &amp;quot;flag1 is checked&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Good code -&lt;br /&gt;
 flags = 26; // (equivalent to: 16|8|0|2|0 [binary 11010])&lt;br /&gt;
 if (flags&amp;amp;16) mes &amp;quot;flag1 is checked&amp;quot;; // 11010 &amp;amp; 10000 &amp;gt; 0 (10000)&lt;br /&gt;
As you can see, only one variable used instead of 5, and it contains all the values of those five variables. (In this case, it is also a lot shorter, but that doesn't have to be the case.)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&amp;lt;br&amp;gt;&lt;br /&gt;
Using binary methods to store variables require that you have at least some knowledge on how to use binary values. This is what you may call advanced scripting, so it is quite normal if you do not understand it right away.&lt;br /&gt;
&lt;br /&gt;
== Infinite For Loops ==&lt;br /&gt;
By nature, the Athena Scripting Engine has a limit on the amount of loops that can go through in a specific amount of time, thus halting the script to eliminate the ever dreadful 'Infinite Loop'. However, there is a way around this:&lt;br /&gt;
&lt;br /&gt;
This script below, would actually halt around 682 give or take a few loops, due to preventions on infinite loops. &lt;br /&gt;
 for (.@a = 0; .@a &amp;lt; 10000; .@a++) {&lt;br /&gt;
   debugmes .@a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This method used below slows the processes down by a millisecond. This works because each time 'sleep' or 'sleep2' is used, the script's gotocount is reset.&lt;br /&gt;
 // Supposing you have 10,000 entries... let .@b = Total Entries, .@a is your splicing filter every 500 entries&lt;br /&gt;
 while (.@b &amp;lt; 10000) {&lt;br /&gt;
   for (.@a = .@b; .@a &amp;lt; (.@b + 500); .@a++) {&lt;br /&gt;
     debugmes .@a;&lt;br /&gt;
   }&lt;br /&gt;
   .@b = .@a;&lt;br /&gt;
   sleep 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
See Also: [[freeloop]]&lt;br /&gt;
&lt;br /&gt;
== While (!getmapxy()) ==&lt;br /&gt;
The standard getmapxy() returns 0 if the player is found, and 1 if the player is offline.&lt;br /&gt;
By using the !getmapxy() feature, while the value does NOT have a value aka it's 0, loop (player still online and active)&lt;br /&gt;
This can also be written while (getmapxy() == 0) { }&lt;br /&gt;
&lt;br /&gt;
 while ( !getmapxy(.@map$, .@x, .@y, 0 ) ) {&lt;br /&gt;
   if ( .@map$ != &amp;quot;prontera&amp;quot; ) { // check the player has warped to other map or not&lt;br /&gt;
     dispbottom &amp;quot;gone&amp;quot;; &lt;br /&gt;
     end; &lt;br /&gt;
   }&lt;br /&gt;
   dispbottom .@x +&amp;quot; &amp;quot;+ .@y; // report the position every N second&lt;br /&gt;
   sleep2 1000; // pause the script&lt;br /&gt;
 }&lt;br /&gt;
 end; // when the player logout, the loops break&lt;br /&gt;
&lt;br /&gt;
== Dynamic Menu ==&lt;br /&gt;
These menu's help in many different ways. Perhaps you have an unknown list of items and you want the user to select one. How do you know which item it was? What if you have a menu based on certain criteria? This menu can then change based on the information per player. This is where a dynamic menu can come into play.&lt;br /&gt;
&lt;br /&gt;
The basis of a Dynamic menu is as follows: Knowing what option a player chooses, even though the option chosen may be random.&lt;br /&gt;
&lt;br /&gt;
This is easily done with a small example of a simple (Item Required Warper)&lt;br /&gt;
&lt;br /&gt;
 prontera,158,174,4	script	MyDynWarper	88,{&lt;br /&gt;
 &lt;br /&gt;
 // Take Locations&lt;br /&gt;
 setarray .@maps$[0],&amp;quot;Prontera&amp;quot;,&amp;quot;Morocc&amp;quot;,&amp;quot;Geffen&amp;quot;,&amp;quot;Izlude&amp;quot;;&lt;br /&gt;
 setarray .@mapx[0],158,100,200,300;&lt;br /&gt;
 setarray .@mapy[0],174,100,200,300;&lt;br /&gt;
 &lt;br /&gt;
 // Set Items Needed&lt;br /&gt;
 setarray .@items,501,502,503,504; &lt;br /&gt;
 &lt;br /&gt;
 // Generate Menu&lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; getarraysize(.@maps$); set .@a, .@a + 1) {&lt;br /&gt;
   if (countitem(.@items[.@a])) {&lt;br /&gt;
     set .@menu_maps$[getarraysize(.@menu_maps$)], .@maps$[.@a];&lt;br /&gt;
     set .@menu_index[getarraysize(.@menu_index)], .@a;&lt;br /&gt;
   }&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 // Generate the Menu String&lt;br /&gt;
 set .@menu$, .@menu_maps$[0];&lt;br /&gt;
 for (set .@a, 1; .@a &amp;lt; getarraysize(.@menu_maps$); set .@a, .@a + 1) {&lt;br /&gt;
   set .@menu$, .@menu$ + &amp;quot;:&amp;quot; + .@menu_maps$[.@a];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // Query Selection&lt;br /&gt;
 set .@a, select(.@menu$) - 1; &lt;br /&gt;
 &lt;br /&gt;
 warp .@menu_maps$[.@a], .@mapx[.@a], .@mapy[.@a];&lt;br /&gt;
 end;&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Compact IF Statement ==&lt;br /&gt;
While, it looks messy, it can help shorten and quicken simplifed IF/ELSE statements. Example below includes a before and after.&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
 if ( team == 1 )&lt;br /&gt;
     mes &amp;quot;You are team Red&amp;quot;;&lt;br /&gt;
 else&lt;br /&gt;
     mes &amp;quot;You are team Blue&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
 mes &amp;quot;You are team &amp;quot;+( ( team == 1 )?&amp;quot;Red&amp;quot;:&amp;quot;Blue&amp;quot; );&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)</id>
		<title>Tips and Tricks (Scripting)</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)"/>
				<updated>2014-11-25T03:30:12Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Use binary methods to store large number of flags (1 and 0). */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
This article will go indepth on various ways to script smartly and optimize your scripts. There is no real manual to use this article, besides reading it all, and trying to remember.&lt;br /&gt;
&lt;br /&gt;
= Tips =&lt;br /&gt;
== If-Statements ==&lt;br /&gt;
There are several ways to make your if-statements function better and faster, and make them more readable at the same time. &lt;br /&gt;
=== Use the switch statement: ===&lt;br /&gt;
Let's say we had the following code:&lt;br /&gt;
 if(getarg(1) == 0) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 1) cutin &amp;quot;kafra_05&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 2) cutin &amp;quot;kafra_04&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 3) cutin &amp;quot;kafra_03&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 4) cutin &amp;quot;kafra_02&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 5) cutin &amp;quot;kafra_01&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 6) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 7) cutin &amp;quot;kafra_08&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 8) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
We could replace that entire block by the switch command. This commands looks up the value that is provided, and jumps to the according case. Don't worry, if it isn't clear yet, let's go to the replacement code first:&lt;br /&gt;
 switch(getarg(1)){&lt;br /&gt;
    case 1: cutin &amp;quot;kafra_05&amp;quot;,2; break;&lt;br /&gt;
    case 2: cutin &amp;quot;kafra_04&amp;quot;,2; break;&lt;br /&gt;
    case 3: cutin &amp;quot;kafra_03&amp;quot;,2; break;&lt;br /&gt;
    case 4: cutin &amp;quot;kafra_02&amp;quot;,2; break;&lt;br /&gt;
    case 5: cutin &amp;quot;kafra_01&amp;quot;,2; break;&lt;br /&gt;
    case 6: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    case 7: cutin &amp;quot;kafra_08&amp;quot;,2; break;&lt;br /&gt;
    case 8: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    default: cutin &amp;quot;kafra_06&amp;quot;,2; break;&lt;br /&gt;
 }&lt;br /&gt;
As you can see, each if-line has been replaced by a case-line. The command switch looks up the value of getarg(1). If this would be 5, then it would jump to &amp;quot;case 5&amp;quot;, do the cutin, and then break. Break makes it jump to after the right curly bracket ('}').&amp;lt;br&amp;gt;&lt;br /&gt;
If it finds getarg(1) to be 8, it jumps to &amp;quot;case 8&amp;quot;, and does the same there. And the best part of the switch statement might be the default one. It kind of replaces the following really unoptimized line:&lt;br /&gt;
 if(getarg(1) != 1 &amp;amp;&amp;amp; getarg(1) != 2 &amp;amp;&amp;amp; getarg(1) != 3 .... &amp;amp;&amp;amp; getarg(1) != 8) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
In English, this means, if the value of getarg(1) does not have an accompanied case, it will jump to the default label.&lt;br /&gt;
&lt;br /&gt;
=== Use the brackets if you're executing more than 1 statement in 'if' statements. ===&lt;br /&gt;
If you have a piece of code, that needs to check for a condition, and do multiple things, then you can make it so, that you only have to use one if-line, instead of 4, 5, 1000 or something else. To do this, you will have to use the curly brackets. They tell the script engine that everything between the curly brackets belongs to the command before the left curly bracket. For example, take the following unoptimized code:&lt;br /&gt;
 if(@var == 1) mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
This can be replaced by the following:&lt;br /&gt;
 if(@var == 1){&lt;br /&gt;
    mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
What is so optimized about this? Well, in this case, you can easily see that each if-statement is completely the same, but keep in mind, that the script engine needs to do each if-statement each time it sees one. So, in the top part, it needs to do 5 checks. In the replacement, it only has to do one single check. Based on that check, it either executes the code between the { and } or skips to right after the }.&amp;lt;br&amp;gt;&lt;br /&gt;
Also, from a writer's point of view, this is exactly the same for you. You see in one glance that the entire part between the curly brackets belongs to the if(@var == 1) statement, so you do not have to check each if-statement individually to see that they are all the same.&lt;br /&gt;
&lt;br /&gt;
=== Use if...else if you're not expecting more than 2 values. ===&lt;br /&gt;
When you evaluate if a variable meets a certain condition, and you need to do something when that condition is true, and something differently when the condition is false, then you really want to use the if...else combination. This does not only make it more clear for yourself, but also faster for the script engine, because it only needs to evaluate one if-statement instead of two. Take this unoptimized piece of code for example:&lt;br /&gt;
 @win = rand(2); // Generates 1 or 0&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 if(@win == 0){&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This can be replaced by the following piece of code:&lt;br /&gt;
 @win = rand(2);&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 } else {&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Variable Use ==&lt;br /&gt;
A lot of people do not pay any attention when it comes to using variables. They randomly choose a type of variable and use it, or even use a variable when it isn't needed. You must keep in mind though, that Hercules has a limited amount of variables it can use, for (global) account and permanent player variables. Therefor, you want to minimize the use of it. This section will contain some examples of how to minimize that use.&lt;br /&gt;
&lt;br /&gt;
=== Use binary methods to store large number of flags (1 and 0). ===&lt;br /&gt;
What a lot of people do not know, is that a single variable can store up to 32 different flags, or values. And with this, I do not mean the use of an array, but really a single variable. This comes in very handy when you are only using a 1 or 0, for example: &amp;quot;@win = 1;&amp;quot;. In a normal situation, you can only win or lose, so it can only be a 1 or 0.&amp;lt;br&amp;gt;&lt;br /&gt;
But, let's see how this translates into normal code:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bad code -&lt;br /&gt;
 flag1 = 1;&lt;br /&gt;
 flag2 = 1;&lt;br /&gt;
 flag3 = 0;&lt;br /&gt;
 flag4 = 1;&lt;br /&gt;
 flag5 = 0;&lt;br /&gt;
 if (flag1) mes &amp;quot;flag1 is checked&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Good code -&lt;br /&gt;
 flags = 26; // (equivalent to: 16|8|0|2|0 [binary 11010])&lt;br /&gt;
 if (flags&amp;amp;16) mes &amp;quot;flag1 is checked&amp;quot;; // 11010 &amp;amp; 10000 &amp;gt; 0 (10000)&lt;br /&gt;
As you can see, only one variable used instead of 5, and it contains all the values of those five variables. (In this case, it is also a lot shorter, but that doesn't have to be the case.)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&amp;lt;br&amp;gt;&lt;br /&gt;
Using binary methods to store variables require that you have at least some knowledge on how to use binary values. This is what you may call advanced scripting, so it is quite normal if you do not understand it right away.&lt;br /&gt;
&lt;br /&gt;
== Infinite For Loops ==&lt;br /&gt;
By nature, the Athena Scripting Engine has a limit on the amount of loops that can go through in a specific amount of time, thus halting the script to eliminate the ever dreadful 'Infinite Loop'. However, there is a way around this:&lt;br /&gt;
&lt;br /&gt;
This script below, would actually halt around 682 give or take a few loops, due to preventions on infinite loops. &lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; 10000; set .@a, .@a + 1) {&lt;br /&gt;
   debugmes .@a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This method used below slows the processes down by a millisecond. This works because each time 'sleep' or 'sleep2' is used, the script's gotocount is reset.&lt;br /&gt;
 // Supposing you have 10,000 entries... let .@b = Total Entries, .@a is your splicing filter every 500 entries&lt;br /&gt;
 while (.@b &amp;lt; 10000) {&lt;br /&gt;
   for (set .@a, .@b; .@a &amp;lt; .@b + 500; set .@a, .@a + 1) {&lt;br /&gt;
     debugmes .@a;&lt;br /&gt;
   }&lt;br /&gt;
   set .@b, .@a;&lt;br /&gt;
   sleep 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
See Also: [[freeloop]]&lt;br /&gt;
&lt;br /&gt;
== While (!getmapxy()) ==&lt;br /&gt;
The standard getmapxy() returns 0 if the player is found, and 1 if the player is offline.&lt;br /&gt;
By using the !getmapxy() feature, while the value does NOT have a value aka it's 0, loop (player still online and active)&lt;br /&gt;
This can also be written while (getmapxy() == 0) { }&lt;br /&gt;
&lt;br /&gt;
 while ( !getmapxy(.@map$, .@x, .@y, 0 ) ) {&lt;br /&gt;
   if ( .@map$ != &amp;quot;prontera&amp;quot; ) { // check the player has warped to other map or not&lt;br /&gt;
     dispbottom &amp;quot;gone&amp;quot;; &lt;br /&gt;
     end; &lt;br /&gt;
   }&lt;br /&gt;
   dispbottom .@x +&amp;quot; &amp;quot;+ .@y; // report the position every N second&lt;br /&gt;
   sleep2 1000; // pause the script&lt;br /&gt;
 }&lt;br /&gt;
 end; // when the player logout, the loops break&lt;br /&gt;
&lt;br /&gt;
== Dynamic Menu ==&lt;br /&gt;
These menu's help in many different ways. Perhaps you have an unknown list of items and you want the user to select one. How do you know which item it was? What if you have a menu based on certain criteria? This menu can then change based on the information per player. This is where a dynamic menu can come into play.&lt;br /&gt;
&lt;br /&gt;
The basis of a Dynamic menu is as follows: Knowing what option a player chooses, even though the option chosen may be random.&lt;br /&gt;
&lt;br /&gt;
This is easily done with a small example of a simple (Item Required Warper)&lt;br /&gt;
&lt;br /&gt;
 prontera,158,174,4	script	MyDynWarper	88,{&lt;br /&gt;
 &lt;br /&gt;
 // Take Locations&lt;br /&gt;
 setarray .@maps$[0],&amp;quot;Prontera&amp;quot;,&amp;quot;Morocc&amp;quot;,&amp;quot;Geffen&amp;quot;,&amp;quot;Izlude&amp;quot;;&lt;br /&gt;
 setarray .@mapx[0],158,100,200,300;&lt;br /&gt;
 setarray .@mapy[0],174,100,200,300;&lt;br /&gt;
 &lt;br /&gt;
 // Set Items Needed&lt;br /&gt;
 setarray .@items,501,502,503,504; &lt;br /&gt;
 &lt;br /&gt;
 // Generate Menu&lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; getarraysize(.@maps$); set .@a, .@a + 1) {&lt;br /&gt;
   if (countitem(.@items[.@a])) {&lt;br /&gt;
     set .@menu_maps$[getarraysize(.@menu_maps$)], .@maps$[.@a];&lt;br /&gt;
     set .@menu_index[getarraysize(.@menu_index)], .@a;&lt;br /&gt;
   }&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 // Generate the Menu String&lt;br /&gt;
 set .@menu$, .@menu_maps$[0];&lt;br /&gt;
 for (set .@a, 1; .@a &amp;lt; getarraysize(.@menu_maps$); set .@a, .@a + 1) {&lt;br /&gt;
   set .@menu$, .@menu$ + &amp;quot;:&amp;quot; + .@menu_maps$[.@a];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // Query Selection&lt;br /&gt;
 set .@a, select(.@menu$) - 1; &lt;br /&gt;
 &lt;br /&gt;
 warp .@menu_maps$[.@a], .@mapx[.@a], .@mapy[.@a];&lt;br /&gt;
 end;&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Compact IF Statement ==&lt;br /&gt;
While, it looks messy, it can help shorten and quicken simplifed IF/ELSE statements. Example below includes a before and after.&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
 if ( team == 1 )&lt;br /&gt;
     mes &amp;quot;You are team Red&amp;quot;;&lt;br /&gt;
 else&lt;br /&gt;
     mes &amp;quot;You are team Blue&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
 mes &amp;quot;You are team &amp;quot;+( ( team == 1 )?&amp;quot;Red&amp;quot;:&amp;quot;Blue&amp;quot; );&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)</id>
		<title>Tips and Tricks (Scripting)</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)"/>
				<updated>2014-11-25T03:28:18Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Use if...else if you're not expecting more than 2 values. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
This article will go indepth on various ways to script smartly and optimize your scripts. There is no real manual to use this article, besides reading it all, and trying to remember.&lt;br /&gt;
&lt;br /&gt;
= Tips =&lt;br /&gt;
== If-Statements ==&lt;br /&gt;
There are several ways to make your if-statements function better and faster, and make them more readable at the same time. &lt;br /&gt;
=== Use the switch statement: ===&lt;br /&gt;
Let's say we had the following code:&lt;br /&gt;
 if(getarg(1) == 0) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 1) cutin &amp;quot;kafra_05&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 2) cutin &amp;quot;kafra_04&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 3) cutin &amp;quot;kafra_03&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 4) cutin &amp;quot;kafra_02&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 5) cutin &amp;quot;kafra_01&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 6) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 7) cutin &amp;quot;kafra_08&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 8) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
We could replace that entire block by the switch command. This commands looks up the value that is provided, and jumps to the according case. Don't worry, if it isn't clear yet, let's go to the replacement code first:&lt;br /&gt;
 switch(getarg(1)){&lt;br /&gt;
    case 1: cutin &amp;quot;kafra_05&amp;quot;,2; break;&lt;br /&gt;
    case 2: cutin &amp;quot;kafra_04&amp;quot;,2; break;&lt;br /&gt;
    case 3: cutin &amp;quot;kafra_03&amp;quot;,2; break;&lt;br /&gt;
    case 4: cutin &amp;quot;kafra_02&amp;quot;,2; break;&lt;br /&gt;
    case 5: cutin &amp;quot;kafra_01&amp;quot;,2; break;&lt;br /&gt;
    case 6: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    case 7: cutin &amp;quot;kafra_08&amp;quot;,2; break;&lt;br /&gt;
    case 8: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    default: cutin &amp;quot;kafra_06&amp;quot;,2; break;&lt;br /&gt;
 }&lt;br /&gt;
As you can see, each if-line has been replaced by a case-line. The command switch looks up the value of getarg(1). If this would be 5, then it would jump to &amp;quot;case 5&amp;quot;, do the cutin, and then break. Break makes it jump to after the right curly bracket ('}').&amp;lt;br&amp;gt;&lt;br /&gt;
If it finds getarg(1) to be 8, it jumps to &amp;quot;case 8&amp;quot;, and does the same there. And the best part of the switch statement might be the default one. It kind of replaces the following really unoptimized line:&lt;br /&gt;
 if(getarg(1) != 1 &amp;amp;&amp;amp; getarg(1) != 2 &amp;amp;&amp;amp; getarg(1) != 3 .... &amp;amp;&amp;amp; getarg(1) != 8) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
In English, this means, if the value of getarg(1) does not have an accompanied case, it will jump to the default label.&lt;br /&gt;
&lt;br /&gt;
=== Use the brackets if you're executing more than 1 statement in 'if' statements. ===&lt;br /&gt;
If you have a piece of code, that needs to check for a condition, and do multiple things, then you can make it so, that you only have to use one if-line, instead of 4, 5, 1000 or something else. To do this, you will have to use the curly brackets. They tell the script engine that everything between the curly brackets belongs to the command before the left curly bracket. For example, take the following unoptimized code:&lt;br /&gt;
 if(@var == 1) mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
This can be replaced by the following:&lt;br /&gt;
 if(@var == 1){&lt;br /&gt;
    mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
What is so optimized about this? Well, in this case, you can easily see that each if-statement is completely the same, but keep in mind, that the script engine needs to do each if-statement each time it sees one. So, in the top part, it needs to do 5 checks. In the replacement, it only has to do one single check. Based on that check, it either executes the code between the { and } or skips to right after the }.&amp;lt;br&amp;gt;&lt;br /&gt;
Also, from a writer's point of view, this is exactly the same for you. You see in one glance that the entire part between the curly brackets belongs to the if(@var == 1) statement, so you do not have to check each if-statement individually to see that they are all the same.&lt;br /&gt;
&lt;br /&gt;
=== Use if...else if you're not expecting more than 2 values. ===&lt;br /&gt;
When you evaluate if a variable meets a certain condition, and you need to do something when that condition is true, and something differently when the condition is false, then you really want to use the if...else combination. This does not only make it more clear for yourself, but also faster for the script engine, because it only needs to evaluate one if-statement instead of two. Take this unoptimized piece of code for example:&lt;br /&gt;
 @win = rand(2); // Generates 1 or 0&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 if(@win == 0){&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This can be replaced by the following piece of code:&lt;br /&gt;
 @win = rand(2);&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 } else {&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Variable Use ==&lt;br /&gt;
A lot of people do not pay any attention when it comes to using variables. They randomly choose a type of variable and use it, or even use a variable when it isn't needed. You must keep in mind though, that Hercules has a limited amount of variables it can use, for (global) account and permanent player variables. Therefor, you want to minimize the use of it. This section will contain some examples of how to minimize that use.&lt;br /&gt;
&lt;br /&gt;
=== Use binary methods to store large number of flags (1 and 0). ===&lt;br /&gt;
What a lot of people do not know, is that a single variable can store up to 32 different flags, or values. And with this, I do not mean the use of an array, but really a single variable. This comes in very handy when you are only using a 1 or 0, for example: &amp;quot;set @win, 1;&amp;quot;. In a normal situation, you can only win or lose, so it can only be a 1 or 0.&amp;lt;br&amp;gt;&lt;br /&gt;
But, let's see how this translates into normal code:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bad code -&lt;br /&gt;
 set flag1, 1;&lt;br /&gt;
 set flag2, 1;&lt;br /&gt;
 set flag3, 0;&lt;br /&gt;
 set flag4, 1;&lt;br /&gt;
 set flag5, 0;&lt;br /&gt;
 if(flag1) mes &amp;quot;flag1 is checked&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Good code -&lt;br /&gt;
 set flags, 26; // (equivalent to: 16|8|0|2|0 [binary 11010])&lt;br /&gt;
 if(flags&amp;amp;16) mes &amp;quot;flag1 is checked&amp;quot;; // 11010 &amp;amp; 10000 &amp;gt; 0 (10000)&lt;br /&gt;
As you can see, only one variable used instead of 5, and it contains all the values of those five variables. (In this case, it is also a lot shorter, but that doesn't have to be the case.)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&amp;lt;br&amp;gt;&lt;br /&gt;
Using binary methods to store variables require that you have at least some knowledge on how to use binary values. This is what you may call advanced scripting, so it is quite normal if you do not understand it right away.&lt;br /&gt;
&lt;br /&gt;
== Infinite For Loops ==&lt;br /&gt;
By nature, the Athena Scripting Engine has a limit on the amount of loops that can go through in a specific amount of time, thus halting the script to eliminate the ever dreadful 'Infinite Loop'. However, there is a way around this:&lt;br /&gt;
&lt;br /&gt;
This script below, would actually halt around 682 give or take a few loops, due to preventions on infinite loops. &lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; 10000; set .@a, .@a + 1) {&lt;br /&gt;
   debugmes .@a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This method used below slows the processes down by a millisecond. This works because each time 'sleep' or 'sleep2' is used, the script's gotocount is reset.&lt;br /&gt;
 // Supposing you have 10,000 entries... let .@b = Total Entries, .@a is your splicing filter every 500 entries&lt;br /&gt;
 while (.@b &amp;lt; 10000) {&lt;br /&gt;
   for (set .@a, .@b; .@a &amp;lt; .@b + 500; set .@a, .@a + 1) {&lt;br /&gt;
     debugmes .@a;&lt;br /&gt;
   }&lt;br /&gt;
   set .@b, .@a;&lt;br /&gt;
   sleep 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
See Also: [[freeloop]]&lt;br /&gt;
&lt;br /&gt;
== While (!getmapxy()) ==&lt;br /&gt;
The standard getmapxy() returns 0 if the player is found, and 1 if the player is offline.&lt;br /&gt;
By using the !getmapxy() feature, while the value does NOT have a value aka it's 0, loop (player still online and active)&lt;br /&gt;
This can also be written while (getmapxy() == 0) { }&lt;br /&gt;
&lt;br /&gt;
 while ( !getmapxy(.@map$, .@x, .@y, 0 ) ) {&lt;br /&gt;
   if ( .@map$ != &amp;quot;prontera&amp;quot; ) { // check the player has warped to other map or not&lt;br /&gt;
     dispbottom &amp;quot;gone&amp;quot;; &lt;br /&gt;
     end; &lt;br /&gt;
   }&lt;br /&gt;
   dispbottom .@x +&amp;quot; &amp;quot;+ .@y; // report the position every N second&lt;br /&gt;
   sleep2 1000; // pause the script&lt;br /&gt;
 }&lt;br /&gt;
 end; // when the player logout, the loops break&lt;br /&gt;
&lt;br /&gt;
== Dynamic Menu ==&lt;br /&gt;
These menu's help in many different ways. Perhaps you have an unknown list of items and you want the user to select one. How do you know which item it was? What if you have a menu based on certain criteria? This menu can then change based on the information per player. This is where a dynamic menu can come into play.&lt;br /&gt;
&lt;br /&gt;
The basis of a Dynamic menu is as follows: Knowing what option a player chooses, even though the option chosen may be random.&lt;br /&gt;
&lt;br /&gt;
This is easily done with a small example of a simple (Item Required Warper)&lt;br /&gt;
&lt;br /&gt;
 prontera,158,174,4	script	MyDynWarper	88,{&lt;br /&gt;
 &lt;br /&gt;
 // Take Locations&lt;br /&gt;
 setarray .@maps$[0],&amp;quot;Prontera&amp;quot;,&amp;quot;Morocc&amp;quot;,&amp;quot;Geffen&amp;quot;,&amp;quot;Izlude&amp;quot;;&lt;br /&gt;
 setarray .@mapx[0],158,100,200,300;&lt;br /&gt;
 setarray .@mapy[0],174,100,200,300;&lt;br /&gt;
 &lt;br /&gt;
 // Set Items Needed&lt;br /&gt;
 setarray .@items,501,502,503,504; &lt;br /&gt;
 &lt;br /&gt;
 // Generate Menu&lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; getarraysize(.@maps$); set .@a, .@a + 1) {&lt;br /&gt;
   if (countitem(.@items[.@a])) {&lt;br /&gt;
     set .@menu_maps$[getarraysize(.@menu_maps$)], .@maps$[.@a];&lt;br /&gt;
     set .@menu_index[getarraysize(.@menu_index)], .@a;&lt;br /&gt;
   }&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 // Generate the Menu String&lt;br /&gt;
 set .@menu$, .@menu_maps$[0];&lt;br /&gt;
 for (set .@a, 1; .@a &amp;lt; getarraysize(.@menu_maps$); set .@a, .@a + 1) {&lt;br /&gt;
   set .@menu$, .@menu$ + &amp;quot;:&amp;quot; + .@menu_maps$[.@a];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // Query Selection&lt;br /&gt;
 set .@a, select(.@menu$) - 1; &lt;br /&gt;
 &lt;br /&gt;
 warp .@menu_maps$[.@a], .@mapx[.@a], .@mapy[.@a];&lt;br /&gt;
 end;&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Compact IF Statement ==&lt;br /&gt;
While, it looks messy, it can help shorten and quicken simplifed IF/ELSE statements. Example below includes a before and after.&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
 if ( team == 1 )&lt;br /&gt;
     mes &amp;quot;You are team Red&amp;quot;;&lt;br /&gt;
 else&lt;br /&gt;
     mes &amp;quot;You are team Blue&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
 mes &amp;quot;You are team &amp;quot;+( ( team == 1 )?&amp;quot;Red&amp;quot;:&amp;quot;Blue&amp;quot; );&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)</id>
		<title>Tips and Tricks (Scripting)</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Tips_and_Tricks_(Scripting)"/>
				<updated>2014-11-25T03:26:59Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Infinite For Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
This article will go indepth on various ways to script smartly and optimize your scripts. There is no real manual to use this article, besides reading it all, and trying to remember.&lt;br /&gt;
&lt;br /&gt;
= Tips =&lt;br /&gt;
== If-Statements ==&lt;br /&gt;
There are several ways to make your if-statements function better and faster, and make them more readable at the same time. &lt;br /&gt;
=== Use the switch statement: ===&lt;br /&gt;
Let's say we had the following code:&lt;br /&gt;
 if(getarg(1) == 0) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 1) cutin &amp;quot;kafra_05&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 2) cutin &amp;quot;kafra_04&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 3) cutin &amp;quot;kafra_03&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 4) cutin &amp;quot;kafra_02&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 5) cutin &amp;quot;kafra_01&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 6) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 7) cutin &amp;quot;kafra_08&amp;quot;,2;&lt;br /&gt;
 if(getarg(1) == 8) cutin &amp;quot;kafra_09&amp;quot;,2;&lt;br /&gt;
We could replace that entire block by the switch command. This commands looks up the value that is provided, and jumps to the according case. Don't worry, if it isn't clear yet, let's go to the replacement code first:&lt;br /&gt;
 switch(getarg(1)){&lt;br /&gt;
    case 1: cutin &amp;quot;kafra_05&amp;quot;,2; break;&lt;br /&gt;
    case 2: cutin &amp;quot;kafra_04&amp;quot;,2; break;&lt;br /&gt;
    case 3: cutin &amp;quot;kafra_03&amp;quot;,2; break;&lt;br /&gt;
    case 4: cutin &amp;quot;kafra_02&amp;quot;,2; break;&lt;br /&gt;
    case 5: cutin &amp;quot;kafra_01&amp;quot;,2; break;&lt;br /&gt;
    case 6: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    case 7: cutin &amp;quot;kafra_08&amp;quot;,2; break;&lt;br /&gt;
    case 8: cutin &amp;quot;kafra_09&amp;quot;,2; break;&lt;br /&gt;
    default: cutin &amp;quot;kafra_06&amp;quot;,2; break;&lt;br /&gt;
 }&lt;br /&gt;
As you can see, each if-line has been replaced by a case-line. The command switch looks up the value of getarg(1). If this would be 5, then it would jump to &amp;quot;case 5&amp;quot;, do the cutin, and then break. Break makes it jump to after the right curly bracket ('}').&amp;lt;br&amp;gt;&lt;br /&gt;
If it finds getarg(1) to be 8, it jumps to &amp;quot;case 8&amp;quot;, and does the same there. And the best part of the switch statement might be the default one. It kind of replaces the following really unoptimized line:&lt;br /&gt;
 if(getarg(1) != 1 &amp;amp;&amp;amp; getarg(1) != 2 &amp;amp;&amp;amp; getarg(1) != 3 .... &amp;amp;&amp;amp; getarg(1) != 8) cutin &amp;quot;kafra_06&amp;quot;,2;&lt;br /&gt;
In English, this means, if the value of getarg(1) does not have an accompanied case, it will jump to the default label.&lt;br /&gt;
&lt;br /&gt;
=== Use the brackets if you're executing more than 1 statement in 'if' statements. ===&lt;br /&gt;
If you have a piece of code, that needs to check for a condition, and do multiple things, then you can make it so, that you only have to use one if-line, instead of 4, 5, 1000 or something else. To do this, you will have to use the curly brackets. They tell the script engine that everything between the curly brackets belongs to the command before the left curly bracket. For example, take the following unoptimized code:&lt;br /&gt;
 if(@var == 1) mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
 if(@var == 1) mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
This can be replaced by the following:&lt;br /&gt;
 if(@var == 1){&lt;br /&gt;
    mes &amp;quot;haha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;heha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hiha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;hoha&amp;quot;;&lt;br /&gt;
    mes &amp;quot;huha&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
What is so optimized about this? Well, in this case, you can easily see that each if-statement is completely the same, but keep in mind, that the script engine needs to do each if-statement each time it sees one. So, in the top part, it needs to do 5 checks. In the replacement, it only has to do one single check. Based on that check, it either executes the code between the { and } or skips to right after the }.&amp;lt;br&amp;gt;&lt;br /&gt;
Also, from a writer's point of view, this is exactly the same for you. You see in one glance that the entire part between the curly brackets belongs to the if(@var == 1) statement, so you do not have to check each if-statement individually to see that they are all the same.&lt;br /&gt;
&lt;br /&gt;
=== Use if...else if you're not expecting more than 2 values. ===&lt;br /&gt;
When you evaluate if a variable meets a certain condition, and you need to do something when that condition is true, and something differently when the condition is false, then you really want to use the if...else combination. This does not only make it more clear for yourself, but also faster for the script engine, because it only needs to evaluate one if-statement instead of two. Take this unoptimized piece of code for example:&lt;br /&gt;
 set @win, rand(2); // Generates 1 or 0&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 if(@win == 0){&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This can be replaced by the following piece of code:&lt;br /&gt;
 set @win, rand(2);&lt;br /&gt;
 if(@win == 1){&lt;br /&gt;
    mes &amp;quot;You win!&amp;quot;;&lt;br /&gt;
 } else {&lt;br /&gt;
    mes &amp;quot;You lose!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Variable Use ==&lt;br /&gt;
A lot of people do not pay any attention when it comes to using variables. They randomly choose a type of variable and use it, or even use a variable when it isn't needed. You must keep in mind though, that Hercules has a limited amount of variables it can use, for (global) account and permanent player variables. Therefor, you want to minimize the use of it. This section will contain some examples of how to minimize that use.&lt;br /&gt;
&lt;br /&gt;
=== Use binary methods to store large number of flags (1 and 0). ===&lt;br /&gt;
What a lot of people do not know, is that a single variable can store up to 32 different flags, or values. And with this, I do not mean the use of an array, but really a single variable. This comes in very handy when you are only using a 1 or 0, for example: &amp;quot;set @win, 1;&amp;quot;. In a normal situation, you can only win or lose, so it can only be a 1 or 0.&amp;lt;br&amp;gt;&lt;br /&gt;
But, let's see how this translates into normal code:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bad code -&lt;br /&gt;
 set flag1, 1;&lt;br /&gt;
 set flag2, 1;&lt;br /&gt;
 set flag3, 0;&lt;br /&gt;
 set flag4, 1;&lt;br /&gt;
 set flag5, 0;&lt;br /&gt;
 if(flag1) mes &amp;quot;flag1 is checked&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Good code -&lt;br /&gt;
 set flags, 26; // (equivalent to: 16|8|0|2|0 [binary 11010])&lt;br /&gt;
 if(flags&amp;amp;16) mes &amp;quot;flag1 is checked&amp;quot;; // 11010 &amp;amp; 10000 &amp;gt; 0 (10000)&lt;br /&gt;
As you can see, only one variable used instead of 5, and it contains all the values of those five variables. (In this case, it is also a lot shorter, but that doesn't have to be the case.)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&amp;lt;br&amp;gt;&lt;br /&gt;
Using binary methods to store variables require that you have at least some knowledge on how to use binary values. This is what you may call advanced scripting, so it is quite normal if you do not understand it right away.&lt;br /&gt;
&lt;br /&gt;
== Infinite For Loops ==&lt;br /&gt;
By nature, the Athena Scripting Engine has a limit on the amount of loops that can go through in a specific amount of time, thus halting the script to eliminate the ever dreadful 'Infinite Loop'. However, there is a way around this:&lt;br /&gt;
&lt;br /&gt;
This script below, would actually halt around 682 give or take a few loops, due to preventions on infinite loops. &lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; 10000; set .@a, .@a + 1) {&lt;br /&gt;
   debugmes .@a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This method used below slows the processes down by a millisecond. This works because each time 'sleep' or 'sleep2' is used, the script's gotocount is reset.&lt;br /&gt;
 // Supposing you have 10,000 entries... let .@b = Total Entries, .@a is your splicing filter every 500 entries&lt;br /&gt;
 while (.@b &amp;lt; 10000) {&lt;br /&gt;
   for (set .@a, .@b; .@a &amp;lt; .@b + 500; set .@a, .@a + 1) {&lt;br /&gt;
     debugmes .@a;&lt;br /&gt;
   }&lt;br /&gt;
   set .@b, .@a;&lt;br /&gt;
   sleep 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
See Also: [[freeloop]]&lt;br /&gt;
&lt;br /&gt;
== While (!getmapxy()) ==&lt;br /&gt;
The standard getmapxy() returns 0 if the player is found, and 1 if the player is offline.&lt;br /&gt;
By using the !getmapxy() feature, while the value does NOT have a value aka it's 0, loop (player still online and active)&lt;br /&gt;
This can also be written while (getmapxy() == 0) { }&lt;br /&gt;
&lt;br /&gt;
 while ( !getmapxy(.@map$, .@x, .@y, 0 ) ) {&lt;br /&gt;
   if ( .@map$ != &amp;quot;prontera&amp;quot; ) { // check the player has warped to other map or not&lt;br /&gt;
     dispbottom &amp;quot;gone&amp;quot;; &lt;br /&gt;
     end; &lt;br /&gt;
   }&lt;br /&gt;
   dispbottom .@x +&amp;quot; &amp;quot;+ .@y; // report the position every N second&lt;br /&gt;
   sleep2 1000; // pause the script&lt;br /&gt;
 }&lt;br /&gt;
 end; // when the player logout, the loops break&lt;br /&gt;
&lt;br /&gt;
== Dynamic Menu ==&lt;br /&gt;
These menu's help in many different ways. Perhaps you have an unknown list of items and you want the user to select one. How do you know which item it was? What if you have a menu based on certain criteria? This menu can then change based on the information per player. This is where a dynamic menu can come into play.&lt;br /&gt;
&lt;br /&gt;
The basis of a Dynamic menu is as follows: Knowing what option a player chooses, even though the option chosen may be random.&lt;br /&gt;
&lt;br /&gt;
This is easily done with a small example of a simple (Item Required Warper)&lt;br /&gt;
&lt;br /&gt;
 prontera,158,174,4	script	MyDynWarper	88,{&lt;br /&gt;
 &lt;br /&gt;
 // Take Locations&lt;br /&gt;
 setarray .@maps$[0],&amp;quot;Prontera&amp;quot;,&amp;quot;Morocc&amp;quot;,&amp;quot;Geffen&amp;quot;,&amp;quot;Izlude&amp;quot;;&lt;br /&gt;
 setarray .@mapx[0],158,100,200,300;&lt;br /&gt;
 setarray .@mapy[0],174,100,200,300;&lt;br /&gt;
 &lt;br /&gt;
 // Set Items Needed&lt;br /&gt;
 setarray .@items,501,502,503,504; &lt;br /&gt;
 &lt;br /&gt;
 // Generate Menu&lt;br /&gt;
 for (set .@a, 0; .@a &amp;lt; getarraysize(.@maps$); set .@a, .@a + 1) {&lt;br /&gt;
   if (countitem(.@items[.@a])) {&lt;br /&gt;
     set .@menu_maps$[getarraysize(.@menu_maps$)], .@maps$[.@a];&lt;br /&gt;
     set .@menu_index[getarraysize(.@menu_index)], .@a;&lt;br /&gt;
   }&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 // Generate the Menu String&lt;br /&gt;
 set .@menu$, .@menu_maps$[0];&lt;br /&gt;
 for (set .@a, 1; .@a &amp;lt; getarraysize(.@menu_maps$); set .@a, .@a + 1) {&lt;br /&gt;
   set .@menu$, .@menu$ + &amp;quot;:&amp;quot; + .@menu_maps$[.@a];&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // Query Selection&lt;br /&gt;
 set .@a, select(.@menu$) - 1; &lt;br /&gt;
 &lt;br /&gt;
 warp .@menu_maps$[.@a], .@mapx[.@a], .@mapy[.@a];&lt;br /&gt;
 end;&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Compact IF Statement ==&lt;br /&gt;
While, it looks messy, it can help shorten and quicken simplifed IF/ELSE statements. Example below includes a before and after.&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
 if ( team == 1 )&lt;br /&gt;
     mes &amp;quot;You are team Red&amp;quot;;&lt;br /&gt;
 else&lt;br /&gt;
     mes &amp;quot;You are team Blue&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
 mes &amp;quot;You are team &amp;quot;+( ( team == 1 )?&amp;quot;Red&amp;quot;:&amp;quot;Blue&amp;quot; );&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Quest_Log_System</id>
		<title>Quest Log System</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Quest_Log_System"/>
				<updated>2014-11-16T19:50:28Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quest Log System ==&lt;br /&gt;
&lt;br /&gt;
==== Basic Structure of NPC ====&lt;br /&gt;
&lt;br /&gt;
First of all you must have a knowledge on basic scripting, if not please kindly Click [[Basic_Scripting|Here!]].&lt;br /&gt;
&lt;br /&gt;
==== Quest Window ====&lt;br /&gt;
&lt;br /&gt;
The Quest Window or Quest Journal (Opened via Alt+U) allows the player to view all quests their character has started but not yet completed (Except for instance dungeon quests and Battlegrounds instances, which always remain once started).&lt;br /&gt;
To place a quest in the Inactive tab, right click once on it and the name will turn gray. It will then appear on the Inactive tab instead of Active. Right clicking the name again will bring it back to the Active tab. Moving the quest back and forth has no effect on whether you can continue it or not.&lt;br /&gt;
Not every quest has a quest window component. Those quests who have quest window walkthroughs can be found in this category as well as by having their infobox in gold. Additionally, the Quest Window guides are not comprehensive, and do not specify the exact coordinates of the next NPC or location the player must visit. It is highly recommended to continue using the wiki guides along with the in-game walkthroughs.&lt;br /&gt;
&lt;br /&gt;
[[File:QWindow.jpg|center|caption]]&lt;br /&gt;
&lt;br /&gt;
== Quest Database - Adding Quest ==&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Quest ID,Time Limit,Target1,Val1,Target2,Val2,Target3,Val3,Quest Title&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Quest ID - ID of the quest, must increment and should not be duplicated.&amp;lt;br&amp;gt;&lt;br /&gt;
Time Limit - Time limit for the quest to be finish.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 1 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val1 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 2 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val2 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 3 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val3 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Quest Title - The title of the Quest you made.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
For this example I will make a quest that will require to kill 10 Poring's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;65000,0,1002,10,0,0,0,0,&amp;quot;Quest - Poring Hunt&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Client Side Editing ====&lt;br /&gt;
&lt;br /&gt;
You have to edit your questid2display.txt&lt;br /&gt;
&lt;br /&gt;
==== Structure ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTID#Quest Name#FILENAME#LOG_FILENAME#&lt;br /&gt;
Summary description#&lt;br /&gt;
Objective description#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
65000#Quest - Poring Hunt#SG_FEEL#QUE_NOIMAGE#&lt;br /&gt;
Find the monster named Poring and kill 10#&lt;br /&gt;
Hunting 10 Poring#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Quest Log Commands ==&lt;br /&gt;
&lt;br /&gt;
=== Set Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*setquest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place quest of &amp;lt;ID&amp;gt; in the users quest log, the state of which is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	SetQuest	51,{&lt;br /&gt;
setquest 65000;	// This will add the Quest ID 65000 to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sample will add the quest &amp;quot;Quest - Poring Hunt&amp;quot; which I stated on the Adding Quest.&lt;br /&gt;
'''Note''': The example is just a simple NPC that will add Quest ID 65000 every time you click it, You can add conditions so that it can only be taken once. &lt;br /&gt;
&lt;br /&gt;
=== Complete Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*completequest &amp;lt;ID&amp;gt;{,&amp;lt;ID2&amp;gt;};&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the state for the given quest &amp;lt;ID&amp;gt; to &amp;quot;complete&amp;quot; and remove from &lt;br /&gt;
the users quest log.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
If a second quest id of greater value is specified, all quests between the two&lt;br /&gt;
will be completed.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CompleteQuest	51,{&lt;br /&gt;
completequest 65000;	// This will change the state of the quest to &amp;quot;complete&amp;quot;&lt;br /&gt;
set zeny,zeny + 100;   //just add line like this if you want to give zeny reward if a player finish the quest.&lt;br /&gt;
getitem 501,1;         //just add line like this if you want to give item reward if a player finish the quest.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Erase Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*erasequest &amp;lt;ID&amp;gt;{,&amp;lt;ID2&amp;gt;};&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove the quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
If a second quest id of greater value is specified, all quests between the two&lt;br /&gt;
will be erased.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	EraseQuest	51,{&lt;br /&gt;
erasequest 65000;	// This will remove the quest to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*changequest &amp;lt;ID&amp;gt;,&amp;lt;ID2&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
Add quest of the &amp;lt;ID2&amp;gt; to the the quest log, and the state is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	ChangeQuest	51,{&lt;br /&gt;
changequest 65000,65001; // This will remove the quest ID 65000 and change it to 65001 with the state &amp;quot;active&amp;quot;.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Check Quest Progress ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questprogress(&amp;lt;ID&amp;gt;{,PLAYTIME|HUNTING})&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If no additional argument supplied, return the state of the quest: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = Quest has been given&lt;br /&gt;
2  = Quest completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questactive(&amp;lt;ID&amp;gt;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check whether the given quest is in its active state.&lt;br /&gt;
Returns true if the quest is active, false otherwise (quest not started, inactive or completed)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if(!questactive(65000)) { //Quest is Inactive&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Inactive&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(!questprogress(65000)) { //Quest Not started yet &lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Not Started&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(questactive(65000)) { //Quest is Active&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Active!&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(questprogress(65000) == 2) {	// Quest finished.&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished!&amp;quot;;&lt;br /&gt;
completequest 65000;&lt;br /&gt;
close;&lt;br /&gt;
} &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;PLAYTIME&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = the time limit has not yet been reached&lt;br /&gt;
2  = the time limit has been reached&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;HUNTING&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1 = Player hasn't killed all of the target monsters&lt;br /&gt;
2 = Player has killed all of the target monsters&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example | Hunting ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if (!questprogress(65000,HUNTING)) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest not Started&amp;quot;,&lt;br /&gt;
close;&lt;br /&gt;
} else if (questprogress(65000,HUNTING) == 1) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;You haven't killed all of the target monsters.&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if (questprogress(65000,HUNTING) == 2) {&lt;br /&gt;
completequest 65000;&lt;br /&gt;
set zeny,zeny+100;      //Zeny Reward&lt;br /&gt;
getitem 501,1;          // Item Reward&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show Event ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*showevent &amp;lt;state&amp;gt;, &amp;lt;color&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Show a colored mark in the mini-map like &amp;quot;viewpoint&amp;quot; and an emotion on top &lt;br /&gt;
of a NPC. This is used to indicate that a NPC has a quest or an event to &lt;br /&gt;
certain player/s. &lt;br /&gt;
&lt;br /&gt;
state can be:&lt;br /&gt;
	0 = disable ( Used to disable and remove the mark and the emotion from &lt;br /&gt;
		the NPC. )&lt;br /&gt;
	1 = exclamation emotion ( Used to show an important quest event to &lt;br /&gt;
		certain player. )&lt;br /&gt;
	2 = interrogation emotion ( Used to show an non-important quest event &lt;br /&gt;
		to certain player. )&lt;br /&gt;
Other value may cause client crashes.&lt;br /&gt;
&lt;br /&gt;
color can be:&lt;br /&gt;
	0 = yellow &amp;quot;Quest&amp;quot;&lt;br /&gt;
	1 = orange &amp;quot;Job&amp;quot;&lt;br /&gt;
	2 = green &amp;quot;Event&amp;quot;&lt;br /&gt;
	3 = an MVP flag&lt;br /&gt;
Other values show a transparent mark in the mini-map.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Increasing Max Quest DB ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trunk/src/map/quest.h &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find this line and increase the value.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recompile, Cheers!&lt;br /&gt;
&lt;br /&gt;
(If you don't know how to recompile click [[Compiling|Here!]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Quest_Log_System</id>
		<title>Quest Log System</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Quest_Log_System"/>
				<updated>2014-10-28T01:07:44Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Example | Hunting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quest Log System ==&lt;br /&gt;
&lt;br /&gt;
==== Basic Structure of NPC ====&lt;br /&gt;
&lt;br /&gt;
First of all you must have a knowledge on basic scripting, if not please kindly Click [[Basic_Scripting|Here!]].&lt;br /&gt;
&lt;br /&gt;
==== Quest Window ====&lt;br /&gt;
&lt;br /&gt;
The Quest Window or Quest Journal (Opened via Alt+U) allows the player to view all quests their character has started but not yet completed (Except for instance dungeon quests and Battlegrounds instances, which always remain once started).&lt;br /&gt;
To place a quest in the Inactive tab, right click once on it and the name will turn gray. It will then appear on the Inactive tab instead of Active. Right clicking the name again will bring it back to the Active tab. Moving the quest back and forth has no effect on whether you can continue it or not.&lt;br /&gt;
Not every quest has a quest window component. Those quests who have quest window walkthroughs can be found in this category as well as by having their infobox in gold. Additionally, the Quest Window guides are not comprehensive, and do not specify the exact coordinates of the next NPC or location the player must visit. It is highly recommended to continue using the wiki guides along with the in-game walkthroughs.&lt;br /&gt;
&lt;br /&gt;
[[File:QWindow.jpg|center|caption]]&lt;br /&gt;
&lt;br /&gt;
== Quest Database - Adding Quest ==&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Quest ID,Time Limit,Target1,Val1,Target2,Val2,Target3,Val3,Quest Title&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Quest ID - ID of the quest, must increment and should not be duplicated.&amp;lt;br&amp;gt;&lt;br /&gt;
Time Limit - Time limit for the quest to be finish.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 1 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val1 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 2 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val2 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 3 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val3 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Quest Title - The title of the Quest you made.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
For this example I will make a quest that will require to kill 10 Poring's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;65000,0,1002,10,0,0,0,0,&amp;quot;Quest - Poring Hunt&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Client Side Editing ====&lt;br /&gt;
&lt;br /&gt;
You have to edit your questid2display.txt&lt;br /&gt;
&lt;br /&gt;
==== Structure ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTID#Quest Name#FILENAME#LOG_FILENAME#&lt;br /&gt;
Summary description#&lt;br /&gt;
Objective description#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
65000#Quest - Poring Hunt#SG_FEEL#QUE_NOIMAGE#&lt;br /&gt;
Find the monster named Poring and kill 10#&lt;br /&gt;
Hunting 10 Poring#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Quest Log Commands ==&lt;br /&gt;
&lt;br /&gt;
=== Set Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*setquest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place quest of &amp;lt;ID&amp;gt; in the users quest log, the state of which is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	SetQuest	51,{&lt;br /&gt;
setquest 65000;	// This will add the Quest ID 65000 to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sample will add the quest &amp;quot;Quest - Poring Hunt&amp;quot; which I stated on the Adding Quest.&lt;br /&gt;
'''Note''': The example is just a simple NPC that will add Quest ID 65000 every time you click it, You can add conditions so that it can only be taken once. &lt;br /&gt;
&lt;br /&gt;
=== Complete Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*completequest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the state for the given quest &amp;lt;ID&amp;gt; to &amp;quot;complete&amp;quot; and remove from &lt;br /&gt;
the users quest log.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CompleteQuest	51,{&lt;br /&gt;
completequest 65000;	// This will change the state of the quest to &amp;quot;complete&amp;quot;&lt;br /&gt;
set zeny,zeny + 100;   //just add line like this if you want to give zeny reward if a player finish the quest.&lt;br /&gt;
getitem 501,1;         //just add line like this if you want to give item reward if a player finish the quest.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Erase Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*erasequest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove the quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	EraseQuest	51,{&lt;br /&gt;
erasequest 65000;	// This will remove the quest to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*changequest &amp;lt;ID&amp;gt;,&amp;lt;ID2&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
Add quest of the &amp;lt;ID2&amp;gt; to the the quest log, and the state is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	ChangeQuest	51,{&lt;br /&gt;
changequest 65000,65001; // This will remove the quest ID 65000 and change it to 65001 with the state &amp;quot;active&amp;quot;.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Check Quest Progress ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questprogress(&amp;lt;ID&amp;gt;{,PLAYTIME|HUNTING})&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If no additional argument supplied, return the state of the quest: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = Quest has been given&lt;br /&gt;
2  = Quest completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questactive(&amp;lt;ID&amp;gt;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check whether the given quest is in its active state.&lt;br /&gt;
Returns true if the quest is active, false otherwise (quest not started, inactive or completed)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if(!questactive(65000)) { //Quest is Inactive&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Inactive&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(!questprogress(65000)) { //Quest Not started yet &lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Not Started&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(questactive(65000)) { //Quest is Active&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Active!&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(questprogress(65000) == 2) {	// Quest finished.&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished!&amp;quot;;&lt;br /&gt;
completequest 65000;&lt;br /&gt;
close;&lt;br /&gt;
} &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;PLAYTIME&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = the time limit has not yet been reached&lt;br /&gt;
2  = the time limit has been reached&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;HUNTING&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1 = Player hasn't killed all of the target monsters&lt;br /&gt;
2 = Player has killed all of the target monsters&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example | Hunting ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if (!questprogress(65000,HUNTING)) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest not Started&amp;quot;,&lt;br /&gt;
close;&lt;br /&gt;
} else if (questprogress(65000,HUNTING) == 1) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;You haven't killed all of the target monsters.&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if (questprogress(65000,HUNTING) == 2) {&lt;br /&gt;
completequest 65000;&lt;br /&gt;
set zeny,zeny+100;      //Zeny Reward&lt;br /&gt;
getitem 501,1;          // Item Reward&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show Event ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*showevent &amp;lt;state&amp;gt;, &amp;lt;color&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Show a colored mark in the mini-map like &amp;quot;viewpoint&amp;quot; and an emotion on top &lt;br /&gt;
of a NPC. This is used to indicate that a NPC has a quest or an event to &lt;br /&gt;
certain player/s. &lt;br /&gt;
&lt;br /&gt;
state can be:&lt;br /&gt;
	0 = disable ( Used to disable and remove the mark and the emotion from &lt;br /&gt;
		the NPC. )&lt;br /&gt;
	1 = exclamation emotion ( Used to show an important quest event to &lt;br /&gt;
		certain player. )&lt;br /&gt;
	2 = interrogation emotion ( Used to show an non-important quest event &lt;br /&gt;
		to certain player. )&lt;br /&gt;
Other value may cause client crashes.&lt;br /&gt;
&lt;br /&gt;
color can be:&lt;br /&gt;
	0 = yellow &amp;quot;Quest&amp;quot;&lt;br /&gt;
	1 = orange &amp;quot;Job&amp;quot;&lt;br /&gt;
	2 = green &amp;quot;Event&amp;quot;&lt;br /&gt;
	3 = an MVP flag&lt;br /&gt;
Other values show a transparent mark in the mini-map.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Increasing Max Quest DB ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trunk/src/map/quest.h &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find this line and increase the value.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recompile, Cheers!&lt;br /&gt;
&lt;br /&gt;
(If you don't know how to recompile click [[Compiling|Here!]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Quest_Log_System</id>
		<title>Quest Log System</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Quest_Log_System"/>
				<updated>2014-10-28T01:04:46Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quest Log System ==&lt;br /&gt;
&lt;br /&gt;
==== Basic Structure of NPC ====&lt;br /&gt;
&lt;br /&gt;
First of all you must have a knowledge on basic scripting, if not please kindly Click [[Basic_Scripting|Here!]].&lt;br /&gt;
&lt;br /&gt;
==== Quest Window ====&lt;br /&gt;
&lt;br /&gt;
The Quest Window or Quest Journal (Opened via Alt+U) allows the player to view all quests their character has started but not yet completed (Except for instance dungeon quests and Battlegrounds instances, which always remain once started).&lt;br /&gt;
To place a quest in the Inactive tab, right click once on it and the name will turn gray. It will then appear on the Inactive tab instead of Active. Right clicking the name again will bring it back to the Active tab. Moving the quest back and forth has no effect on whether you can continue it or not.&lt;br /&gt;
Not every quest has a quest window component. Those quests who have quest window walkthroughs can be found in this category as well as by having their infobox in gold. Additionally, the Quest Window guides are not comprehensive, and do not specify the exact coordinates of the next NPC or location the player must visit. It is highly recommended to continue using the wiki guides along with the in-game walkthroughs.&lt;br /&gt;
&lt;br /&gt;
[[File:QWindow.jpg|center|caption]]&lt;br /&gt;
&lt;br /&gt;
== Quest Database - Adding Quest ==&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Quest ID,Time Limit,Target1,Val1,Target2,Val2,Target3,Val3,Quest Title&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Quest ID - ID of the quest, must increment and should not be duplicated.&amp;lt;br&amp;gt;&lt;br /&gt;
Time Limit - Time limit for the quest to be finish.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 1 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val1 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 2 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val2 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 3 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val3 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Quest Title - The title of the Quest you made.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
For this example I will make a quest that will require to kill 10 Poring's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;65000,0,1002,10,0,0,0,0,&amp;quot;Quest - Poring Hunt&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Client Side Editing ====&lt;br /&gt;
&lt;br /&gt;
You have to edit your questid2display.txt&lt;br /&gt;
&lt;br /&gt;
==== Structure ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTID#Quest Name#FILENAME#LOG_FILENAME#&lt;br /&gt;
Summary description#&lt;br /&gt;
Objective description#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
65000#Quest - Poring Hunt#SG_FEEL#QUE_NOIMAGE#&lt;br /&gt;
Find the monster named Poring and kill 10#&lt;br /&gt;
Hunting 10 Poring#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Quest Log Commands ==&lt;br /&gt;
&lt;br /&gt;
=== Set Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*setquest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place quest of &amp;lt;ID&amp;gt; in the users quest log, the state of which is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	SetQuest	51,{&lt;br /&gt;
setquest 65000;	// This will add the Quest ID 65000 to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sample will add the quest &amp;quot;Quest - Poring Hunt&amp;quot; which I stated on the Adding Quest.&lt;br /&gt;
'''Note''': The example is just a simple NPC that will add Quest ID 65000 every time you click it, You can add conditions so that it can only be taken once. &lt;br /&gt;
&lt;br /&gt;
=== Complete Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*completequest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the state for the given quest &amp;lt;ID&amp;gt; to &amp;quot;complete&amp;quot; and remove from &lt;br /&gt;
the users quest log.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CompleteQuest	51,{&lt;br /&gt;
completequest 65000;	// This will change the state of the quest to &amp;quot;complete&amp;quot;&lt;br /&gt;
set zeny,zeny + 100;   //just add line like this if you want to give zeny reward if a player finish the quest.&lt;br /&gt;
getitem 501,1;         //just add line like this if you want to give item reward if a player finish the quest.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Erase Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*erasequest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove the quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	EraseQuest	51,{&lt;br /&gt;
erasequest 65000;	// This will remove the quest to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*changequest &amp;lt;ID&amp;gt;,&amp;lt;ID2&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
Add quest of the &amp;lt;ID2&amp;gt; to the the quest log, and the state is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	ChangeQuest	51,{&lt;br /&gt;
changequest 65000,65001; // This will remove the quest ID 65000 and change it to 65001 with the state &amp;quot;active&amp;quot;.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Check Quest Progress ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questprogress(&amp;lt;ID&amp;gt;{,PLAYTIME|HUNTING})&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If no additional argument supplied, return the state of the quest: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = Quest has been given&lt;br /&gt;
2  = Quest completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questactive(&amp;lt;ID&amp;gt;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check whether the given quest is in its active state.&lt;br /&gt;
Returns true if the quest is active, false otherwise (quest not started, inactive or completed)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if(!questactive(65000)) { //Quest is Inactive&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Inactive&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(!questprogress(65000)) { //Quest Not started yet &lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Not Started&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(questactive(65000)) { //Quest is Active&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Active!&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(questprogress(65000) == 2) {	// Quest finished.&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished!&amp;quot;;&lt;br /&gt;
completequest 65000;&lt;br /&gt;
close;&lt;br /&gt;
} &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;PLAYTIME&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = the time limit has not yet been reached&lt;br /&gt;
2  = the time limit has been reached&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;HUNTING&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1 = Player hasn't killed all of the target monsters&lt;br /&gt;
2 = Player has killed all of the target monsters&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example | Hunting ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if (checkquest(65000,HUNTING) == -1) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest not Started&amp;quot;,&lt;br /&gt;
close;&lt;br /&gt;
} else if (checkquest(65000,HUNTING) == 0) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;You haven't killed all of the target monsters and the time limit has not been reached.&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if (checkquest(65000,HUNTING) == 1) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;You haven't killed all of the target monsters but the time limit has been reached.&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if (checkquest(65000,HUNTING) == 2) {&lt;br /&gt;
completequest 65000;&lt;br /&gt;
set zeny,zeny+100;      //Zeny Reward&lt;br /&gt;
getitem 501,1;          // Item Reward&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show Event ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*showevent &amp;lt;state&amp;gt;, &amp;lt;color&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Show a colored mark in the mini-map like &amp;quot;viewpoint&amp;quot; and an emotion on top &lt;br /&gt;
of a NPC. This is used to indicate that a NPC has a quest or an event to &lt;br /&gt;
certain player/s. &lt;br /&gt;
&lt;br /&gt;
state can be:&lt;br /&gt;
	0 = disable ( Used to disable and remove the mark and the emotion from &lt;br /&gt;
		the NPC. )&lt;br /&gt;
	1 = exclamation emotion ( Used to show an important quest event to &lt;br /&gt;
		certain player. )&lt;br /&gt;
	2 = interrogation emotion ( Used to show an non-important quest event &lt;br /&gt;
		to certain player. )&lt;br /&gt;
Other value may cause client crashes.&lt;br /&gt;
&lt;br /&gt;
color can be:&lt;br /&gt;
	0 = yellow &amp;quot;Quest&amp;quot;&lt;br /&gt;
	1 = orange &amp;quot;Job&amp;quot;&lt;br /&gt;
	2 = green &amp;quot;Event&amp;quot;&lt;br /&gt;
	3 = an MVP flag&lt;br /&gt;
Other values show a transparent mark in the mini-map.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Increasing Max Quest DB ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trunk/src/map/quest.h &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find this line and increase the value.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recompile, Cheers!&lt;br /&gt;
&lt;br /&gt;
(If you don't know how to recompile click [[Compiling|Here!]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Quest_Log_System</id>
		<title>Quest Log System</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Quest_Log_System"/>
				<updated>2014-10-28T00:59:24Z</updated>
		
		<summary type="html">&lt;p&gt;GmOcean: /* Quest Progress */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quest Log System ==&lt;br /&gt;
&lt;br /&gt;
==== Basic Structure of NPC ====&lt;br /&gt;
&lt;br /&gt;
First of all you must have a knowledge on basic scripting, if not please kindly Click [[Basic_Scripting|Here!]].&lt;br /&gt;
&lt;br /&gt;
==== Quest Window ====&lt;br /&gt;
&lt;br /&gt;
The Quest Window or Quest Journal (Opened via Alt+U) allows the player to view all quests their character has started but not yet completed (Except for instance dungeon quests and Battlegrounds instances, which always remain once started).&lt;br /&gt;
To place a quest in the Inactive tab, right click once on it and the name will turn gray. It will then appear on the Inactive tab instead of Active. Right clicking the name again will bring it back to the Active tab. Moving the quest back and forth has no effect on whether you can continue it or not.&lt;br /&gt;
Not every quest has a quest window component. Those quests who have quest window walkthroughs can be found in this category as well as by having their infobox in gold. Additionally, the Quest Window guides are not comprehensive, and do not specify the exact coordinates of the next NPC or location the player must visit. It is highly recommended to continue using the wiki guides along with the in-game walkthroughs.&lt;br /&gt;
&lt;br /&gt;
[[File:QWindow.jpg|center|caption]]&lt;br /&gt;
&lt;br /&gt;
== Quest Database - Adding Quest ==&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Quest ID,Time Limit,Target1,Val1,Target2,Val2,Target3,Val3,Quest Title&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Quest ID - ID of the quest, must increment and should not be duplicated.&amp;lt;br&amp;gt;&lt;br /&gt;
Time Limit - Time limit for the quest to be finish.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 1 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val1 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 2 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val2 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Target 3 - Monster ID.&amp;lt;br&amp;gt;&lt;br /&gt;
Val3 - Value of Monster to be killed.&amp;lt;br&amp;gt;&lt;br /&gt;
Quest Title - The title of the Quest you made.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
For this example I will make a quest that will require to kill 10 Poring's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;65000,0,1002,10,0,0,0,0,&amp;quot;Quest - Poring Hunt&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Client Side Editing ====&lt;br /&gt;
&lt;br /&gt;
You have to edit your questid2display.txt&lt;br /&gt;
&lt;br /&gt;
==== Structure ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTID#Quest Name#FILENAME#LOG_FILENAME#&lt;br /&gt;
Summary description#&lt;br /&gt;
Objective description#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
65000#Quest - Poring Hunt#SG_FEEL#QUE_NOIMAGE#&lt;br /&gt;
Find the monster named Poring and kill 10#&lt;br /&gt;
Hunting 10 Poring#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Quest Log Commands ==&lt;br /&gt;
&lt;br /&gt;
=== Set Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*setquest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place quest of &amp;lt;ID&amp;gt; in the users quest log, the state of which is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	SetQuest	51,{&lt;br /&gt;
setquest 65000;	// This will add the Quest ID 65000 to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sample will add the quest &amp;quot;Quest - Poring Hunt&amp;quot; which I stated on the Adding Quest.&lt;br /&gt;
'''Note''': The example is just a simple NPC that will add Quest ID 65000 every time you click it, You can add conditions so that it can only be taken once. &lt;br /&gt;
&lt;br /&gt;
=== Complete Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*completequest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the state for the given quest &amp;lt;ID&amp;gt; to &amp;quot;complete&amp;quot; and remove from &lt;br /&gt;
the users quest log.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CompleteQuest	51,{&lt;br /&gt;
completequest 65000;	// This will change the state of the quest to &amp;quot;complete&amp;quot;&lt;br /&gt;
set zeny,zeny + 100;   //just add line like this if you want to give zeny reward if a player finish the quest.&lt;br /&gt;
getitem 501,1;         //just add line like this if you want to give item reward if a player finish the quest.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Erase Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*erasequest &amp;lt;ID&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove the quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	EraseQuest	51,{&lt;br /&gt;
erasequest 65000;	// This will remove the quest to your Quest Window.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change Quest ===&lt;br /&gt;
&amp;lt;pre&amp;gt;*changequest &amp;lt;ID&amp;gt;,&amp;lt;ID2&amp;gt;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove quest of the given &amp;lt;ID&amp;gt; from the user's quest log.&lt;br /&gt;
Add quest of the &amp;lt;ID2&amp;gt; to the the quest log, and the state is &amp;quot;active&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	ChangeQuest	51,{&lt;br /&gt;
changequest 65000,65001; // This will remove the quest ID 65000 and change it to 65001 with the state &amp;quot;active&amp;quot;.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Check Quest Progress ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questprogress(&amp;lt;ID&amp;gt;{,PLAYTIME|HUNTING})&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If no additional argument supplied, return the state of the quest: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 = Quest not started (not in quest log)&lt;br /&gt;
1  = Quest has been given&lt;br /&gt;
2  = Quest completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;*questactive(&amp;lt;ID&amp;gt;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check whether the given quest is in its active state.&lt;br /&gt;
Returns true if the quest is active, false otherwise (quest not started, inactive or completed)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if(checkquest(65000) == 0) { //Quest is Inactive&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Inactive&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(checkquest(65000) == -1) { //Quest Not started yet &lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Not Started&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(checkquest(65000) == 1) { //Quest is Active&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest is Active!&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if(checkquest(65000) == 2) {	// Quest finished.&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished!&amp;quot;;&lt;br /&gt;
completequest 65000;&lt;br /&gt;
close;&lt;br /&gt;
} &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;PLAYTIME&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-1 = Quest not started (not in quest log)&lt;br /&gt;
0  = the time limit has not yet been reached&lt;br /&gt;
1  = the time limit has not been reached but the quest is marked as complete&lt;br /&gt;
2  = the time limit has been reached&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If parameter &amp;quot;HUNTING&amp;quot; is supplied:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-1 = Quest not started (not in quest log)&lt;br /&gt;
0 = you haven't killed all of the target monsters and the time limit has not been reached.&lt;br /&gt;
1 = you haven't killed all of the target monsters but the time limit has been reached.&lt;br /&gt;
2 = you've killed all of the target monsters&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example | Hunting ===&lt;br /&gt;
&amp;lt;pre&amp;gt;prontera,xx,xx,4	script	CheckQuest	51,{&lt;br /&gt;
&lt;br /&gt;
if (checkquest(65000,HUNTING) == -1) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest not Started&amp;quot;,&lt;br /&gt;
close;&lt;br /&gt;
} else if (checkquest(65000,HUNTING) == 0) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;You haven't killed all of the target monsters and the time limit has not been reached.&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if (checkquest(65000,HUNTING) == 1) {&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;You haven't killed all of the target monsters but the time limit has been reached.&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
} else if (checkquest(65000,HUNTING) == 2) {&lt;br /&gt;
completequest 65000;&lt;br /&gt;
set zeny,zeny+100;      //Zeny Reward&lt;br /&gt;
getitem 501,1;          // Item Reward&lt;br /&gt;
mes &amp;quot;[Jelly]&amp;quot;;&lt;br /&gt;
mes &amp;quot;Quest Finished&amp;quot;;&lt;br /&gt;
close;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show Event ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*showevent &amp;lt;state&amp;gt;, &amp;lt;color&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Show a colored mark in the mini-map like &amp;quot;viewpoint&amp;quot; and an emotion on top &lt;br /&gt;
of a NPC. This is used to indicate that a NPC has a quest or an event to &lt;br /&gt;
certain player/s. &lt;br /&gt;
&lt;br /&gt;
state can be:&lt;br /&gt;
	0 = disable ( Used to disable and remove the mark and the emotion from &lt;br /&gt;
		the NPC. )&lt;br /&gt;
	1 = exclamation emotion ( Used to show an important quest event to &lt;br /&gt;
		certain player. )&lt;br /&gt;
	2 = interrogation emotion ( Used to show an non-important quest event &lt;br /&gt;
		to certain player. )&lt;br /&gt;
Other value may cause client crashes.&lt;br /&gt;
&lt;br /&gt;
color can be:&lt;br /&gt;
	0 = yellow &amp;quot;Quest&amp;quot;&lt;br /&gt;
	1 = orange &amp;quot;Job&amp;quot;&lt;br /&gt;
	2 = green &amp;quot;Event&amp;quot;&lt;br /&gt;
	3 = an MVP flag&lt;br /&gt;
Other values show a transparent mark in the mini-map.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Increasing Max Quest DB ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trunk/src/map/quest.h &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find this line and increase the value.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recompile, Cheers!&lt;br /&gt;
&lt;br /&gt;
(If you don't know how to recompile click [[Compiling|Here!]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>GmOcean</name></author>	</entry>

	</feed>