<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
	<title>Scripting Academy</title>
	<link>http://herc.ws/board/blog/29-scripting-academy/</link>
	<description>Scripting Academy Syndication</description>
	<pubDate>Wed, 13 Jan 2016 02:08:24 +0000</pubDate>
	<webMaster>haru@dotalux.com (Hercules Board)</webMaster>
	<generator>IP.Blog</generator>
	<ttl>60</ttl>
	<item>
		<title>Disguise Event Script</title>
		<link>http://herc.ws/board/blog/29/entry-101-disguise-event-script/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Disguise Event Script <sup class='bbc'>( 3 Parts )</sup></strong></span><br />Due, to the possibility of this script being removed from Hercules' main repository, I'm going to write a guide for this script. Well, that and I lack the imagination to write up a new script from scratch right now @.@;<br />Because this post is tremendously long, each part has been wrapped in spoiler tags to help make it easier to follow.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;"><br />Okay, so this script is going to be our first event tutorial, and advanced script (Am I being biased? Lol).<br />This event, will have an NPC disguise itself at certain times during the day, and players simply need to shout out the monsters name.<br />Get it correct, they get a prize. Get it wrong, just keep trying! Sounds simple right? Well, it's a bit harder than it seems, hence the reason it's an advanced script.<br />Now, through out this guide, I'll be adding little notations within the scripting-code. This will help keep track of why we set something to what. And what exactly we're trying to do.<br /><br />So let's get started. Let's start off with a normal NPC header:<pre class='prettyprint lang-auto linenums:0'>
prontera,160,155,4	script	Disguise Event	4_M_NFDEADMAN,{
</pre><br />Alright, before we do anything in the script, we are going to add a check. This check will check to see if the <em class='bbc'><strong class='bbc'>event is currently on</strong></em> and if the <em class='bbc'><strong class='bbc'>player is a GM or not</strong></em>. Followed by an abrupt <strong class='bbc'>end;</strong>, if the player isn't a GM or the event is on.<br />To get the GM level of the player we'll use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3113' class='bbc_url' title='External link' rel='nofollow external'>getgmlevel()</a>, and we'll use it to check against the variable <em class='bbc'><strong class='bbc'>.gm_level</strong></em>, which we haven't set yet. But that's okay because we will. Also, to check whether the even is on or off, we'll simply check if the variable <em class='bbc'><strong class='bbc'>.event_onoff</strong></em> is <em class='bbc'><strong class='bbc'>0</strong></em> or not.<br />Again, this variable hasn't been set yet, but we will later. So let's add the check in:<pre class='prettyprint lang-auto linenums:0'>
if (getgmlevel() &lt; .gm_level && .event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Okay, we did that because we didn't want player's talking to the NPC during the event, because it would give them an unfair disadvantage to have the dialogue box up.<br />So now that we got the initial check out of the way. Let's start off by adding <em class='bbc'><strong class='bbc'>2 lines of dialogue</strong></em>, the first saying the<em class='bbc'><strong class='bbc'> npc's <span style='color: #0000ff'>name</span></strong></em>, which we will <em class='bbc'><strong class='bbc'>store into a variable</strong></em> at the same time. And the second, being a simple <em class='bbc'><strong class='bbc'>"Welcome. How may I help you?"</strong></em><br />So let's do that:<pre class='prettyprint lang-auto linenums:0'>
mes .@n$ = "&#91;^0000FFDisguise NPC^000000]",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Welcome. How may I help you?";
</pre><br />Alright, now we are going to use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1226' class='bbc_url' title='External link' rel='nofollow external'>next;</a> so we can start with more dialogue on the next page. Followed by another mes command, with the NPC's name again:<pre class='prettyprint lang-auto linenums:0'>
next;
mes .@n$;
</pre><br />Alright, the reason we did that, is because we are going to prompt the player with a menu now. And we don't want to have to type <em class='bbc'><strong class='bbc'>next; mes .@n$;</strong></em> after each and every option they choose. So we do it before, so all options will take advantage of it. Saves us time.<br />Now then, this menu will have <em class='bbc'><strong class='bbc'>2 options, 4 if your a GM</strong></em>. The <em class='bbc'><strong class='bbc'>first option</strong></em> will be <em class='bbc'><strong class='bbc'>"Information"</strong></em>, the <em class='bbc'><strong class='bbc'>second & third options</strong></em> will only be <em class='bbc'><strong class='bbc'>available to GMs</strong></em>, which are to <em class='bbc'><strong class='bbc'>"Turn the Event ON/OFF"</strong></em> and <em class='bbc'><strong class='bbc'>"Event Settings"</strong></em> and the <em class='bbc'><strong class='bbc'>fourth option</strong></em> will be <em class='bbc'><strong class='bbc'>"Nothing, just passing by."</strong></em><br />We'll be using <em class='bbc'><strong class='bbc'>switch(select)</strong></em> for our menu, and to separate the GM options from the normal player options, we'll be using a conditional check <em class='bbc'><strong class='bbc'>(?: )</strong></em> to see if they have a high enough GM level to see those options. Also, since the option to turn the event on or off, can do both, we want to properly display whether or not to <em class='bbc'><strong class='bbc'>turn it <span style='color: #ff0000'>off</span>, if it's <span style='color: #0000ff'>on</span>. Or <span style='color: #0000ff'>on</span> if it's <span style='color: #ff0000'>off</span>.</strong></em> To do that we'll use another conditional check <em class='bbc'><strong class='bbc'>(?: )</strong></em>, again checking if the variable <em class='bbc'><strong class='bbc'>.event_onoff</strong></em> is <em class='bbc'><strong class='bbc'>0</strong></em> or not.<br />So let's do it:<pre class='prettyprint lang-auto linenums:0'>
switch( select("Information", ((getgmlevel() &gt;= .gm_level)?"Turn Event &#91;"+(.event_onoff?"^FF0000OFF":"^0000FFON")+"^000000]:Event Settings":":"), "Nothing, just passing by.") ) {
</pre><br />Okay, that was a little long winded. But at least we did it. Now then, let's start off with <em class='bbc'><strong class='bbc'>case 1:</strong></em> and tell the players about the event. Once you're done telling them what the event does, we'll use the command <em class='bbc'><strong class='bbc'>break;</strong></em> to bring them out of that code block.<br />So let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "This event is quite simple. At the ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"start of the event, I will disguise",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"myself as a random monster.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"You have to shout that monster's",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name out loud.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "If you are correct, you will",
	&nbsp;&nbsp;&nbsp;&nbsp;"receive a prize. If not, keep ",
	&nbsp;&nbsp;&nbsp;&nbsp;"trying! That's all that there is to ",
	&nbsp;&nbsp;&nbsp;&nbsp;"this event.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
</pre><br />Alright, that was simple. Now we're going to start working on <em class='bbc'><strong class='bbc'>case 2:</strong></em> which is only for GMs and deals with turning the event on or off.<br />So we'll start with a dialogue that <em class='bbc'><strong class='bbc'>asks the GM if they want to</strong></em> <em class='bbc'><strong class='bbc'>turn the event <span style='color: #ff0000'>OFF</span> if it's <span style='color: #0000ff'>on</span>, or <span style='color: #0000ff'>ON</span> if it's <span style='color: #ff0000'>off</span>.</strong></em> To do so we'll need to use another conditional check <em class='bbc'><strong class='bbc'>(?: )</strong></em> to check against the variable <em class='bbc'><strong class='bbc'>.event_onoff</strong></em> again.<br />So let's do it:<pre class='prettyprint lang-auto linenums:0'>
case 2:
&nbsp;&nbsp;&nbsp;&nbsp;mes "Are you sure you want to turn the ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"event &#91;"+ (.event_onoff?"^FF0000OFF":"^0000FFON") +"^000000]";
</pre><br />Alright, now we'll prompt them with a menu of either <em class='bbc'><strong class='bbc'>Yes or No</strong></em>. And if the say <em class='bbc'><strong class='bbc'>No, we'll close the script.</strong></em><br />So yet again, let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (select("Yes", "No") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Well, that was easy! But we're not done yet. Now it's time to actually turn the event on or off.<br />So we'll start by adding a check to see if the event is currently on or not. To do that, we'll see if the variable <em class='bbc'><strong class='bbc'>.event_onoff is set to anything besides 0.</strong></em> Simple enough:<pre class='prettyprint lang-auto linenums:0'>
if (.event_onoff) {
</pre><br />Now, this means the event is on. So we'll proceed to turn it off and announce to the whole server that a GM turned the event off:<br />Let's get to it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.event_onoff = 0;
&nbsp;&nbsp;&nbsp;&nbsp;announce "A GM has decided to turn the Disguise Event off. As a result no further prizes will be rewarded.",bc_all | bc_blue;
</pre><br />Okay, now the next part probably won't make much sense to you since you don't know how the event works at it's <em class='bbc'><strong class='bbc'>core</strong></em>, and I do. But I'll try my best to explain. Since the script works by having players use global chat to answer, we need to delete that answer from working.<br />To do that, we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7553' class='bbc_url' title='External link' rel='nofollow external'>deletepset &lt;set number&gt;;</a> and we'll use the <em class='bbc'><strong class='bbc'>number 1</strong></em>.<br />additionally, we need to <em class='bbc'><strong class='bbc'>change the NPC's display back to normal</strong></em>. To do that we use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6305' class='bbc_url' title='External link' rel='nofollow external'>setnpcdisplay("&lt;npc name&gt;", "&lt;display name&gt;", &lt;class id&gt;, &lt;size&gt;)</a><br />Also, the event uses a timer to manage when it disguises into a new monster. So we need to stop that timer since we turned the event off.<br />To do so we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6356' class='bbc_url' title='External link' rel='nofollow external'>stopnpctimer { "&lt;NPC name&gt;" {, &lt;Detach Flag&gt;} }</a>;<br />lastly, we'll close the script and the check.<br />So let's add those in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;deletepset 1;
&nbsp;&nbsp;&nbsp;&nbsp;stenpcdisplay "Disguise Event", 4_M_NFDEADMAN;
&nbsp;&nbsp;&nbsp;&nbsp;stopnpctimer;
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Okay, now we finished turning off the event. Now we need to turn the event on. Thankfully, we'll be handling that else where. For now, we are just going to make the GM click a <em class='bbc'><strong class='bbc'>close button</strong></em>, which will start the event for us later.<br />To do so we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1261' class='bbc_url' title='External link' rel='nofollow external'>close2;</a><br />as for turning the event on, we'll do that somewhere else in the script, so let's just make them go to it, using the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1683' class='bbc_url' title='External link' rel='nofollow external'>callsub &lt;label&gt;{,&lt;argument&gt;,...&lt;argument&gt;};</a> for the label, we'll use <em class='bbc'><strong class='bbc'>iStartEvent:</strong></em><br />lastly, we'll end the script with <em class='bbc'><strong class='bbc'>end;</strong></em> this time we can do this, because we used <em class='bbc'><strong class='bbc'>close2;</strong></em> first.<br />So lets add that in:<pre class='prettyprint lang-auto linenums:0'>
close2;
callsub iStartEvent;
end;
</pre><br />Awesome, we just finished <em class='bbc'><strong class='bbc'>case 2:</strong></em>, let's just jump straight into <em class='bbc'><strong class='bbc'>case 3:</strong></em><br />We'll start by having the <em class='bbc'><strong class='bbc'>npc say "Pick a setting to modify."</strong></em>, followed by a <strong class='bbc'>next;</strong> command, then by the <em class='bbc'><strong class='bbc'>npc saying it's name</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
case 3:
&nbsp;&nbsp;&nbsp;&nbsp;mes "Pick a setting to modify.";
&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
</pre><br />Now, we need to make a menu with 3 options inside. Those options are: <em class='bbc'><strong class='bbc'>"Monster Display", "Number of Rounds" </strong></em>and<em class='bbc'><strong class='bbc'> "Prize Settings"</strong></em>, again using <em class='bbc'><strong class='bbc'>switch()</strong></em>. I'd say it's pretty safe for you to assume by now, that if the <em class='bbc'><strong class='bbc'>menu has more than 2 options</strong></em>, we are using <em class='bbc'><strong class='bbc'>switch()</strong></em>, else we'd just use <em class='bbc'><strong class='bbc'>if(select())</strong></em><br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
switch(select("Monster Display", "Number of Rounds", "Prize Settings")) {
</pre><br />Well, I know I said we were almost done with our cases, but looks like we just got 3 more. No matter we'll just take care of them 1by1. We'll start with <em class='bbc'><strong class='bbc'>case 1:</strong></em> (obviously), which deals with choosing a disguise rule. For now we'll, simply have a dialogue saying <em class='bbc'><strong class='bbc'>"Choose a disguise rule"</strong></em>, followed by a <em class='bbc'><strong class='bbc'>next;</strong></em> command:<pre class='prettyprint lang-auto linenums:0'>
case 1:
&nbsp;&nbsp;&nbsp;&nbsp;mes "Choose a disguise rule.";
&nbsp;&nbsp;&nbsp;&nbsp;next;
</pre><br />Okay, now this script by default only has <em class='bbc'><strong class='bbc'>2 disguise options</strong></em>, <em class='bbc'><strong class='bbc'>All monsters or MVPs only</strong></em>, but the way I wrote <em class='bbc'>the script will allow for more options should you decide to add more options</em>. So, instead of a normal <em class='bbc'><strong class='bbc'>if(select()) for 2 options</strong></em>, we're going to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7872' class='bbc_url' title='External link' rel='nofollow external'>implode(&lt;string_array&gt;{,&lt;glue&gt;})</a> in combination with the <em class='bbc'><strong class='bbc'>select;</strong></em> command. For the string array we'll use this variable: <em class='bbc'><strong class='bbc'>.disguise_desc$</strong></em>, for the glue we'll use <strong class='bbc'>":" </strong>just as I wrote it, quotations too.<br />Additionally, we'll be setting the variable: <em class='bbc'><strong class='bbc'>.disguise_option</strong></em> to whatever the <em class='bbc'><strong class='bbc'>GM selects, -1</strong></em>. This is because <em class='bbc'><strong class='bbc'>arrays start at the 0th element</strong></em>, while <em class='bbc'><strong class='bbc'>menu's start at the 1st.</strong></em><br />So let's add this in:<pre class='prettyprint lang-auto linenums:0'>
.disguise_option = select(implode(.disguise_desc$, ":")) - 1;
</pre><br />Okay, now the last thing we need to do, before we move on to <em class='bbc'><strong class='bbc'>case 2:</strong></em> again, is tell the Gm that they the <span style='color: #0000ff'><em class='bbc'><strong class='bbc'>disguise rule</strong></em></span> has been set. Followed by a <em class='bbc'><strong class='bbc'>break;</strong></em> to get them out of the code block. To get the exact rule they chose, we'll use our variable we set above, as the element for the array, we used for the menu.<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"The Disguise Rule has been set:",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"----&gt; &#91;"^0000FF"+ .disguise_desc$&#91;.disguise_option] +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;break;
</pre><br />Alright, now we can start on <em class='bbc'><strong class='bbc'>case 2:</strong></em> (again). This will be a quick one. We'll, start by having the npc tell the GM to input how many rounds they want the event to last, and how many rounds the even currently will last for, which we'll determine by using the variable <em class='bbc'><strong class='bbc'>.rounds</strong></em><pre class='prettyprint lang-auto linenums:0'>
case 2:
&nbsp;&nbsp;&nbsp;&nbsp;mes "Input the number of rounds you want",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"the event to last.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Current number of rounds: &#91;^0000FF"+ .rounds +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;next;
</pre><br />Okay, now we need to have the GM input how much rounds they want the event to last. But, we are going to <em class='bbc'><strong class='bbc'>limit how much rounds</strong></em> it can have <em class='bbc'><strong class='bbc'>maximium</strong></em> as well as <em class='bbc'><strong class='bbc'>minimum</strong></em>.<br />To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1561' class='bbc_url' title='External link' rel='nofollow external'>input(&lt;variable&gt;{,&lt;min&gt;{,&lt;max&gt;}})</a><br />we'll use a simple <em class='bbc'><strong class='bbc'>scope variable for the variable</strong></em>. For <em class='bbc'><strong class='bbc'>min value, we'll use the variable .min</strong></em> and for the <em class='bbc'><strong class='bbc'>max value, we'll use the variable .max</strong></em>. Of course these will be set later.<br />Now, for us we don't care if the GM sets it to anything within that range, but <strong class='bbc'><em class='bbc'>if they try to put something higher or lower</em></strong>, we'll simply <em class='bbc'><strong class='bbc'>set it to the minimum in both cases</strong></em>. This makes it easier for us.<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (input(.@rounds,.min,.max)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@rounds = .min;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br /><br />Now, the last thing we need to do before we can work on <em class='bbc'><strong class='bbc'>case 3:</strong></em> for the second time, is <em class='bbc'><strong class='bbc'>set the variable .rounds, to the number the GM inputted</strong></em>. Then <em class='bbc'><strong class='bbc'>tell the GM what the rounds have been changed to</strong></em>, followed by <em class='bbc'><strong class='bbc'>break;</strong></em> to get them out of the code block.<br />Real quick, let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.rounds = .@rounds;
&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"The number of rounds has been",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"changed to "+ .rounds +".";
&nbsp;&nbsp;&nbsp;&nbsp;break;
</pre><br />Okay, now it's time for the second iteration of <em class='bbc'><strong class='bbc'>case 3:</strong></em>. Here, we'll be handling the prize settings. So we'll start off with <em class='bbc'><strong class='bbc'>telling the GM to input the item id of the prize, along with what the current prize is</strong></em>, which we can find by using the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2775' class='bbc_url' title='External link' rel='nofollow external'>getitemname(&lt;item id&gt;)</a> in combination with the variable <em class='bbc'><strong class='bbc'>.prize_item</strong></em>.<br />Followed by a <strong class='bbc'>next;</strong> command, and lastly top it off with the actual <em class='bbc'><strong class='bbc'>input</strong></em> of the <em class='bbc'><strong class='bbc'>item id</strong></em>, this time, with <em class='bbc'><strong class='bbc'>no minimum or maximum setting</strong></em>.<br />Let's do this, scripting time:<pre class='prettyprint lang-auto linenums:0'>
case 3:
&nbsp;&nbsp;&nbsp;&nbsp;mes "Tell me the Item ID of the prize ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"to be given each round.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Current item: &#91;^0000FF"+ getitemname(.prize_item) +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;input .@prize;
</pre><br />Now, let's have the <em class='bbc'><strong class='bbc'>npc say it's name again</strong></em>. Followed, by <em class='bbc'><strong class='bbc'>checking to see if the item they entered exists or not</strong></em>. To do that we'll use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2775' class='bbc_url' title='External link' rel='nofollow external'>getitemname(&lt;item id&gt;)</a> and we'll check it against <em class='bbc'><strong class='bbc'>"null"</strong></em>. Because <em class='bbc'><strong class='bbc'>if an item doesn't exist that command will return null as it's name</strong></em>. If the name is <em class='bbc'><strong class='bbc'>null</strong></em>, we'll have the <em class='bbc'><strong class='bbc'>npc tell them the item doesn't exist, please try again</strong></em>. And then <em class='bbc'><strong class='bbc'>close the script and check</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (getitemname(.@prize) == "null") {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "That item does not exist.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Please try again.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Now, since the item does exist, we're going to <em class='bbc'><strong class='bbc'>set the variable .prize_item to what they entered</strong></em>. Then we're going to have the<em class='bbc'><strong class='bbc'> npc tell them to input the amount they want to give away</strong></em>, followed by the <strong class='bbc'>next;</strong> command. Have the <em class='bbc'><strong class='bbc'>npc say it's name</strong></em> yet again. Then, we'll have them <em class='bbc'><strong class='bbc'>input the amount they want to give away</strong></em>, but keep it <em class='bbc'><strong class='bbc'>limited between 1 and 10,000</strong></em>. And if it's <em class='bbc'><strong class='bbc'>lower or higher,</strong></em> we'll <em class='bbc'><strong class='bbc'>set it to 1</strong></em>. We'll also <em class='bbc'><strong class='bbc'>tell them</strong></em> that the <em class='bbc'><strong class='bbc'>amount they used is invalid, and we set it to 1</strong></em>. Then to top it all off, we'll use the <strong class='bbc'>next;</strong> command again, followed by the <em class='bbc'><strong class='bbc'>npc saying it's name</strong></em> yet another time, finally <em class='bbc'><strong class='bbc'>closing off that check</strong></em>.<br />Whoo picking up the pace! Let's do this, scripting time:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.prize_item = .@prize;
&nbsp;&nbsp;&nbsp;&nbsp;mes "Input the amount to be given.";
&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;if (input(.@amount,1,10000)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "That amount is invalid.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Using a default amount of 1.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Awesome, wasn't that easy? Now then, let's <em class='bbc'><strong class='bbc'>set the variable .prize_amount to what they entered</strong></em>. Then we'll have the <em class='bbc'><strong class='bbc'>npc tell them that the amount was success fully changed</strong></em>. Followed by <em class='bbc'><strong class='bbc'>what the new prize is and how much of that prize players will get</strong></em>. And put a <strong class='bbc'>break;</strong> there to get out of the code block.<br />Let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.prize_amount = .@amount;
&nbsp;&nbsp;&nbsp;&nbsp;mes "Successfully changed prize.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Prize: "+ .prize_amount +"x &#91;^0000FF"+ getitemname(.prize_item) +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;break;
</pre><br />Alright, now let's close that <em class='bbc'><strong class='bbc'>switch()</strong></em> segment, and follow it with a <strong class='bbc'>break;</strong> since that's the end of our first <em class='bbc'><strong class='bbc'>case 3:</strong></em><br />Simple enough:<pre class='prettyprint lang-auto linenums:0'>
}
break;
</pre><br />Lastly, we'll close off the first <em class='bbc'><strong class='bbc'>switch()</strong></em> segment we used and then end it with <em class='bbc'><strong class='bbc'>close;</strong></em> because all of our cases are going to end up here. Including if the player chose, <em class='bbc'><strong class='bbc'>"Nothing, just passing by."</strong></em>. Forgot about that one didn't you? Well, we're going to care of it now:<pre class='prettyprint lang-auto linenums:0'>
}
close;
</pre><br />Alright, that takes care of the main body! Right now your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,160,155,4&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;Disguise Event&nbsp;&nbsp;&nbsp;&nbsp;4_M_NFDEADMAN,{
if (getgmlevel() &lt; .gm_level && .event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
mes .@n$ = "&#91;^0000FFDisguise NPC^000000]",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Welcome. How may I help you?";
next;
mes .@n$;
switch(select("Information", ((getgmlevel() &gt;= .gm_level)?"Turn Event &#91;"+(.event_onoff?"^FF0000OFF":"^0000FFON")+"^000000]:Event Settings":":"), "Nothing, just passing by.")) {
&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "This event is quite simple. At the ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"start of the event, I will disguise",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"myself as a random monster.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"You have to shout that monster's",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name out loud.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "If you are correct, you will",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"receive a prize. If not, keep ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"trying! That's all that there is to ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"this event.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Are you sure you want to turn the ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"event &#91;"+(.event_onoff?"^FF0000OFF":"^0000FFON")+"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (select("Yes", "No") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (.event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.event_onoff = 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;announce "A GM has decided to turn the Disguise Event off. As a result no further prizes will be rewarded.",bc_all | bc_blue;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deletepset 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setnpcdisplay "Disguise Event", 4_M_NFDEADMAN;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stopnpctimer;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callsub iStartEvent;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;

&nbsp;&nbsp;&nbsp;&nbsp;case 3:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Pick a setting to modify.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch(select("Monster Display", "Number of Rounds", "Prize Settings")) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Choose a disguise rule.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.disguise_option = select(implode(.disguise_desc$), ":")) - 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"The Disguise Rule has been set:",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"----&gt; &#91;^0000FF"+ .disguise_desc$&#91;.disguise_option] +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Input the number of rounds you want",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"the event to last.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Current number of rounds: &#91;^0000FF"+ .rounds +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (input(.@rounds,.min,.max)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@rounds = .min;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.rounds = .@rounds;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"The number of rounds has been",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"changed to "+ .rounds +".";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 3:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Tell me the Item ID of the prize ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"to be given each round.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Current item: &#91;^0000FF"+ getitemname(.prize_item) +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input .@prize;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (getitemname(.@prize) == "null") {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "That item does not exist.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Please try again.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.prize_item = .@prize;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Input the amount to be given.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (input(.@amount,1,10000)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "That amount is invalid.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Using a default amount of 1.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.prize_amount = .@amount;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Successfully changed prize.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Prize: "+ .prize_amount +"x &#91;^0000FF"+ getitemname(.prize_item) +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
}
close;
</pre>And that's it for the <em class='bbc'><strong class='bbc'>main body</strong></em> of our script as well as <strong class='bbc'><em class='bbc'>Part 1</em></strong>. In <em class='bbc'><strong class='bbc'>Part 2</strong></em>, we'll work on the <em class='bbc'><strong class='bbc'>configuration part</strong></em> of the script. This is mainly going to be under the <em class='bbc'><strong class='bbc'>OnInit:</strong></em> label.</div></div>
</div><hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;"><br />Alright, so in <em class='bbc'><strong class='bbc'>Part 1</strong></em>, we did the <em class='bbc'><strong class='bbc'>main body</strong></em> of the script, which mainly involved when a player talks to the npc and when a GM talks to the npc. However, we used quite a few variables that haven't been set yet. In <em class='bbc'><strong class='bbc'>Part 2</strong></em>, the <em class='bbc'><strong class='bbc'>configuration part</strong></em>, we'll actually set those. So let's get to it.<br /><br />Now, as with most configurations let's create our <em class='bbc'><strong class='bbc'>OnInit:</strong></em> label.<pre class='prettyprint lang-auto linenums:0'>
OnInit:
</pre><br />In here we are going to set up quite a few things. It's an event script after all. So let's jump into this.<br />Firstly, we want this script to only allow <em class='bbc'><strong class='bbc'>GMs level 60</strong></em> or higher to manually turn the event on. So we'll make a variable for that. We also want the event to last <em class='bbc'><strong class='bbc'>10 rounds</strong></em>, so we'll make a variable for that as well:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.gm_level = 60;
&nbsp;&nbsp;&nbsp;&nbsp;.rounds = 10;
</pre><br />Now, since this is a tutorial, we are going to set the prize they earn for getting the answer correct, to <em class='bbc'><strong class='bbc'>10 Red Potions</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.prize_item = Red_Potion;
&nbsp;&nbsp;&nbsp;&nbsp;.prize_amount = 10;
</pre><br />Okay, so now we are going to <em class='bbc'><strong class='bbc'>set 2 variables</strong></em>, called <em class='bbc'><strong class='bbc'>.min</strong></em> and <em class='bbc'><strong class='bbc'>.max</strong></em> to <em class='bbc'><strong class='bbc'>3</strong></em> and <em class='bbc'><strong class='bbc'>10 respectively</strong></em>, this will serve as the amount the GM is able to choose in the main body of the script:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.min = 3;
&nbsp;&nbsp;&nbsp;&nbsp;.max = 10;
</pre><br />Now, since this event involves the NPC transforming into all kinds of monsters, let's setup a toggle-able option. That will allow the NPC to either transform into <em class='bbc'><strong class='bbc'>all monsters</strong></em>, or just <em class='bbc'><strong class='bbc'>MVPs</strong></em>. The reason being, not everyone knows the names of every single monster, and for good reason. There's like 2 thousand of them. However, chances are they know most of the MVPs. So, let's set a variable up to determine what we will use. Let's also create an array with the description for those options:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;// What disguise rule, the NPC should follow.
&nbsp;&nbsp;&nbsp;&nbsp;// 0 = Disguise as all monsters | 1 = Disguise as MVPs only
&nbsp;&nbsp;&nbsp;&nbsp;.disguise_option = 1;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .disguise_desc$&#91;0],"Disguise as all monsters.", "Disguise as MVPs only.";
</pre><br />Now, you'll see I set the option to <em class='bbc'><strong class='bbc'>1</strong></em>, this <em class='bbc'><strong class='bbc'>means</strong></em> that I've set the script to <em class='bbc'><strong class='bbc'>only disguise as MVPs</strong></em>.<br />Okay, now since player's need to be able to see what the NPC transform into, let's add an option to make an area surrounding the NPC un-walkable. This will prevent players from smothering the NPC and blocking it's view from other people:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;// Whether or not to block surrounding cells from players during event.
&nbsp;&nbsp;&nbsp;&nbsp;// 0 = Disabled, 1 = 1x1 | 2 = 2x2 | 9 = 9x9
&nbsp;&nbsp;&nbsp;&nbsp;// Default: 0 (Disabled).
&nbsp;&nbsp;&nbsp;&nbsp;.block_cells = 3;
</pre><br />Alright, we're almost done with adding configurations, but we've still got a few more.<br />Now, let's add <em class='bbc'><strong class='bbc'>2 variables</strong></em> that deal with <em class='bbc'><strong class='bbc'>timing</strong></em>. The first being, how long does the <em class='bbc'><strong class='bbc'>NPC wait before officially starting the event</strong></em>. For this example, we're going to go with <em class='bbc'><strong class='bbc'>3 minutes</strong></em>. And the second variable, determining the <em class='bbc'><strong class='bbc'>length of intermission before the NPC transform into another monster, <em class='bbc'><strong class='bbc'>10 seconds</strong></em></strong></em>.<br />Let's add those in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;// Minutes before event starts
&nbsp;&nbsp;&nbsp;&nbsp;.start_delay = 3;

&nbsp;&nbsp;&nbsp;&nbsp;// Seconds of intermission before transforming again
&nbsp;&nbsp;&nbsp;&nbsp;.change_delay = 10;
</pre><br />Alright, now there are just 2 more configurations to add. The first being an array, that stores all the MVPs that we want the NPC to use as a disguise.<br />So let's create that array:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;// MVP List
&nbsp;&nbsp;&nbsp;&nbsp;setarray .MVP&#91;0], OSIRIS, BAPHOMET, DOPPELGANGER, MISTRESS, GOLDEN_BUG, ORK_HERO, DRAKE, EDDGA, MAYA, MOONLIGHT,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PHARAOH, PHREEONI, ORC_LORD, KNIGHT_OF_WINDSTORM, GARM, DARK_LORD, TURTLE_GENERAL, LORD_OF_DEATH, DRACULA, EVENT_BAPHO,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DARK_SNAKE_LORD, INCANTATION_SAMURAI, PORING_V, AMON_RA, TAO_GUNKA, RSX_0806, BACSOJIN_, B_SEYREN, B_EREMES, B_HARWORD,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B_MAGALETA, B_SHECIL, B_KATRINN, B_YGNIZEM, APOCALIPS_H, LADY_TANEE, THANATOS, DETALE, KIEL_, RANDGRIS,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GLOOMUNDERNIGHT, KTULLANUX, ATROCE, G_MAGALETA_, IFRIT, FALLINGBISHOP, BEELZEBUB_, GOPINICH, MOROCC_, KUBLIN,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S_NYDHOG, BOITATA;
</pre><br />Okay, now keep in mind there are a few MVPs that only spawn in Renewal Ragnarok. And since I couldn't possibly know what version of RO you're running, let's add a check to add those MVPs in, only if the server is in renewal mode.<br />To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4028' class='bbc_url' title='External link' rel='nofollow external'>checkre(&lt;type&gt;)</a>. We are going to be checking against type <em class='bbc'><strong class='bbc'>0</strong></em>. Now, when we add the MVPs to the array, we need to add them starting at the end of the array. So we'll use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2340' class='bbc_url' title='External link' rel='nofollow external'>getarraysize(&lt;array name&gt;)</a> to determine where the end is. Beats having to count all those MVPs above.<br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if(checkre(0)){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setarray .MVP&#91;getarraysize(.MVP)], QUEEN_SCARABA, LOST_DRAGON, LEAK, I_QUEEN_SCARABA;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, now it's time to add the last and final configuration for the script. The monster <em class='bbc'><strong class='bbc'>blacklist</strong></em>. This will serve as a list of monster's you don't want the NPC to disguise as. We need to do this, because there are just some monsters that exist which don't spawn naturally. And we are going to weed those out! So what we're going to do, to put it simply, is we are going to loop through all the existing monsters, and check to see if they have any drops. This is because 90%+ of the monsters in ragnarok that spawn naturally have drops.<br />But, since there are well over a thousand monsters, we need to prevent an infinity loop. To do so we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2169' class='bbc_url' title='External link' rel='nofollow external'>freeloop(&lt;toggle&gt;)</a> with a value of <strong class='bbc'><em class='bbc'>1</em></strong> before we actually start the loop.<br />Lastly, to check to see if the monster drops any items we'll be using this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3565' class='bbc_url' title='External link' rel='nofollow external'>getmobdrops(&lt;mob id&gt;)</a>. So let's create that loop:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;// DO NOT CHANGE THE BELOW !!
&nbsp;&nbsp;&nbsp;&nbsp;// Since this is a custom event, it should be made to support custom monsters !!
&nbsp;&nbsp;&nbsp;&nbsp;// To increase mosnter range, simply increase the value of .last_mobid
&nbsp;&nbsp;&nbsp;&nbsp;// Default: 5000
&nbsp;&nbsp;&nbsp;&nbsp;.last_mobid = 5000;
&nbsp;&nbsp;&nbsp;&nbsp;freeloop(1);
&nbsp;&nbsp;&nbsp;&nbsp;for( .@i = SCORPION; .@i &lt; .last_mobid; .@i++ ) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( !getmobdrops( ( .@i ) ) ) {
	&nbsp;&nbsp;&nbsp;&nbsp;.blacklist&#91;.@i] = .@i;
	}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;freeloop(0);
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre>Now, this is probably still confusing so let me break down what we just did:<br />1. We set a variable <em class='bbc'><strong class='bbc'>.last_mobid</strong></em> to <em class='bbc'><strong class='bbc'>5000</strong></em>. This is well above the final monster in the game. This is just so we don't have update the script every time Ragnarok releases new content. This will give you <strong class='bbc'>years</strong> of leeway, before you have to update the script.<br />2. We started the loop off at <em class='bbc'><strong class='bbc'>SCORPION</strong></em>, because he is the first mob.<br />3. We checked to see if the <em class='bbc'><strong class='bbc'>mob_id</strong></em> we were on had any drops. If it didn't it got added to the black list.<br />4. Since, each monster has a <em class='bbc'><strong class='bbc'>unique ID</strong></em>, we simply used their <em class='bbc'><strong class='bbc'>ID number</strong></em> as the element of the array, and set it to itself.<br />5. We used <strong class='bbc'>freeloop(0);</strong> to stop the free looping, since it's no longer needed.<br />6. end; because we are <strong class='bbc'>FINALLY</strong> done with the <em class='bbc'><strong class='bbc'>OnInit:</strong></em> label.<br /><br />That's the end of Part 2, right now your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,160,155,4&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;Disguise Event&nbsp;&nbsp;&nbsp;&nbsp;4_M_NFDEADMAN,{
if (getgmlevel() &lt; .gm_level && .event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
mes .@n$ = "&#91;^0000FFDisguise NPC^000000]",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Welcome. How may I help you?";
next;
mes .@n$;
switch(select("Information", ((getgmlevel() &gt;= .gm_level)?"Turn Event &#91;"+(.event_onoff?"^FF0000OFF":"^0000FFON")+"^000000]:Event Settings":":"), "Nothing, just passing by.")) {
&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "This event is quite simple. At the ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"start of the event, I will disguise",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"myself as a random monster.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"You have to shout that monster's",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name out loud.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "If you are correct, you will",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"receive a prize. If not, keep ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"trying! That's all that there is to ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"this event.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Are you sure you want to turn the ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"event &#91;"+(.event_onoff?"^FF0000OFF":"^0000FFON")+"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (select("Yes", "No") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (.event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.event_onoff = 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;announce "A GM has decided to turn the Disguise Event off. As a result no further prizes will be rewarded.",bc_all | bc_blue;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deletepset 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setnpcdisplay "Disguise Event", 4_M_NFDEADMAN;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stopnpctimer;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callsub iStartEvent;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;

&nbsp;&nbsp;&nbsp;&nbsp;case 3:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Pick a setting to modify.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch(select("Monster Display", "Number of Rounds", "Prize Settings")) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Choose a disguise rule.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.disguise_option = select(implode(.disguise_desc$), ":")) - 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"The Disguise Rule has been set:",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"----&gt; &#91;^0000FF"+ .disguise_desc$&#91;.disguise_option] +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Input the number of rounds you want",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"the event to last.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Current number of rounds: &#91;^0000FF"+ .rounds +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (input(.@rounds,.min,.max)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@rounds = .min;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.rounds = .@rounds;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"The number of rounds has been",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"changed to "+ .rounds +".";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 3:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Tell me the Item ID of the prize ",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"to be given each round.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Current item: &#91;^0000FF"+ getitemname(.prize_item) +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input .@prize;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (getitemname(.@prize) == "null") {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "That item does not exist.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Please try again.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.prize_item = .@prize;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Input the amount to be given.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (input(.@amount,1,10000)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "That amount is invalid.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Using a default amount of 1.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes .@n$;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.prize_amount = .@amount;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "Successfully changed prize.",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Prize: "+ .prize_amount +"x &#91;^0000FF"+ getitemname(.prize_item) +"^000000]";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
}
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.gm_level = 60;
&nbsp;&nbsp;&nbsp;&nbsp;.rounds = 10;
&nbsp;&nbsp;&nbsp;&nbsp;.prize_item = Red_Potion;
&nbsp;&nbsp;&nbsp;&nbsp;.prize_amount = 10;
&nbsp;&nbsp;&nbsp;&nbsp;.min = 3;
&nbsp;&nbsp;&nbsp;&nbsp;.max = 10;

&nbsp;&nbsp;&nbsp;&nbsp;// What disguise rule, the NPC should follow by default.
&nbsp;&nbsp;&nbsp;&nbsp;// 0 = Disguise as all monsters | 1 = Disguise as MVPs only
&nbsp;&nbsp;&nbsp;&nbsp;// Default: 1
&nbsp;&nbsp;&nbsp;&nbsp;.disguise_option = 1;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .disguise_desc$&#91;0],"Disguise as all monsters.", "Disguise as MVPs only.";

&nbsp;&nbsp;&nbsp;&nbsp;// Whether or not to block surrounding cells from players during event.
&nbsp;&nbsp;&nbsp;&nbsp;// 0 = Disabled, 1 = 1x1 | 2 = 2x2 | 9 = 9x9
&nbsp;&nbsp;&nbsp;&nbsp;// Default: 0 (Disabled).
&nbsp;&nbsp;&nbsp;&nbsp;.block_cells = 3;

&nbsp;&nbsp;&nbsp;&nbsp;// Minutes before event starts
&nbsp;&nbsp;&nbsp;&nbsp;.start_delay = 3;

&nbsp;&nbsp;&nbsp;&nbsp;// Seconds of intermission before transforming again
&nbsp;&nbsp;&nbsp;&nbsp;.change_delay = 10;

&nbsp;&nbsp;&nbsp;&nbsp;// MVP List
	setarray .MVP&#91;0], OSIRIS, BAPHOMET, DOPPELGANGER, MISTRESS, GOLDEN_BUG, ORK_HERO, DRAKE, EDDGA, MAYA, MOONLIGHT,
		&nbsp;&nbsp;&nbsp;&nbsp;PHARAOH, PHREEONI, ORC_LORD, KNIGHT_OF_WINDSTORM, GARM, DARK_LORD, TURTLE_GENERAL, LORD_OF_DEATH, DRACULA, EVENT_BAPHO,
		&nbsp;&nbsp;&nbsp;&nbsp;DARK_SNAKE_LORD, INCANTATION_SAMURAI, PORING_V, AMON_RA, TAO_GUNKA, RSX_0806, BACSOJIN_, B_SEYREN, B_EREMES, B_HARWORD,
		&nbsp;&nbsp;&nbsp;&nbsp;B_MAGALETA, B_SHECIL, B_KATRINN, B_YGNIZEM, APOCALIPS_H, LADY_TANEE, THANATOS, DETALE, KIEL_, RANDGRIS,
		&nbsp;&nbsp;&nbsp;&nbsp;GLOOMUNDERNIGHT, KTULLANUX, ATROCE, G_MAGALETA_, IFRIT, FALLINGBISHOP, BEELZEBUB_, GOPINICH, MOROCC_, KUBLIN,
		&nbsp;&nbsp;&nbsp;&nbsp;S_NYDHOG, BOITATA;

&nbsp;&nbsp;&nbsp;&nbsp;if(checkre(0)){
		setarray .MVP&#91;getarraysize(.MVP)], QUEEN_SCARABA, LOST_DRAGON, LEAK, I_QUEEN_SCARABA;
	}

&nbsp;&nbsp;&nbsp;&nbsp;// DO NOT CHANGE THE BELOW !!
	// Since this is a custom event, it should be made to support custom monsters !!
	// To increase mosnter range, simply increase the value of .last_mobid
	// Default: 5000
	.last_mobid = 5000;
	freeloop(1);
	for( .@i = SCORPION; .@i &lt; .last_mobid; .@i++ ) {
		if( !getmobdrops( ( .@i ) ) ) {
		.blacklist&#91;.@i] = .@i;
	&nbsp;&nbsp;&nbsp;&nbsp;}
	}
	freeloop(0);
	end;
</pre><br />Alright, all of that and we only just finished the <em class='bbc'><strong class='bbc'>OnInit:</strong></em> label. Let's stop here for now, and continue in <strong class='bbc'>Part 3</strong>, the <em class='bbc'><strong class='bbc'>core</strong></em> of our script.</div></div>
</div><hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 3</strong></span><div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;"><br />Alright, now we are on the final part of this script, the <strong class='bbc'>core</strong>. Here is where all the technical bits of the script are.<br /><br />Okay so to start the core off, this script starts every 2 hours of the day. So we're going to just add a bunch of OnClock lablels, that will represent every 2 hours:<pre class='prettyprint lang-auto linenums:0'>
OnClock0000:
OnClock0200:
OnClock0400:
OnClock0600:
OnClock0800:
OnClock1000:
OnClock1200:
OnClock1400:
OnClock1600:
OnClock1800:
OnClock2000:
OnClock2200:
</pre><br />Simple right? Alright, now when ever the server reaches any one of those times, they are all going to end up at the same spot. Which is where we start the event. However, we also made the script start when a GM chooses to do so, so we're going to add that label here as well:<pre class='prettyprint lang-auto linenums:0'>
iStartEvent:
</pre><br />Alright, now all the starting event callers are taken care of. However, if we leave it as is, there'll be an issue where a GM could have started the event, and then the server tries to start it, because it's that time of the day. So we are going to add a check, that will end the script abruptly if the event is already running:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (.event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Okay, that takes care of that issue. Now it's time to get down to business. There are 3 variables we are going to set, <em class='bbc'><strong class='bbc'>.change</strong></em>, <em class='bbc'><strong class='bbc'>.round_count</strong></em> and <em class='bbc'><strong class='bbc'>.event_onoff</strong></em>. We are going to set them to 0, 0 and 1 respectively.<br />So let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.change = .round_count = 0;
&nbsp;&nbsp;&nbsp;&nbsp;.event_onoff = 1;
</pre><br />The reason we set those variables to 0, is because they are set to other values throughout the event. However, instead of changing them to 0 when the event ends, we are just simply doing it before the event starts. This is to ensure a fresh event start.<br />Alright, now next we are going to add <em class='bbc'><strong class='bbc'>2 announcements</strong></em>. <em class='bbc'><strong class='bbc'>The first, letting players know when the event is going to officially start, and the second letting them know where the event is being held</strong></em>, in this case <em class='bbc'><strong class='bbc'>the map the NPC is on</strong></em>, to get that we'll need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2327' class='bbc_url' title='External link' rel='nofollow external'>strnpcinfo(&lt;type&gt;)</a><br />Also, we'll be <em class='bbc'><strong class='bbc'>editing our first announcement</strong></em> to <em class='bbc'><strong class='bbc'>show the proper wording depending on how many minutes are left</strong></em>, so we'll need to use a conditional check <em class='bbc'><strong class='bbc'>(?: )</strong></em> in side.<br /><br />Let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;announce "The Disguise Event will begin in "+ .start_delay +" minute"+ ( (.start_delay &gt; 1)?"s":"") +".",bc_all | bc_blue;
&nbsp;&nbsp;&nbsp;&nbsp;announce "The Event is being held in "+ strnpcinfo(4) +".",bc_all | bc_blue;
</pre><br />Okay, with that taken care of, it's now time to do the <em class='bbc'><strong class='bbc'>announcements that happen every 1 minute until the event starts</strong></em>. In the old version, this was done through an npc_timer. However, I've changed that around to use a <em class='bbc'>generic_loop</em>. This just means I'm going to call a single label over and over again, until it's fulfilled it's purpose, in our case it's just until the event starts.<br />So we'll start by adding the label, <em class='bbc'><strong class='bbc'>iSleepTimer:</strong></em><pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;iSleepTimer:
</pre><br />Okay, now we need to have the script <em class='bbc'><strong class='bbc'>wait 1 minute</strong></em> before it does anything. To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6486' class='bbc_url' title='External link' rel='nofollow external'>sleep {&lt;milliseconds&gt;};</a> So, since those are milliseconds, we'll just use the <em class='bbc'><strong class='bbc'>value of 60,000</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;sleep 60000;
</pre><br />Okay, so now we need to count how many minutes pass by. To do that, we'll just set a scope_variable to +1 after every minute we wait:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;++.@minute;
</pre><br />Next, we are going to add a simple check to see if the event is still on or not. If it isn't on, we'll end the script, else we'd just continue on with what it's got to do. The reason we do this check here, is because a GM may have decided to turn the event off early, so we need to anticipate that.<br />Let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (!.event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, now we need to <em class='bbc'><strong class='bbc'>add a check, that sees if our variable .@minute is equal to .start_delay or not</strong></em>. This will serve as our guide to see if we are going to loop back or not. <em class='bbc'><strong class='bbc'>If it isn't the same, we want to put our announcements here</strong></em>. The same as above, but we want it to <em class='bbc'><strong class='bbc'>update the time left, as well as using proper wording</strong></em>. Then after those <em class='bbc'><strong class='bbc'>2 announcements</strong></em>, we'll use the <strong class='bbc'>callsub;</strong> command.<br />So let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if( .@minute != .start_delay ) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;announce "The Disguise Event will begin in "+ ( .start_delay - .@minute ) +" minute"+ ( (.start_delay - .@minute &gt; 1)?"s":"") +".",bc_all | bc_blue;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;announce "The Event is being held in "+ strnpcinfo(4) +".",bc_all | bc_blue;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callsub iSleepTimer;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, with that taken care of, we need to run 1 more check to see if the GM turned the event off. Darn those GMs making it harder for us. So let's just add that in really quick:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (!.event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Next, we'll just add 2 more announcements, this time letting them know the event has started, and where it's being located:<pre class='prettyprint lang-auto linenums:0'>
	announce "The Disguise Event has begun!",bc_all | bc_blue;
	announce "The Event is being held in "+ strnpcinfo(4) +".",bc_all | bc_blue;
</pre><br />Okay, now we are going to have another generic loop here. This loop, will be used whenever the npc needs to change it's disguise. So let's add a label here called <em class='bbc'><strong class='bbc'>iDisguise:</strong></em>, I know I lack originality. After that we'll add 1 more check to see if the event is on or not, yet again.<br />So let's just add this in really quick:<pre class='prettyprint lang-auto linenums:0'>
iDisguise:
&nbsp;&nbsp;&nbsp;&nbsp;if (!.event_onoff) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, with that out of the way, we now need to <em class='bbc'><strong class='bbc'>check if the npc is currently disguising itself</strong></em> by <em class='bbc'><strong class='bbc'>seeing if the variable .change is set to 1 or not</strong></em>. <em class='bbc'><strong class='bbc'>If it is disguising itself</strong></em> we'll simply <em class='bbc'><strong class='bbc'>make the npc pause for .change_delay seconds</strong></em>. Using the <em class='bbc'><strong class='bbc'>sleep;</strong></em> command.<br />Let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (.change) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep (.change_delay * 1000);
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Next, we need to <em class='bbc'><strong class='bbc'>set .change to 0</strong></em> again. Even though we set it to 0 when the event starts, we need to set it to 0 after the npc disguises itself again. Then we'll also <em class='bbc'><strong class='bbc'>set the variable .winner to 0</strong></em> as well. Because, if the npc is disguising itself, then someone probably already guessed the right answer and it's moved on to the next round:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.change = .winner = 0;
</pre><br />Alright, now it's time to make the npc disguise into a monster, although, different from the last disguised monster if it previously had a disguise. To do this, we'll need to first switch between the disguise options we chose.<br />So let's use a switch based on <em class='bbc'><strong class='bbc'>.disguise_option</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;switch(.disguise_option) {
</pre><br />Now since we only have 2 options, we're only going to have 2 cases here. The first case deals with the npc being able to disguise as all monsters. So we'll start with that. Firstly, let's make the npc <em class='bbc'><strong class='bbc'>choose a random monster ID between SCORPION and .last_mobid</strong></em>, then we'll <em class='bbc'><strong class='bbc'>check to see if the ID chosen is in the blacklist we created</strong></em>. <em class='bbc'><strong class='bbc'>If it is, then we'll simply call the label iDisguise again</strong></em>, and make the npc choose another disguise until it's a monster that's not on the black list.<br />To do that we'll need to use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7713' class='bbc_url' title='External link' rel='nofollow external'>compare(&lt;string&gt;,&lt;substring&gt;)</a> to check if it's apart of the black list.<br />As well as the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7116' class='bbc_url' title='External link' rel='nofollow external'>rand(&lt;number&gt;{,&lt;number&gt;});</a> for choosing the monster id.<br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
case 1:
&nbsp;&nbsp;&nbsp;&nbsp;.@monster = rand(SCORPION, .last_mobid);
&nbsp;&nbsp;&nbsp;&nbsp;if (compare(.blacklist$, ","+ .@monster +",")) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callsub iDisguise;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, now we need to <em class='bbc'><strong class='bbc'>check if the monster chosen, is the same monster that it was disguised as last time</strong></em>. To do that, we'll <em class='bbc'><strong class='bbc'>check the monster name of the ID chosen vs the variable .last_monster$</strong></em> which contains the name of the monster we last chose. <em class='bbc'><strong class='bbc'>If it is the same, we'll call the label iDisguise again</strong></em>, until the npc chooses a completely unique monster to disguise as.<br />To do that we'll need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3474' class='bbc_url' title='External link' rel='nofollow external'>getmonsterinfo(&lt;mob ID&gt;,&lt;type&gt;)</a> <em class='bbc'><strong class='bbc'>for &lt;mob_ID&gt; use the variable .@monster</strong></em>, and <em class='bbc'><strong class='bbc'>for &lt;type&gt; we'll be using 0 to obtain it's name</strong></em>.<br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (getmonsterinfo(.@monster, 0) == .last_monster$) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callsub iDisguise;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Okay so now the npc should have chosen a unique monster. So now we are going to <em class='bbc'><strong class='bbc'>set 2 variables.</strong></em> The first being, <em class='bbc'><strong class='bbc'>.last_monster$</strong></em> and we are going to <em class='bbc'><strong class='bbc'>set that to the variable .monster_name$</strong></em> which in turn, is going to be<em class='bbc'><strong class='bbc'> set to the monsters name of the id chosen</strong></em>. Then we're just going to <em class='bbc'><strong class='bbc'>use the command break; to get out of the switch command</strong></em>.<br />Simple right? Let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.last_monster$ = .monster_name$ = getmonsterinfo(.@monster, 0);
&nbsp;&nbsp;&nbsp;&nbsp;break;
</pre><br />And that's it for case 1. Now it's time to do case 2, which is very similar to case 1, with the exception we'll be choosing a random MVP monster for the array we created. Which means we don't need to check if it's on the blacklist. So let's<strong class='bbc'><em class='bbc'> start by choosing a random element of the MVP array we created.</em></strong> and <em class='bbc'><strong class='bbc'>then checking to see if it's the same MVP we chose last time</strong></em>. If it is, call the label <em class='bbc'><strong class='bbc'>iDisguise:</strong></em><br />Let's add it in:<pre class='prettyprint lang-auto linenums:0'>
case 2:
&nbsp;&nbsp;&nbsp;&nbsp;.@i = rand(getarraysize(.MVP));
&nbsp;&nbsp;&nbsp;&nbsp;if (getmonsterinfo(.MVP&#91;.@i], 0) == .last_monster$) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callsub iDisguise;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, now we just need to <em class='bbc'><strong class='bbc'>set .last_monster$ to .monster_name$ which is set to the name of the MVP chosen</strong></em>. After that we need to <em class='bbc'><strong class='bbc'>set the variable, .@monster to the id chosen</strong></em> so the NPC knows what monster to disguise as, then we'll <em class='bbc'><strong class='bbc'>end it with a break; command and close out the switch command</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.last_monster$ = .monster_name$ = getmonsterinfo(.MVP&#91;.@i], 0);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.@monster = .MVP&#91;.@i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
}
</pre><br />Okay, so by now the NPC has successfully chosen a unique monster regardless of the disguise option. What we need to do now is have it do the following, change it's display to the monster chosen. To do that we'll use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6286' class='bbc_url' title='External link' rel='nofollow external'>setnpcdisplay("&lt;npc name&gt;", &lt;class id&gt;)</a> <em class='bbc'><strong class='bbc'>for &lt;class_id&gt; we'll use the monster id we chose</strong></em>.<br />In combination with the command <strong class='bbc'>strnpcinfo(3);</strong> Then we need to <strong class='bbc'><em class='bbc'>set an npc timer to 0, and start it</em></strong>. This will serve to make the npc change it's disguise every 30seconds, meaning player's have that long to guess what the NPC currently is before it switches disguises again.<br />To do that we'll need to use these 2 commands: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6338' class='bbc_url' title='External link' rel='nofollow external'>setnpctimer &lt;tick&gt;{,"&lt;NPC name&gt;"};</a> and <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6332' class='bbc_url' title='External link' rel='nofollow external'>initnpctimer { "&lt;NPC name&gt;" {, &lt;Attach Flag&gt;} }</a><br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;setnpcidsplay strnpcinfo(3), .@monster;
&nbsp;&nbsp;&nbsp;&nbsp;setnpctimer 0;
&nbsp;&nbsp;&nbsp;&nbsp;initnpctimer;
</pre><br />Okay, the next thing we need to do is <em class='bbc'><strong class='bbc'>call the label iSetPset:</strong></em> while <em class='bbc'><strong class='bbc'>passing the argument of 1</strong></em>. After that we need to <strong class='bbc'>end;</strong> the script.<br />So let's do that really quick:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;callsub iSetPset,1;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Alright that takes care of the label <em class='bbc'><strong class='bbc'>iDisguise:</strong></em>. Now we need to work on the label, <em class='bbc'><strong class='bbc'>iSetPset:</strong></em> that we just called. This label, will serve to change the answer players need to input to receive a prize from the NPC and be declared the rounds winner. So let's just <em class='bbc'><strong class='bbc'>make the label</strong></em> before anything:<pre class='prettyprint lang-auto linenums:0'>
iSetPset:
</pre><br />Okay, so before we set a new answer, we first need to delete the old one.<br />To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7531' class='bbc_url' title='External link' rel='nofollow external'>deletepset &lt;set number&gt;;</a> for &lt;set_number&gt; we'll use 1.<br />So let's add that in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;deletepset 1;
</pre><br />Next, we need to <em class='bbc'><strong class='bbc'>check if we passed an argument or not</strong></em>, this is because this label will be called when we change disguises, and we a player wins a round and if they do, we need to delete the previous answer or people will just spam that as fast as they can to try and get a prize too.<br />So let's just <em class='bbc'><strong class='bbc'>check if getarg(0) has any value other than 0</strong></em>.<pre class='prettyprint lang-auto linenums:0'>
if (getarg(0)) {
</pre><br />Now, since it does have a value of 1 in this case, we'll need to define the pattern the npc will look for when players shout out the monsters name. To do that we'll need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7528' class='bbc_url' title='External link' rel='nofollow external'>defpattern &lt;set number&gt;,"&lt;regular expression pattern&gt;","&lt;event label&gt;";</a> <em class='bbc'><strong class='bbc'>for &lt;set_number&gt; use 1</strong></em>, and <em class='bbc'><strong class='bbc'>for "&lt;event_label&gt;" we'll use the label iCorrect:</strong></em><br />Now, I would love to break down the <em class='bbc'><strong class='bbc'>"&lt;regular_expression_pattern&gt;"</strong></em> for you, but sadly I don't remember how I came upon this being the correct expression pattern to be used. All you need to know is that it checks to see if what the player says, matches what the NPC is looking for.<br />So, just copy what I have below for the correct usage:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;defpattern 1, "(&#91;^:]+):.\\s*"+ .monster_name$ +".*", "iCorrect";
}
</pre><br />See, it's too confusing for me to try and explain it to you. All I can say is, it's looking for the monster name of the monster we chose, which is stored in the variable <em class='bbc'><strong class='bbc'>.monster_name$</strong></em>.<br />Alright, now we need to activate that answer. To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7529' class='bbc_url' title='External link' rel='nofollow external'>activatepset &lt;set number&gt;;</a> <strong class='bbc'><em class='bbc'>for &lt;set_number&gt; we'll use 1 again.</em></strong> After that we need to use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1811' class='bbc_url' title='External link' rel='nofollow external'>return {&lt;value&gt;};</a> which will allow us to return to the part of the script where we called this label <em class='bbc'><strong class='bbc'>followed by an obligatory end; command</strong></em>, because we should always take precautions.<br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;activatepset 1;
&nbsp;&nbsp;&nbsp;&nbsp;return;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Alright now remember this script uses a timer for how long the npc will stay disguised before it's going to change it into a different monster. That time is only 30seconds, so let's create that label.<br /><strong class='bbc'><em class='bbc'>OnTimer30000:</em></strong> then, immediately after that label is called we need to stop the npc timer.<br />To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6334' class='bbc_url' title='External link' rel='nofollow external'>stopnpctimer { "&lt;NPC name&gt;" {, &lt;Detach Flag&gt;} }</a><br />Then we'll set the npc's display back to normal. Meaning turn back into the regular npc it was before hand. We'll also add a small special effect as well, so it's not boring when it undisguises.<br />To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L5531' class='bbc_url' title='External link' rel='nofollow external'>specialeffect &lt;effect number&gt;{,&lt;send_target&gt;{,"&lt;NPC Name&gt;"}};</a> <em class='bbc'><strong class='bbc'>the effect we'll use is EF_DETECT2</strong></em><br />For a list of other effects, look here: <a href='https://github.com/HerculesWS/Hercules/blob/master/db/const.txt#L1393' class='bbc_url' title='External link' rel='nofollow external'>Effect List</a> <em class='bbc'><strong class='bbc'>they'll begin with EF_</strong></em><br />So let's do that:<pre class='prettyprint lang-auto linenums:0'>
OnTimer30000:
&nbsp;&nbsp;&nbsp;&nbsp;stopnpctimer;
&nbsp;&nbsp;&nbsp;&nbsp;setnpcdisplay strnpcinfo(3), 4_M_NFDEADMAN;
&nbsp;&nbsp;&nbsp;&nbsp;specialeffect EF_DETECT2;
</pre><br />Okay, now we're going to <em class='bbc'><strong class='bbc'>have the npc tell the players in the surrounding area, that they took too long to guess what it was disguised as. And to please wait .change_delay seconds while it disguises again</strong></em>. Make sure to use proper labeling for second/seconds if you made it more than 1second long. To do that we'll need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6270' class='bbc_url' title='External link' rel='nofollow external'>npctalk "&lt;message&gt;";</a><br />So let's just add that in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;npctalk "You took too long to guess what I was. Please wait "+ .change_delay +" second"+((.change_delay &gt; 1)"s":"")+" while I disguise again.";
</pre><br /><br />Next we need to <em class='bbc'><strong class='bbc'>reset the variable .monster_name$</strong></em>, then we'll <em class='bbc'><strong class='bbc'>call the label iSetPset again, this time without an argument.</strong></em> After that we need to <em class='bbc'><strong class='bbc'>set the variable .change to 1</strong></em> so the script knows that it's changing it's disguise and will wait the proper time before it actually chooses a disguise. Then lastly <em class='bbc'><strong class='bbc'>call the label iDisguise:</strong></em> and<em class='bbc'><strong class='bbc'> </strong></em><strong class='bbc'>end;</strong><em class='bbc'><strong class='bbc'> the script early</strong></em>.<br />So let's do that:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.monster_name$ = "";
&nbsp;&nbsp;&nbsp;&nbsp;callsub iSetPset;
&nbsp;&nbsp;&nbsp;&nbsp;.change = 1;
&nbsp;&nbsp;&nbsp;&nbsp;callsub iDisguise;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Perfect, now we're finally on the last part of the script. The label <em class='bbc'><strong class='bbc'>iCorrect:</strong></em> which deals with when a player correctly guesses the monster's name. We'll start off by <em class='bbc'><strong class='bbc'>checking to see if the variable .winner is set to anything other than 0</strong></em>. If it is, we'll <em class='bbc'><strong class='bbc'>use the command dispbottom;</strong></em> <em class='bbc'><strong class='bbc'>to have the npc say, Someone has already won this round.</strong></em> Then <em class='bbc'><strong class='bbc'>end; the script early</strong></em>. After that we'll actually<em class='bbc'><strong class='bbc'> set the variable .winner to 1.</strong></em> This will prevent multiple people being a winner in the same round if the server lags.<br />Lastly, we'll <em class='bbc'><strong class='bbc'>set the variable .round_count +1</strong></em>. So that the npc knows the round is over.<br />Let's add it in:<pre class='prettyprint lang-auto linenums:0'>
iCorrect:
&nbsp;&nbsp;&nbsp;&nbsp;if (.winner) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "Someone has already won this round.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;.winner = 1;
&nbsp;&nbsp;&nbsp;&nbsp;++.round_count;
</pre><br />Okay, now we need to call the label<em class='bbc'><strong class='bbc'> iSetPset without an argument</strong></em> yet again. This will delete the current answer and set it to nothing, which is impossible for players to enter. Then we'll<strong class='bbc'> <em class='bbc'>give the winner the prize we chose along with the amount we chose</em></strong>:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;callsub iSetPset;
&nbsp;&nbsp;&nbsp;&nbsp;getitem .prize_item, .prize_amount;
</pre><br />Next we'll have the npc announce that strcharinfo(0) is correct, and tell them that the NPC was disguised as .monster_name$. This time we'll only announce it to those on the current map. Then <em class='bbc'><strong class='bbc'>have the NPC change it's display back to a normal npc</strong></em>. Because before this label was called the npc was disguised as a monster:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;announce strcharinfo(0) +" is correct!! I was disguised as: "+ .monster_name$ +"",bc_map | bc_blue;
&nbsp;&nbsp;&nbsp;&nbsp;setnpcdisplay strnpcinfo(3), 4_M_NFDEADMAN;
</pre><br />Now we'll <em class='bbc'><strong class='bbc'>check to see if the we finished all the rounds that we said the npc would last for</strong></em>. If it is, <em class='bbc'><strong class='bbc'>have the npc tell those in the surrounding area, "Thank you all for playing. That was the last round of the Disguise Event. Come play again later."</strong></em><br />Then we'll turn the event off by <em class='bbc'><strong class='bbc'>setting the variable .event_onoff to 0</strong></em>. Lastly <em class='bbc'><strong class='bbc'>stop the npctimer, and end; the script early</strong></em>.<br />Let's add that in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (.round_count &gt;= .rounds) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;npctalk "Thank you all for playing. That was the last round of the Disguise Event. Come play again later.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.event_onoff = 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stopnpctimer;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Okay now for the final stretch. <em class='bbc'><strong class='bbc'>Have the npc tell the player's to wait .change_delay second(s if more than 1 second) while it disguises again</strong></em>. Then <strong class='bbc'><em class='bbc'>set the npctimer to 0, and stop the timer</em></strong>. This is to prevent the timer going to 30seconds again while it tries to find a disguise. Next, we'll <em class='bbc'><strong class='bbc'>set the variable .change to 1</strong></em>, so the NPC will wait the proper time before finding a suitable disguise. Lastly <em class='bbc'><strong class='bbc'>call the label iDisguise:</strong></em> and <em class='bbc'><strong class='bbc'>end; the script </strong></em><strong class='bbc'><em class='bbc'>completely.</em></strong><br />This is it, add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;npctalk "Please wait "+ .change_delay +" second"+((.change_delay &gt; 1)?"s":"")+", while I disguise again.";
&nbsp;&nbsp;&nbsp;&nbsp;setnpctimer 0;
&nbsp;&nbsp;&nbsp;&nbsp;stopnpctimer;
&nbsp;&nbsp;&nbsp;&nbsp;.change = 1;
&nbsp;&nbsp;&nbsp;&nbsp;callsub iDisguise;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>And that's it. The disguise event is done. It should look something like this when you're finished: <a href='http://upaste.me/1a29160054babf6e2' class='bbc_url' title='External link' rel='nofollow external'>Disguise Event</a> (Have to use link as this post has gotten too long to paste the script in a code block).</div></div>
</div>]]></description>
		<pubDate>Fri, 28 Nov 2014 06:36:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-101-disguise-event-script/</guid>
	</item>
	<item>
		<title>Did I help you? Let me know!</title>
		<link>http://herc.ws/board/blog/29/entry-100-did-i-help-you-let-me-know/</link>
		<category></category>
		<description><![CDATA[Just a little poll, to see how helpful these are. After all, if people aren't learning, I must be doing something wrong.<br />
Either that or perhaps it's the scripts I chose. Either way, let me know! I'll try to correct my faults, because if you came here, you obviously wanted to learn as well !]]></description>
		<pubDate>Fri, 28 Nov 2014 00:07:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-100-did-i-help-you-let-me-know/</guid>
	</item>
	<item>
		<title>Custom AtCommand @buff</title>
		<link>http://herc.ws/board/blog/29/entry-99-custom-atcommand-buff/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Custom AtCommand @buff <sup class='bbc'>( 2 parts )</sup></strong></span><br />A custom @command, that will buff the player with preset buffs, have a cast time, cost zeny, have a cooldown time and will unlock more buffs the more they use it!<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><br />Okay, so now it's time for us to make our first @command using a script. Which means we don't need to modify the src code in any way.<br /><br />Let's start off by making a floating npc:<pre class='prettyprint lang-auto linenums:0'>
-&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;at_buff&nbsp;&nbsp;&nbsp;&nbsp;-1,{
</pre><br />Now we are going to tell the script to create a custom @command for us, to do so we will be using this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7352' class='bbc_url' title='External link' rel='nofollow external'>bindatcmd "command","&lt;NPC object name&gt;::&lt;event label&gt;"{,&lt;group level&gt;,&lt;group level char&gt;,&lt;log&gt;};</a><br />So let's add ours under <em class='bbc'><strong class='bbc'>OnInit:</strong></em> and call it @buff. For <em class='bbc'><strong class='bbc'>&lt;NPC_object_name&gt;</strong></em>, we'll be using this command to retrieve that: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2327' class='bbc_url' title='External link' rel='nofollow external'>strnpcinfo(&lt;type&gt;)</a>.<br />Lastly, let's call the event label, <em class='bbc'><strong class='bbc'>OnAtBuff:</strong></em><pre class='prettyprint lang-auto linenums:0'>
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;bindatcmd "buff", strnpcinfo(3)+"::OnAtBuff";
</pre><br />Now, let's add our other variables. Let's make this command have a cast time of<em class='bbc'><strong class='bbc'> 5 seconds</strong></em>, <em class='bbc'><strong class='bbc'>cost</strong></em> <em class='bbc'><strong class='bbc'>10.000z</strong></em> to use, and have a <em class='bbc'><strong class='bbc'>cool-down</strong></em> time of <em class='bbc'><strong class='bbc'>10 minutes</strong></em>. Let's also set a variable for how many tiers of buffs there are, and what the cap tier is.<br />For this example we'll use <strong class='bbc'><em class='bbc'>10</em></strong> as each increment of a tier, and cap it at <em class='bbc'><strong class='bbc'>2</strong></em> additional tiers:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.cast_time = 5;
&nbsp;&nbsp;&nbsp;&nbsp;.zeny = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.cool_down = 600;
&nbsp;&nbsp;&nbsp;&nbsp;.tiers = 10;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_level_limit = 2 * tiers;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Let's move on to our next step. We'll start by making the <em class='bbc'><strong class='bbc'>OnAtBuff:</strong></em> label:<pre class='prettyprint lang-auto linenums:0'>
OnAtBuff:
</pre><br />From here we need to first, preform the check for the cool-down, to see if they've used the command recently. We're going to be using this command for that: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3135' class='bbc_url' title='External link' rel='nofollow external'>gettimetick(&lt;tick type&gt;)</a>.<br />But first we need to use a <em class='bbc'>player_variable</em> to check against, we'll call this variable <em class='bbc'><strong class='bbc'>buff_cool_down:</strong></em><pre class='prettyprint lang-auto linenums:0'>
if (buff_cool_down &gt; gettimetick(2)) {
</pre><br />Now that we got the check out of the way, let' sput a message that says "You cannot use this command for another - X amount of minutes.<br />To do that, we are going to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4139' class='bbc_url' title='External link' rel='nofollow external'>dispbottom "&lt;message&gt;";</a><br />in combination with this function: <a href='https://github.com/HerculesWS/Hercules/blob/master/npc/other/Global_Functions.txt#L311' class='bbc_url' title='External link' rel='nofollow external'>Time2Str</a>. What that function will do is convert the cool-down into a readable time for us.<br />To call the function we'll use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1617' class='bbc_url' title='External link' rel='nofollow external'>callfunc "&lt;function&gt;"{,&lt;argument&gt;,...&lt;argument&gt;};</a><br />So let's add it all in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "You cannot use this command for another: "+ callfunc("Time2Str",buff_cool_down) +"";
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Let's continue on now that we took care of that, and create our check to see if they have enough zeny. Again, using <strong class='bbc'>dispbottom</strong> to let them know they don't have enough zeny:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Now it's time to add the cast time for the command. To do so we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6509' class='bbc_url' title='External link' rel='nofollow external'>progressbar "&lt;color&gt;",&lt;seconds&gt;;</a><pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;progressbar "0x00FF00", .cast_time;
</pre><br />Okay, now since things in RO are subject to change at any given time, we need to perform the zeny check once more to make sure they didn't some how store their Zeny away. So let's just copy+paste that again, below the progressbar. Also, another reason for doing it this way, is to not make the player suffer through a loading bar when they initially didn't have enough Zeny. That would just be too curel. Unless you like that sort of thing:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Now, all that's left to do is take away the zeny for payment, and add the buffs as needed. To do that we'll be using <strong class='bbc'>switch()</strong> to make them cycle through the appropriate buffs. We'll determine that by creating a <strong class='bbc'><em class='bbc'>scope_variable</em></strong> that divides a <strong class='bbc'><em class='bbc'>player_variable</em></strong> by <em class='bbc'><strong class='bbc'>.tiers</strong></em>. We also need to increase the <em class='bbc'><strong class='bbc'>player_variable</strong></em> by <em class='bbc'><strong class='bbc'>1</strong></em> after receiving buffs, and check to make sure it isn't above the level limit:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .zeny;
&nbsp;&nbsp;&nbsp;&nbsp;.@buffs = at_buff_usuage / .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;switch( .@buffs ){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 20:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_ASSUMPTIO,300000,5;
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 10:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_IMPOSITIO,300000,5;
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 0:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_BLESSING,300000,10;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_INC_AGI,300000,10;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++at_buff_usage;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (at_buff_usage &gt; .buff_level_limit) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at_buff_usage = .buff_level_limit
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Now, all we need to do is, add the cool-down as proof they used the command:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;buff_cool_down = gettimetick(2) + .cool_down;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Also, since that's the end of the script let's close it off. And when you're done, it should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	at_buff	-1,{
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;bindatcmd "buff", strnpcinfo(3)+"::OnAtBuff";
&nbsp;&nbsp;&nbsp;&nbsp;.cast_time = 5;
&nbsp;&nbsp;&nbsp;&nbsp;.zeny = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.cool_down = 600;
&nbsp;&nbsp;&nbsp;&nbsp;.tiers = 10;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_level_limit = 2 * .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnAtBuff:
&nbsp;&nbsp;&nbsp;&nbsp;if (buff_cool_down &gt; gettimetick(2)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "You cannot use this command for another: "+ callfunc("Time2Str",buff_cool_down) +"";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;progressbar "0x00FF00", .cast_time;
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .zeny;
&nbsp;&nbsp;&nbsp;&nbsp;.@buffs = at_buff_usuage / .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;switch( .@buffs ){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 20:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_ASSUMPTIO,300000,5;
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 10:
&nbsp;&nbsp;&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_IMPOSITIO,300000,5;
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 0:
&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_BLESSING,300000,10;
	&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_INC_AGI,300000,10;
	&nbsp;&nbsp;&nbsp;&nbsp;++at_buff_usuage;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (at_buff_usuage &gt; .buff_level_limit) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at_buff_usage = .buff_level_limit;
	&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;buff_cool_down = gettimetick(2) + .cool_down;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>And that's it, you just finished making a custom @buff command that everyone in your server can use.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><br />Alright, so here we are going to limit the use of this command to certain maps depending on mapflags that are already set in place on those maps. Additionally, we are going to clean the script up a bit.<br /><br />So let's start by opening up our script again:<pre class='prettyprint lang-auto linenums:0'>
-	script	at_buff	-1,{
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;bindatcmd "buff", strnpcinfo(3)+"::OnAtBuff";
&nbsp;&nbsp;&nbsp;&nbsp;.cast_time = 5;
&nbsp;&nbsp;&nbsp;&nbsp;.zeny = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.cool_down = 600;
&nbsp;&nbsp;&nbsp;&nbsp;.tiers = 10;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_level_limit = 2 * .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnAtBuff:
&nbsp;&nbsp;&nbsp;&nbsp;if (buff_cool_down &gt; gettimetick(2)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "You cannot use this command for another: "+ callfunc("Time2Str",buff_cool_down) +"";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;progressbar "0x00FF00", .cast_time;
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .zeny;
&nbsp;&nbsp;&nbsp;&nbsp;.@buffs = at_buff_usuage / .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;switch( .@buffs ){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 20:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_ASSUMPTIO,300000,5;
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 10:
&nbsp;&nbsp;&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_IMPOSITIO,300000,5;
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 0:
&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_BLESSING,300000,10;
	&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_INC_AGI,300000,10;
	&nbsp;&nbsp;&nbsp;&nbsp;++at_buff_usuage;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (at_buff_usuage &gt; .buff_level_limit) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at_buff_usage = .buff_level_limit;
	&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;buff_cool_down = gettimetick(2) + .cool_down;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />To start with, we are going to be adding a new array under <em class='bbc'><strong class='bbc'>OnInit:</strong></em> called <em class='bbc'><strong class='bbc'>.mapflags</strong></em>. In side the array we will add all the mapflags that we wish to use to limit our commands usage.<br />For a list of mapflags look here: <a href='https://github.com/HerculesWS/Hercules/blob/master/db/const.txt#L312' class='bbc_url' title='External link' rel='nofollow external'>mapflags</a>.<br />Now then let's add our flags in to limit use in areas that are PvP, GvG or BattleGrounds:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;setarray .mapflags&#91;0],mf_pvp,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_pvp_noparty,
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_pvp_noguild,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_gvg,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_gvg_noparty,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_gvg_castle,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_battleground;
</pre><br />With that out of the way let's add a check under our OnAtBuff: label to see if the map the player is on, has any of these mapflags on them. To do that we will be using this loop command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2123' class='bbc_url' title='External link' rel='nofollow external'>for (&lt;variable initialization&gt;; &lt;condition&gt;; &lt;variable update&gt;) &lt;statement&gt;;</a><br />in combination with this command to perform the actual check: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6891' class='bbc_url' title='External link' rel='nofollow external'>getmapflag("&lt;map name&gt;",&lt;flag&gt;)</a>.<br />To get the mapname of the player we will use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2310' class='bbc_url' title='External link' rel='nofollow external'>strcharinfo(&lt;type&gt;)</a>.<br />So let's make our loop, and also let the player know that they can't use the command on PvP, GvG and BattleGround maps. This should be no problem for you now, after the few scripts we've done:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp; for (.@i = 0; .@i &lt; getarraysize(.mapflags&#91;0]); .@i++) {
&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;if (getmapflag( strcharinfo(3), .mapflags&#91;.@i] )) {
		&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "This command is disabled on PVP, GVG and BattleGround maps.";
		&nbsp;&nbsp;&nbsp;&nbsp;end;
	&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Alright, now we need to do the clean up portion of this edit. To do this, we'll be making a new label at the bottom of our script. We'll call it <em class='bbc'><strong class='bbc'>OnZenyCheck:</strong></em>. Underneath this label we'll add our zeny check we already have in the script. Lastly, beneath the check we will be adding this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1811' class='bbc_url' title='External link' rel='nofollow external'>return {&lt;value&gt;};</a> without the value:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;return;
</pre><br />Now the last ting you need to is replace the other Zeny checks with this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1683' class='bbc_url' title='External link' rel='nofollow external'>callsub &lt;label&gt;{,&lt;argument&gt;,...&lt;argument&gt;};</a> For this we won't be using any arguments, we are just going to call the label, <em class='bbc'><strong class='bbc'>OnZenyCheck</strong></em><br />What this will do is instead of typing out the check twice, we simply type it once, and make the script call the check and return to the point of it's execution.<br />So let's add them in:<pre class='prettyprint lang-auto linenums:0'>
callsub OnZenyCheck;
</pre><br />Now, we are done. Your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	at_buff	-1,{
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;bindatcmd "buff", strnpcinfo(3)+"::OnAtBuff";
&nbsp;&nbsp;&nbsp;&nbsp;.cast_time = 5;
&nbsp;&nbsp;&nbsp;&nbsp;.zeny = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.cool_down = 600;
&nbsp;&nbsp;&nbsp;&nbsp;.tiers = 10;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_level_limit = 2 * .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .mapflags&#91;0],mf_pvp,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_pvp_noparty,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_pvp_noguild,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_gvg,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_gvg_noparty,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_gvg_castle,
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mf_battleground;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnAtBuff:
&nbsp;&nbsp;&nbsp;&nbsp;for (.@i = 0; .@i &lt; getarraysize(.mapflags&#91;0]); .@i++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (getmapflag( strcharinfo(3), .mapflags&#91;.@i] )) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "This command is disabled on PVP, GVG and BattleGround maps.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;if (buff_cool_down &gt; gettimetick(2)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "You cannot use this command for another: "+ callfunc("Time2Str",buff_cool_down) +"";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;callsub OnZenyCheck;
&nbsp;&nbsp;&nbsp;&nbsp;progressbar "0x00FF00", .cast_time;
&nbsp;&nbsp;&nbsp;&nbsp;callsub OnZenyCheck;
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .zeny;
&nbsp;&nbsp;&nbsp;&nbsp;.@buffs = at_buff_usuage / .tiers;
&nbsp;&nbsp;&nbsp;&nbsp;switch( .@buffs ){
	&nbsp;&nbsp;&nbsp;&nbsp;case 20:
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_ASSUMPTIO,300000,5;
	
	&nbsp;&nbsp;&nbsp;&nbsp;case 10:
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_IMPOSITIO,300000,5;
	
	&nbsp;&nbsp;&nbsp;&nbsp;case 0:
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_BLESSING,300000,10;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_INC_AGI,300000,10;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++at_buff_usuage;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (at_buff_usage &gt; .buff_level_limit) {
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at_buff_usuable = .buff_level_limit;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;buff_cool_down = gettimetick(2) + .cool_down;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnZenyCheck:
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "It costs "+ .zeny +" zeny to use this command.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;return;
}
</pre>And that's it, we're done with this script.]]></description>
		<pubDate>Thu, 27 Nov 2014 10:42:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-99-custom-atcommand-buff/</guid>
	</item>
	<item>
		<title>Bounty Hunting PvP Script</title>
		<link>http://herc.ws/board/blog/29/entry-98-bounty-hunting-pvp-script/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Bounty Hunting PvP Script <sup class='bbc'>( 2 Parts )</sup></strong></span><br />An intermediate level PvP script. This script is intended to help improve your scripting abilities, while also making you feel more comfortable about PvP scripts.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><br />Alright, before we begin I'm assuming you already completed the Basic PvP Script. If not, you will need to do so to follow along.<br /><br />Otherwise let's continue, by first creating a floating npc, followed by the <em class='bbc'><strong class='bbc'>OnInit:</strong></em> label:<pre class='prettyprint lang-auto linenums:0'>
-&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;bounty_script&nbsp;&nbsp;&nbsp;&nbsp;-1,{
OnInit:
</pre><br />Now that we got rid of the easy part, let's add some configurations to our script.<br />We'll start by setting up the following 2 variables:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.bounty = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.wanted_increments = 1000000;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Those will be used later when we determine what happens when a player is killed in PvP combat. So to continue on, we are going to be adding the <em class='bbc'><strong class='bbc'>OnPCKillEvent:</strong></em> label followed by a check to see if the person who died, is also the killer and if so, end the script.<br />To do that we'll need to use <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2423' class='bbc_url' title='External link' rel='nofollow external'>getcharid(3)</a>, as this will return the account id:<pre class='prettyprint lang-auto linenums:0'>
OnPCKillEvent:
&nbsp;&nbsp;&nbsp;&nbsp;if (killedrid == getcharid(3)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Now, this is a bit different than normal, because right now the script is attached to the killer. But we want to make changes to the killed person first, so let's attach the script to that person:<pre class='prettyprint lang-auto linenums:0'>
attachrid(killedrid);
</pre><br />Alright, now we need to set 2 variables. The first being <em class='bbc'><strong class='bbc'>.@zeny</strong></em> to the player's current bounty regardless of whether or not he had one.<br />To do this, we need to use the command: <strong class='bbc'>getcharid(0);</strong> as the element of an array.<br />It should look like this:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.@zeny = .bounty&#91;getcharid(0)];
</pre><br />Now we just need to set the player's bounty to <em class='bbc'><strong class='bbc'>0</strong></em> since he was killed. So let's do that:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.bounty&#91;getcharid(0)] = 0;
</pre><br />Now the last thing we are going to do with this player is save their name into a scope-string variable for later use, let's call it <em class='bbc'><strong class='bbc'>.@name$</strong></em>, and remember the command to get their name is: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2310' class='bbc_url' title='External link' rel='nofollow external'>strcharinfo(&lt;type&gt;);</a><pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.@name$ = strcharinfo(0);
</pre><br />Now that we are done making changes to the killed player, let's attach the script back to the killer:<pre class='prettyprint lang-auto linenums:0'>
attachrid(killerrid);
</pre><br />Here we are going to do 2 things. The first is, we are going to increase the killer's Zeny by the variable <em class='bbc'><strong class='bbc'>.@zeny</strong></em> which we got from the killed player. The second is, we are going to increase the killer's bounty by the variable <em class='bbc'><strong class='bbc'>.bounty</strong></em>.<br />So let's do that:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;Zeny += .@zeny;
&nbsp;&nbsp;&nbsp;&nbsp;.bounty&#91;getcharid(0)] += .bounty;
</pre><br />See, that wasn't too hard. Finally, we are going to announce that the player has killed the other player, as well as show what his bounty level is. This will be determined by dividing his bounty by the <em class='bbc'><strong class='bbc'>.wanted_increments</strong></em> variable we made earlier in the script. Also, we will be using a <em class='bbc'><strong class='bbc'>(? <img src='http://herc.ws/board/public/style_emoticons/default/smile.png' class='bbc_emoticon' alt=':)' /></strong></em> condition to properly announce whether or not the killer is male or female. Along with what the player's bounty is so others can hunt them down. And lastly, announce it to everyone, in blue.<br />Let's do it:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;announce "&#91;"+ strcharinfo(0) +"] has killed &#91;"+ .@name$ +"]. "+ (Sex?"He":"She") +" has a bounty of: "+ .bounty&#91;getcharid(0)] +"") +" zeny! &#91; WANTED LEVEL "+ ( .bounty&#91;getcharid(0)] / .wanted_increments ) +" ]",bc_blue|bc_all;
</pre><br />Alright. That's it, when you're all done it should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	bounty_script	-1,{
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.bounty = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.wanted_increments = 100000;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnPCKillEvent:
&nbsp;&nbsp;&nbsp;&nbsp;if (killedrid == getcharid(3)) {
	end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killedrid);
	.@zeny = .bounty&#91;getcharid(0)];
	.bounty&#91;getcharid(0)] = 0;
	.@name$ = strcharinfo(0);
		
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killerrid);
	Zeny += .@zeny;
	.bounty&#91;getcharid(0)] += .bounty;
	announce "&#91;"+ strcharinfo(0) +"] has killed &#91;"+ .@name$ +"]. "+ (Sex?"He":"She") +" has a bounty of: "+ .bounty&#91;getcharid(0)] +" zeny! &#91; WANTED LEVEL "+ ( .bounty&#91;getcharid(0)] / .wanted_increments ) +" ]",bc_blue|bc_all;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>And that's it for now. We'll make some more improvements, as well as add more features in <strong class='bbc'><em class='bbc'>part 2</em></strong>.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><br />Okay, let's just jump straight into this one.<br /><br />Let's open up the script from last time:<pre class='prettyprint lang-auto linenums:0'>
-	script	bounty_script	-1,{
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.bounty = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.wanted_increments = 100000;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnPCKillEvent:
&nbsp;&nbsp;&nbsp;&nbsp;if (killedrid == getcharid(3)) {
	end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killedrid);
	.@zeny = .bounty&#91;getcharid(0)];
	.bounty&#91;getcharid(0)] = 0;
	.@name$ = strcharinfo(0);
		
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killerrid);
	Zeny += .@zeny;
	.bounty&#91;getcharid(0)] += .bounty;
	announce "&#91;"+ strcharinfo(0) +"] has killed &#91;"+ .@name$ +"]. "+ (Sex?"He":"She") +" has a bounty of: "+ .bounty&#91;getcharid(0)] +" zeny! &#91; WANTED LEVEL "+ ( .bounty&#91;getcharid(0)] / .wanted_increments ) +" ]",bc_blue|bc_all;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Now, the additions we're going to put in here are peretty simple. We are going to add 3 things in:<br />1) A check so that this script only works on certain maps.<br />2) Whether or not to warp the player to their SavePoint upon death.<br />3) Whether or not player's lose zeny when they die.<br />So let's add those variables into <em class='bbc'><strong class='bbc'>OnInit:</strong></em><pre class='prettyprint lang-auto linenums:0'>
.mapname$ = "pvp_y_2-1";
.warp_death = 1;
.zeny_loss = .bounty;
</pre><br />So above, we chose our map that it is enabled on, also said <em class='bbc'><strong class='bbc'>yes</strong></em> players get warped out upon dying and the <em class='bbc'><strong class='bbc'>.zeny_loss</strong></em> is set to the bounty players gain per kill. Seems easy enough, now the next step is to add a check to see if the killer is on the same map as what we specified.<br />So let's add the check directly under <em class='bbc'><strong class='bbc'>OnPCKillEvent:</strong></em> using <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2310' class='bbc_url' title='External link' rel='nofollow external'>strcharinfo(3)</a>:<pre class='prettyprint lang-auto linenums:0'>
if (strcharinfo(3) != .mapname$) {
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Took care of that. And now it won't cause any problems down the line.<br />Alright, we're almost done. Just need to add a few more checks regarding the zeny_loss variable. Let's knock those out. We are going to check if <em class='bbc'><strong class='bbc'>.zeny_loss</strong></em> is enabled.<br />So let's do that:<pre class='prettyprint lang-auto linenums:0'>
if (.zeny_loss) {
</pre><br />Okay, now we need to add <em class='bbc'><strong class='bbc'>another</strong></em> check inside of that one. This time, we are going to check if the player has Zeny less-than how much we are going to take away. If they do, we are going to take away the remaining zeny from them. If they happen to have more, we'll take away just what we need to.<br />So let's do that:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny_loss) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= Zeny;
&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .zeny_loss;
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</pre><br />Alright, last thing we need to do is add the check to see if <em class='bbc'><strong class='bbc'>.warp_death</strong></em> is enabled, and if so, warp the dead player out. So we'll add that right <em class='bbc'><strong class='bbc'>before</strong></em> we end the script.<br />To do that, we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt' class='bbc_url' title='External link' rel='nofollow external'>warp "&lt;map name&gt;",&lt;x&gt;,&lt;y&gt;;</a><br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
if (warp_death) {
&nbsp;&nbsp;&nbsp;&nbsp;warp "SavePoint",0,0;
}
</pre><br />Now we are finished. Your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	bounty_script	-1,{
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.bounty = 10000;
&nbsp;&nbsp;&nbsp;&nbsp;.wanted_increments = 100000;
&nbsp;&nbsp;&nbsp;&nbsp;.mapname$ = "pvp_y_2-1";
&nbsp;&nbsp;&nbsp;&nbsp;.warp_death = 1;
&nbsp;&nbsp;&nbsp;&nbsp;.zeny_loss = .bounty;
&nbsp;&nbsp;&nbsp;&nbsp;end;

OnPCKillEvent:
&nbsp;&nbsp;&nbsp;&nbsp;if (strcharinfo(3) != .mapname$ && .mapname$ != "") {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;if (killedrid == getcharid(3)) {
	end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killedrid);
	.@zeny = getd(".bounty"+ getcharid(0) +"");
	setd ".bounty"+ getcharid(0) +"", 0;
	.@name$ = strcharinfo(0);
	if (.zeny_loss) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .zeny_loss) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= Zeny;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .zeny_loss;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killerrid);
	Zeny += .@zeny;
	setd ".bounty"+ getcharid(0) +"", getd(".bounty"+ getcharid(0) +"") + .bounty;
	announce "&#91;"+ strcharinfo(0) +"] has killed &#91;"+ .@name$ +"]. "+ (Sex?"He":"She") +" has a bounty of: "+ getd(".bounty"+ getcharid(0) +"") +" zeny! &#91; WANTED LEVEL "+ ( getd(".bounty"+ getcharid(0) +"") / .wanted_increments ) +" ]",bc_blue|bc_all;
&nbsp;&nbsp;&nbsp;&nbsp;if (.warp_death) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;warp "SavePoint",0,0;
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}

</pre>And that's it. We just finished making a Bounty Hunting PvP script, that doesn't involve having to do anything but kill. This should inspire people to want to pvp now.]]></description>
		<pubDate>Wed, 26 Nov 2014 02:17:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-98-bounty-hunting-pvp-script/</guid>
	</item>
	<item>
		<title><![CDATA[Intermediate Healer &#38; Buffer Script]]></title>
		<link>http://herc.ws/board/blog/29/entry-97-intermediate-healer-buffer-script/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Intermediate Healer & Buffer Script <sup class='bbc'>( 2 parts )</sup></strong></span><br />An intermediate version of the Basic Healer & Buffer Script.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><br /><br />Okay let's start by opening up the final version of our Basic Healer & Buffer Script.<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
switch( select("Yes, heal me.", "I want buffs", "No thank you") ) {
	case 1:
		if (Zeny &lt; .heal_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .heal_price;
		percentheal 100,100;
		break;
	
	case 2:
		if (Zeny &lt; .buff_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .buff_price;
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.heal_price = 1000;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_price = 5000;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />So what we're going to do here is edit our script quite a bit. but firstly we are going to make the zeny price for healing / buffing optional. To do that is simple. We just need to put our current zeny checks and zeny payment lines, into another <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1916' class='bbc_url' title='External link' rel='nofollow external'>if()</a> statement that simply checks to see if we set a variable to anything other than 0. The variable we are going to use is our <em class='bbc'><strong class='bbc'>.heal_price</strong></em> and <em class='bbc'><strong class='bbc'>.buff_price</strong></em><br />So let's make those changes:<pre class='prettyprint lang-auto linenums:0'>
if (.heal_price) {
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .heal_price) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "I'm sorry, but you don't have enough zeny.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .heal_price;
}
</pre>and<pre class='prettyprint lang-auto linenums:0'>
if (.buff_price) {
&nbsp;&nbsp;&nbsp;&nbsp;if (Zeny &lt; .buff_price) {
	mes "I'm sorry, but you don't have enough zeny.";
	close;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= .buff_price;
}
</pre><br />That takes care of the first part. Now this is where we get a little technical. We are going to add another variable that gets set every time the server starts / reloads. We are going to call it <em class='bbc'><strong class='bbc'>.include_buffs</strong></em>. And let's just set it to 1 since it's going to be a simple toggle on/off setting.<br />Also, make sure to place it above the other variables we set beforehand:<pre class='prettyprint lang-auto linenums:0'>
.include_buffs = 1;
</pre><br />Now this may not seem obvious, but this setting is going to let us decide whether or not players receive buffs when they pay for heals (free of charge). Assuming we are all kind admins. So let's add a check in <em class='bbc'><strong class='bbc'>case 1:</strong></em>.<br />It's going to check if the variable is set to 0. And then simply wrap the existing <em class='bbc'><strong class='bbc'>break;</strong></em> command inside that check:<pre class='prettyprint lang-auto linenums:0'>
if (!.include_buffs) {
&nbsp;&nbsp;&nbsp;&nbsp;break;
}
</pre><br />Doing this will let the script rn on through <em class='bbc'><strong class='bbc'>case 1:</strong></em> to <em class='bbc'><strong class='bbc'>case 2:</strong></em>. Next is a bit tricky, we are going to modify the way we set our .buff_price variable. To be more specific, we are going to use a <strong class='bbc'>(? <img src='http://herc.ws/board/public/style_emoticons/default/smile.png' class='bbc_emoticon' alt=':)' /></strong> check. For more information regarding <strong class='bbc'>(:?)</strong> look here: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L886' class='bbc_url' title='External link' rel='nofollow external'>Conditional Operator</a>.<br />Otherwise let's make the following changes:<pre class='prettyprint lang-auto linenums:0'>
.buff_price = ((.include_buffs)?0:5000);
</pre><br />Okay so this little bit of code is in short, just going to set the variable to <em class='bbc'><strong class='bbc'>0</strong></em> if we include buffs when they buy heals. Otherwise set the variable to <em class='bbc'><strong class='bbc'>5000</strong></em> which is what we said buffs cost normally.<br />Alright, so we only have 2 more changes to make, and that is simply 1 more check to determine whether or not we show them the buff price. Obviously, if buffs come with heals, we are going to just not show it so let's simply wrap the mes command dealing with showing buff pricing, into a check to see if <em class='bbc'><strong class='bbc'>.include_buffs</strong></em> is <em class='bbc'><strong class='bbc'>0</strong></em>, additionally let's make that check also check to see if <em class='bbc'><strong class='bbc'>.buff_price</strong></em> is above <strong class='bbc'><em class='bbc'>0</em></strong>.<pre class='prettyprint lang-auto linenums:0'>
if (!.include_buffs && .buff_price) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
}
</pre><br />And lastly, we are going to edit our menu. Again, this time we are going to use a (:?) check. We will be doing a little trick where we push the menu options down 1 slot. So let's edit our menu:<pre class='prettyprint lang-auto linenums:0'>
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
</pre><br />What this effectively allows us to do, is hide our option to choose <em class='bbc'><strong class='bbc'>"I want buffs" </strong></em>while still making sure the option <em class='bbc'><strong class='bbc'>"No thank you"</strong></em>, which is now shown as option 2, doesn't get directed to <em class='bbc'><strong class='bbc'>case 2:</strong></em> since it is used for buffs only.<br />And that's it. Your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if (.heal_price) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
}
if (!.include_buffs && .buff_price){
&nbsp;&nbsp;&nbsp;&nbsp;mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
}
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
	case 1:
		if (.heal_price) {
			if (Zeny &lt; .heal_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .heal_price;
		}
		percentheal 100,100;
		if (!.include_buffs) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
	
	case 2:
		if( .buff_price ){
			if( Zeny &lt; .buff_price ) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .buff_price;
		}
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.include_buffs = 1;
&nbsp;&nbsp;&nbsp;&nbsp;.heal_price = 1000;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_price = ( (.include_buffs)?0:5000 );
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>So there we go, we now just made the Zeny Price for Heals & Buffs optional. As well as made it so buffs can be included with heals. Lastly, this will work for free should you choose to.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><br />Okay, here we're going to make it so, players in a guild receive additional buffs, at no extra cost.<br /><br />So let's open up the script from before:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if (.heal_price) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
}
if (!.include_buffs && .buff_price){
&nbsp;&nbsp;&nbsp;&nbsp;mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
}
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
	case 1:
		if (.heal_price) {
			if (Zeny &lt; .heal_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .heal_price;
		}
		percentheal 100,100;
		if (!.include_buffs) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
	
	case 2:
		if( .buff_price ){
			if( Zeny &lt; .buff_price ) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .buff_price;
		}
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.include_buffs = 1;
&nbsp;&nbsp;&nbsp;&nbsp;.heal_price = 1000;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_price = ( (.include_buffs)?0:5000 );
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Alright, now let's add a mes command near the top that lets players know that they get more buffs if they are in a guild, also let's use ^0000FF as the color so it stands out:<pre class='prettyprint lang-auto linenums:0'>
mes "^0000FF *Note - Players in a guild receive additional buffs at no extra charge.* ^000000";
</pre><br />Next, beneath where we give them Increase AGI and Blessing, we are going to add a check to see if they are in a guild. Any guild doesn't matter so long as they are in one.<br />To do that we will need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2423' class='bbc_url' title='External link' rel='nofollow external'>getcharid(&lt;type&gt;{,"&lt;character name&gt;"})</a><pre class='prettyprint lang-auto linenums:0'>
if (getcharid(2)) {
</pre><br />Now we just need to give them more buffs. You can add as many as you like, but for this tutorial we're just going to give them Impositio Manus Level 5 and Assumptio Level 5:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_IMPOSITIO,300000,5;
&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_ASSUMPTIO,300000,5;
}
</pre><br />And that's it. We didn't do much here, but that's because the brunt of the work was done a long time ago. Now we are just expanding it with additional features. So your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if( .heal_price ){ mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000"; }
if( !.include_buffs && .buff_price ){ mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000"; }
mes "^0000FF *Note - Players in a guild receive additional buffs at no extra charge.* ^000000";
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
	case 1:
		if (.heal_price) {
			if (Zeny &lt; .heal_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .heal_price;
		}
		percentheal 100,100;
		if (!.include_buffs) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
	
	case 2:
		if (.buff_price) {
			if (Zeny &lt; .buff_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .buff_price;
		}
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		if (getcharid(2)) {
			sc_start SC_IMPOSITIO,300000,5;
			sc_start SC_ASSUMPTIO,300000,5;
		}
		break;
}
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.include_buffs = 1;
&nbsp;&nbsp;&nbsp;&nbsp;.heal_price = 0;
&nbsp;&nbsp;&nbsp;&nbsp;.buff_price = ( (.include_buffs)?0:5000 );
end;
}
</pre>That's it for our healer, we probably won't need to come back to this ever again. But we will, I assure you.]]></description>
		<pubDate>Wed, 26 Nov 2014 01:01:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-97-intermediate-healer-buffer-script/</guid>
	</item>
	<item>
		<title>Basic Player vs Player Script</title>
		<link>http://herc.ws/board/blog/29/entry-96-basic-player-vs-player-script/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Basic Player vs Player Script <sup class='bbc'>( 1 Part )</sup></strong></span><br />A Player vs Player script designed to introduce you to the basics needed to make them work.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><br />Okay this is going to be a short one. Despite what you may think, PvP scripts are actually very easy write and don't require much to get them to work.<br /><br />Let's start off by making a floating NPC:<pre class='prettyprint lang-auto linenums:0'>
-&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;pvp_script&nbsp;&nbsp;&nbsp;&nbsp;-1,{
</pre><br />So for this script, it is going to be a simple script that merely tells the player who it was that killed them. As well as giving he killer 1,000z. Simple right?<br />Let's start off by creating this label: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1055' class='bbc_url' title='External link' rel='nofollow external'>OnPCKillEvent</a><pre class='prettyprint lang-auto linenums:0'>
OnPCKillEvent:
</pre><br />Now, this part is important. When a Player kills another player, 2 variables are set. killerrid (The Killer) and killedrid (The Dead one). Additionally, OnPCKillEvent automatically attaches the script to the killer.<br />So, before we decided to give them zeny, let's check to make sure they didn't commit suicide. Because that'd be cheating!<br />To do that we'll use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2423' class='bbc_url' title='External link' rel='nofollow external'>getcharid(&lt;type&gt;{,"&lt;character name&gt;"})</a> and check it against the id of the player killed. If they are the same, then the killer committed suicide, so we'll end the script early.<br />Let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;if (getcharid(3) == killedrid) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre><br />Now that we've gotten that check out of the way, let's continue with the script and give the killer some zeny for doing a good job at slaying his opponent:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;Zeny += 1000;
</pre><br />Now we need to let the person who died know who killed him, so he can get revenge later. To do that we will use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4106' class='bbc_url' title='External link' rel='nofollow external'>attachrid(&lt;account ID&gt;)</a>.<br />Thankfully we already know what the dead person's account id is, because that is what killedrid is.<br />So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;attachrid(killedrid);
</pre><br />Now all that's left to do is let them know who killed them. We are going to use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4139' class='bbc_url' title='External link' rel='nofollow external'>dispbottom "&lt;message&gt;";</a> in combination with this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4119' class='bbc_url' title='External link' rel='nofollow external'>rid2name(&lt;rid&gt;)</a>.<br />Now remember when I said there were 2 commands set, well we already used killedrid, so now we will be using killerrid to get the name of the killer.<br />Easy right? Let's add it in and end the script:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "You were killed by: "+ rid2name(killerrid) +"";
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Once you've done that you are done. Your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	pvp_script	-1,{
OnPCKillEvent:
&nbsp;&nbsp;&nbsp;&nbsp;if (getcharid(3) == killedrid) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;Zeny += 1000;
&nbsp;&nbsp;&nbsp;&nbsp;attachrid( killedrid );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispbottom "You were killed by: "+ rid2name( killerrid ) +"";
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>I told you it was fast and simple.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Extra Information</strong></span><br />There is just 1 more thing I want you to know about the label <em class='bbc'><strong class='bbc'>OnPCKillEvent</strong></em> and the variables <em class='bbc'><strong class='bbc'>killerrid</strong></em> and <em class='bbc'><strong class='bbc'>killedrid</strong></em>. If you read the link I gave you, it was very vague about what it does.<br />So let me explain in more detail:<pre class='prettyprint lang-auto linenums:0'>
1. When a player kills another player, the label OnPCKillEvent is triggered.
2. The script is automatically attached to the killer.
3. (Important) The variable ' killedrid ' holds the dead person's account_id number. BUT, only the killer has this variable.
4. (Important) The variable ' killerrid ' holds the killing person's account_id number. BUT, only the dead person has this variable.
</pre>So that's it, just remember that when writing your own scripts.]]></description>
		<pubDate>Tue, 25 Nov 2014 23:52:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-96-basic-player-vs-player-script/</guid>
	</item>
	<item>
		<title>Basic Floating Rates Script</title>
		<link>http://herc.ws/board/blog/29/entry-95-basic-floating-rates-script/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Basic Floating Rates Script <sup class='bbc'>( 2 Parts )</sup></strong></span><br />Here we will create an npc that will adjust the base & job experience rates.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><br />Alright, so we're going to start off by making a floating npc header. It's similar to a normal npc header with the exception of replacing the <strong class='bbc'>&lt;map_name&gt;,&lt;x&gt;,&lt;y&gt;,&lt;facing&gt;</strong> with a simply hyphen ( <strong class='bbc'>-</strong> ), and the <strong class='bbc'>&lt;sprite_id&gt;</strong> with <em class='bbc'><strong class='bbc'>-1</strong></em>.<br /><br />So let's make our floating npc header and call our npc <strong class='bbc'><em class='bbc'>floating_rates</em></strong>:<pre class='prettyprint lang-auto linenums:0'>
-&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;floating_rates&nbsp;&nbsp;&nbsp;&nbsp;-1,{
</pre><br />Alright, since this is our third script in the beginner's series, we're going to speed things up a bit by not taking so much time to explain things ( this sentence & mandatory explanations being the exception ).<br />Now, since we want our script to activate everyday of the week, and change daily, we are going to use a label called: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L986' class='bbc_url' title='External link' rel='nofollow external'>OnClock&lt;hour&gt;&lt;minute&gt;:</a> The time we are going to use is <em class='bbc'><strong class='bbc'>0000</strong></em>:<pre class='prettyprint lang-auto linenums:0'>
OnClock0000:
</pre><br />Okay, now it's time to start adding in where we change the experience rates, but first we need to set 2 variables to a random value between <em class='bbc'>150 & 200</em>.<br />To do so we use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L7086' class='bbc_url' title='External link' rel='nofollow external'>rand(&lt;number&gt;{,&lt;number&gt;});</a> We're going to use scope variables, and we're going to call them base_exp & job_exp.<br />So go ahead and add that beneath our <em class='bbc'><strong class='bbc'>OnClock</strong></em> label:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;.@base_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;.@job_exp = rand(150,200);
</pre><br />We got that taken care of. Now we are going to actually change the base & job experience rates. To do that we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6847' class='bbc_url' title='External link' rel='nofollow external'>setbattleflag "&lt;battle flag&gt;",&lt;value&gt;;</a><br />A list of battle flags can be found in the files listed here: <a href='https://github.com/HerculesWS/Hercules/tree/master/conf/battle' class='bbc_url' title='External link' rel='nofollow external'>Battle Flags</a>. But we are only going to be using the following flags: <em class='bbc'><strong class='bbc'>base_exp_rate</strong></em> & <em class='bbc'><strong class='bbc'>job_exp_rate</strong></em><pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", .@base_exp;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", .@job_exp;
</pre><br />Alright, that's everything we need to do. So let's end the script and close it up:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />When you're done, your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	floating_rates	-1,{
OnClock0000:
&nbsp;&nbsp;&nbsp;&nbsp;.@base_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;.@job_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", .@base_exp;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", .@job_exp;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>And, now whenever your players kill a monster they will get that modified experience rate, that changes everyday at midnight.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><br />Okay, so last lesson we made a very basic floating rates npc that changes the rates everyday. However, now we are going to change that npc to only change rates during weekends.<br /><br />Let's start by opening up our script:<pre class='prettyprint lang-auto linenums:0'>
-	script	floating_rates	-1,{
OnClock0000:
&nbsp;&nbsp;&nbsp;&nbsp;.@base_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;.@job_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", .@base_exp;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", .@job_exp;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />So, to make it only work for <em class='bbc'>Friday, Saturday and Sunday</em>, we are going to change our label <em class='bbc'><strong class='bbc'>OnClock0000:</strong></em> to this label: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L989' class='bbc_url' title='External link' rel='nofollow external'>On&lt;weekday&gt;&lt;hour&gt;&lt;minute&gt;:</a>.<br />So let's change it for Firday same time:<pre class='prettyprint lang-auto linenums:0'>
OnFri0000:
</pre><br />Okay now that we got that taken care of, rates will change to a new random amount every Friday. However we want this to only last for the weekend, so we need to change them back starting Monday. That's right you guessed it, very similar setup but this time we'll be setting the rates back to normal so let's do it:<pre class='prettyprint lang-auto linenums:0'>
OnMon0000:
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", 100;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", 100;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />Right now your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	floating_rates	-1,{
OnFri0000:
&nbsp;&nbsp;&nbsp;&nbsp;.@base_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;.@job_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", .@base_exp;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", .@job_exp;
&nbsp;&nbsp;&nbsp;&nbsp;end;
OnMon0000:
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", 100;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", 100;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />As of right now it's almost done. Let's just edit it a bit, so that we let player's know when the experience rates change and what they changed to.<br />To do that we are going to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6481' class='bbc_url' title='External link' rel='nofollow external'>announce "&lt;text&gt;",&lt;flag&gt;{,&lt;fontColor&gt;{,&lt;fontType&gt;{,&lt;fontSize&gt;{,&lt;fontAlign&gt;{,&lt;fontY&gt;}}}}};</a> in combination with this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L6848' class='bbc_url' title='External link' rel='nofollow external'>getbattleflag("&lt;battle flag&gt;")</a><br />The <em class='bbc'>announcement_flag</em> we'll be using is <em class='bbc'><strong class='bbc'>bc_all</strong></em> with <em class='bbc'><strong class='bbc'>0x00FFFF</strong></em> as the color. For other flags look here: <a href='https://github.com/HerculesWS/Hercules/blob/master/db/const.txt#L302' class='bbc_url' title='External link' rel='nofollow external'>Broadcast Flags</a>. Additionally, you can use other hex color codes for the broadcast color in this format: <strong class='bbc'>0x<span style='color: #ff0000'>RR</span><span style='color: #008000'>GG</span><span style='color: #0000ff'>BB</span></strong><br />Now then let's add 1 announcement when we increase the rates:<pre class='prettyprint lang-auto linenums:0'>
announce "Bonus Experience Weekend has just started! Base Exp: +"+ (getbattleflag("base_exp_rate") - 100) +"% | Job Exp: +"+ (getbattleflag("job_exp_rate") - 100) +"% !!",bc_all,0x00FFFF;
</pre><br />And 1 announcement when we set the rates back:<pre class='prettyprint lang-auto linenums:0'>
announce "Bonus Experience Weekend has ended.",bc_all,0x00FFFF;
</pre><br />Make sure you added those announcements under the correct label, if you got them backwards you'll be confusing your players. Although, we are almost done so let's finish this.<br />The last thing we're going to do is add 1 more announcement that occurs every hour, to let player's know it is bonus exp weeked.<br />To do that we're going to use the label: <em class='bbc'><strong class='bbc'>OnMinute&lt;minute&gt;: </strong></em>and we are going to use <em class='bbc'><strong class='bbc'>00</strong></em> as the minute, additionally we need to use this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3152' class='bbc_url' title='External link' rel='nofollow external'>gettime(&lt;type&gt;)</a> so we can find out the day.<br />Mainly we need to check if it's Friday, Saturday or Sunday. So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
OnMinute00:
&nbsp;&nbsp;&nbsp;&nbsp;if (!gettime(4) || gettime(4) &gt;= 5){
	announce "Bonus Experience Weekend in progress! Base Exp: +"+ (getbattleflag("base_exp_rate") - 100) +"% | Job Exp: +"+ (getbattleflag("job_exp_rate") - 100) +"% !!",bc_all,0x00FFFF;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />When you're all done your script should look like this:<pre class='prettyprint lang-auto linenums:0'>
-	script	floating_rates	-1,{
OnFri0000:
&nbsp;&nbsp;&nbsp;&nbsp;.@base_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;.@job_exp = rand(150,200);
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", .@base_exp;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", .@job_exp;
&nbsp;&nbsp;&nbsp;&nbsp;announce "Bonus Experience Weekend has just started! Base Exp: +"+ (getbattleflag("base_exp_rate") - 100) +"% | Job Exp: +"+ (getbattleflag("job_exp_rate") - 100) +"% !!",bc_all,0x00FFFF;
&nbsp;&nbsp;&nbsp;&nbsp;end;
OnMon0000:
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "base_exp_rate", 100;
&nbsp;&nbsp;&nbsp;&nbsp;setbattleflag "job_exp_rate", 100;
&nbsp;&nbsp;&nbsp;&nbsp;announce "Bonus Experience Weekend has ended.",bc_all,0x00FFFF;
&nbsp;&nbsp;&nbsp;&nbsp;end;
	
OnMinute00:
&nbsp;&nbsp;&nbsp;&nbsp;if (!gettime(4) || gettime(4) &gt;= 5){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;announce "Bonus Experience Weekend in progress! Base Exp: +"+ (getbattleflag("base_exp_rate") - 100) +"% | Job Exp: +"+ (getbattleflag("job_exp_rate") - 100) +"% !!",bc_all,0x00FFFF;
	}
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>Save it and we are done. You just finished creating a Floating Rates NPC.]]></description>
		<pubDate>Tue, 25 Nov 2014 21:22:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-95-basic-floating-rates-script/</guid>
	</item>
	<item>
		<title>Basic Item Trader Script</title>
		<link>http://herc.ws/board/blog/29/entry-94-basic-item-trader-script/</link>
		<category></category>
		<description><![CDATA[<strong class='bbc'><span style='font-size: 36px;'>Basic Item Trader Script <span style='color: #0000ff'><sup class='bbc'>( 2 Parts )</sup></span></span></strong><br />A basic item trader script. Here we will learn how to give players an item in exchange for other items.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 1</strong></span><br />Alright, since you're here, I'm goign to assume you completed the previous guide and created a working Healer & Buffer script with a zeny cost. Or, you already know all that.<br />So let's start off by making our npc header. Don't forget to use those constants for sprite_id. For a list of sprite IDs and their constants check here: <a href='http://nn.nachtwolke.com/dev/npclist/?qq=all' class='bbc_url' title='External link' rel='nofollow external'>Sprite_IDs</a> Credits: <a href='http://herc.ws/board/user/260-ai4rei/' class='bbc_url' title=''>Ai4rei</a>. Additonally, the constants for those NPCs are also located in <a href='https://github.com/HerculesWS/Hercules/blob/master/db/const.txt' class='bbc_url' title='External link' rel='nofollow external'>const.txt</a>.<br /><br />For this npc, I'm going to be using the vending machine sprite and I'm going to name my npc Vending machine. You're free to choose your own sprite and name.<pre class='prettyprint lang-auto linenums:0'>
prontera,152,180,4&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;Vending Machine&nbsp;&nbsp;&nbsp;&nbsp;2_VENDING_MACHINE1,{
</pre><br />So let's start off by making the variables we'll be using for this script. And we're going to place those under the label: <strong class='bbc'>OnInit:</strong> again. We are also going to be using npc_variables as well. The only difference is that this we're going to be using arrays via the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2193' class='bbc_url' title='External link' rel='nofollow external'>setarray &lt;array name&gt;[&lt;first value&gt;],&lt;value&gt;{,&lt;value&gt;...&lt;value&gt;};</a> and don't forget to end it all with the <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1281' class='bbc_url' title='External link' rel='nofollow external'>end;</a> command.<br />Now, our script is going to give a Player, 1 Valkyrie_Helm for 5 different items. So let's add it in:<pre class='prettyprint lang-auto linenums:0'>
OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.reward_item = Valkyrie_Helm;
&nbsp;&nbsp;&nbsp;&nbsp;.reward_amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .request_items&#91;0], Red_Potion, White_Potion, Blue_Potion, Jellopy, Poring_Card;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_amount&#91;0], 10, 5, 1, 1000, 1;
&nbsp;&nbsp;&nbsp;&nbsp;end;
</pre><br />This tells us, that we're going to be giving a player, 1 Valkyrie helm for 10 Red Potions, 5 White Potions, 1 Blue Potion, 1000 Jellopy and 1 Poring card. Now that's easy!<br />Now we need to add in all of our mes commands to give our npc some dialogue. But, since this npc is gonna do a bit of talking let's save it's name in a temporary scope_variable:<pre class='prettyprint lang-auto linenums:0'>
.@npc_name$ = "&#91;^FF0000 Vending Machine ^000000]";
</pre><br />Now the variable <strong class='bbc'>.@npc_name$</strong> holds all that information inside of it. And it's definitely a lot easier to type. So let's add the <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1175' class='bbc_url' title='External link' rel='nofollow external'>mes</a> command beneath that with our variable:<pre class='prettyprint lang-auto linenums:0'>
mes .@npc_name$;
</pre><br />You'll notice I didn't use any quotation marks for that. This is because we used a string variable. And our string variable already has those quotation marks saved inside of it. Now then, let's add in the rest of the mes commands to let player's know how much 1 valkyrie helm costs. To do that were going to be utilizing the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2767' class='bbc_url' title='External link' rel='nofollow external'>getitemname(&lt;item id&gt;)</a> and where it asks for <em class='bbc'><strong class='bbc'>&lt;item_id&gt;</strong></em> we're going to be using our variables. So let's add the following lines in:<pre class='prettyprint lang-auto linenums:0'>
mes "I will give you "+ .reward_amount +" "+ getitemname(.reward_item) +",";
mes "for the following items:";
mes ""+ getitemname(.required_items&#91;0]) +" x"+ .required_amount&#91;0] +"";
mes ""+ getitemname(.required_items&#91;1]) +" x"+ .required_amount&#91;1] +"":
mes ""+ getitemname(.required_items&#91;2]) +" x"+ .required_amount&#91;2] +"":
mes ""+ getitemname(.required_items&#91;3]) +" x"+ .required_amount&#91;3] +"":
mes ""+ getitemname(.required_items&#91;4]) +" x"+ .required_amount&#91;4] +"":
</pre><br />See, that wasn't too hard. It's practically the same thing as the reward variables, just with the extra [#] added. Okay, next let's add in our menu. This time we're going to keep it to 2 options, so we're going to make it that if they choose option 2, end the script with <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1246' class='bbc_url' title='External link' rel='nofollow external'>close;</a> since we used <strong class='bbc'>mes</strong> earlier.<pre class='prettyprint lang-auto linenums:0'>
if (select("Trade in items", "That's a rip off!") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Okay, now that we got that taken care of. We need to add a few checks. The first check being whether or not they have those items. To do that we're going to use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4890' class='bbc_url' title='External link' rel='nofollow external'>countitem(&lt;item id&gt;)</a>.<br />Keep in mind that since we have 5 items to check for, we're going to be utilizing the <span style='color: #ff0000'><strong class='bbc'>| |</strong></span> operator. Now this is where things get a little technical, after each <span style='color: #ff0000'><strong class='bbc'>| |</strong></span> we're going to add the next check on the line beneath.<br />We're doing this to keep the script nice and neat. Would you rather look at 5 short lines, or 1 really long line that makes your head turn? So let's stick to 5 short lines.<br />Let's add our check below the <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1916' class='bbc_url' title='External link' rel='nofollow external'>if()</a> statement we did above. It should look something like this:<pre class='prettyprint lang-auto linenums:0'>
if ((countitem(.required_items&#91;0]) &lt; .required_amount&#91;0]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;1]) &lt; .required_amount&#91;1]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;2]) &lt; .required_amount&#91;2]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;3]) &lt; .required_amount&#91;3]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;4]) &lt; .required_amount&#91;4])) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You don't have all the required items.";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Now that we added the check to see if they have all the items, it's time to delete those items, and give them the reward! The commands that let us do that are the following respectively: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4861' class='bbc_url' title='External link' rel='nofollow external'>delitem &lt;item id&gt;,&lt;amount&gt;{,&lt;account ID&gt;};</a> and <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4589' class='bbc_url' title='External link' rel='nofollow external'>getitem &lt;item id&gt;,&lt;amount&gt;{,&lt;account ID&gt;};</a><br />So let's add that in below our check, and remember to use those variables:<pre class='prettyprint lang-auto linenums:0'>
delitem .required_items&#91;0], .required_amount&#91;0];
delitem .required_items&#91;1], .required_amount&#91;1];
delitem .required_items&#91;2], .required_amount&#91;2];
delitem .required_items&#91;3], .required_amount&#91;3];
delitem .required_items&#91;4], .required_amount&#91;4];
getitem .reward_item, .reward_amount;
</pre><br />Okay, now there's only 1 more thing to do, and that's add the last <span style='color: #ff0000'><strong class='bbc'>}</strong></span> to the very bottom of our script. After you add that you're done. You now have a working item trader script. It should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,154,180,4	script	Vending Machine	2_VENDING_MACHINE1,{
.@npc_name$ = "&#91;^FF0000 Vending Machine ^000000]";
mes .@npc_name$;
mes "I will give you "+ .reward_amount +" "+ getitemname(.reward_item) +",";
mes "for the following items:";
mes ""+ getitemname(.required_items&#91;0]) +" x"+ .required_amount&#91;0] +"";
mes ""+ getitemname(.required_items&#91;1]) +" x"+ .required_amount&#91;1] +"";
mes ""+ getitemname(.required_items&#91;2]) +" x"+ .required_amount&#91;2] +"";
mes ""+ getitemname(.required_items&#91;3]) +" x"+ .required_amount&#91;3] +"";
mes ""+ getitemname(.required_items&#91;4]) +" x"+ .required_amount&#91;4] +"";
if (select("Trade in items", "That's a rip off!") == 2) {
	close;
}
if ((countitem(.required_items&#91;0]) &lt; .required_amount&#91;0]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;1]) &lt; .required_amount&#91;1]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;2]) &lt; .required_amount&#91;2]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;3]) &lt; .required_amount&#91;3]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;4]) &lt; .required_amount&#91;4])){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You don't have all the required items.";
	close;
}
delitem .required_items&#91;0], .required_amount&#91;0];
delitem .required_items&#91;1], .required_amount&#91;1];
delitem .required_items&#91;2], .required_amount&#91;2];
delitem .required_items&#91;3], .required_amount&#91;3];
delitem .required_items&#91;4], .required_amount&#91;4];
getitem .reward_item, .reward_amount;
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.reward_item = Valkyrie_Helm;
&nbsp;&nbsp;&nbsp;&nbsp;.reward_amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_items&#91;0], Red_Potion, White_Potion, Blue_Potion, Jellopy, Poring_Card;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_amount&#91;0], 10, 5, 1, 1000, 1;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>You just finished making a working item trader npc. But it's not 100% done yet. We need to do a few more things. We'll deal with those in the next lesson. For now look at it, and be proud.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><br />Okay, last lesson I mentioned how the script wasn't 100% done yet, because there were a few things we needed to take care of. So let's knock those out.<br /><br />Firstly, let's start by opening the script from last time:<pre class='prettyprint lang-auto linenums:0'>
prontera,154,180,4	script	Vending Machine	2_VENDING_MACHINE1,{
.@npc_name$ = "&#91;^FF0000 Vending Machine ^000000]";
mes .@npc_name$;
mes "I will give you "+ .reward_amount +" "+ getitemname(.reward_item) +",";
mes "for the following items:";
mes ""+ getitemname(.required_items&#91;0]) +" x"+ .required_amount&#91;0] +"";
mes ""+ getitemname(.required_items&#91;1]) +" x"+ .required_amount&#91;1] +"";
mes ""+ getitemname(.required_items&#91;2]) +" x"+ .required_amount&#91;2] +"";
mes ""+ getitemname(.required_items&#91;3]) +" x"+ .required_amount&#91;3] +"";
mes ""+ getitemname(.required_items&#91;4]) +" x"+ .required_amount&#91;4] +"";
if (select("Trade in items", "That's a rip off!") == 2) {
	close;
}
if ((countitem(.required_items&#91;0]) &lt; .required_amount&#91;0]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;1]) &lt; .required_amount&#91;1]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;2]) &lt; .required_amount&#91;2]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;3]) &lt; .required_amount&#91;3]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;4]) &lt; .required_amount&#91;4])){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You don't have all the required items.";
	close;
}
delitem .required_items&#91;0], .required_amount&#91;0];
delitem .required_items&#91;1], .required_amount&#91;1];
delitem .required_items&#91;2], .required_amount&#91;2];
delitem .required_items&#91;3], .required_amount&#91;3];
delitem .required_items&#91;4], .required_amount&#91;4];
getitem .reward_item, .reward_amount;
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.reward_item = Valkyrie_Helm;
&nbsp;&nbsp;&nbsp;&nbsp;.reward_amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_items&#91;0], Red_Potion, White_Potion, Blue_Potion, Jellopy, Poring_Card;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_amount&#91;0], 10, 5, 1, 1000, 1;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre><br />Alright, now that we opened this up, we need to add a check to make sure the player has enough inventory space, and free-weight to carry the reward.<br />To do so we need to use the command:<a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3671' class='bbc_url' title='External link' rel='nofollow external'> checkweight(&lt;item id&gt;,&lt;amount&gt;{,&lt;item id&gt;,&lt;amount&gt;,&lt;item id&gt;,&lt;amount&gt;,...});</a> Only thin is, we're going to check to see if the command fails using this operator: <span style='color: #ff0000'><strong class='bbc'>!</strong></span><br />So let's go ahead and add that above the first <strong class='bbc'>delitem</strong> command:<pre class='prettyprint lang-auto linenums:0'>
if (!checkweight(.reward_item, .reward_amount)) {
</pre><br />This tells us that, if true ( if the command fails ) to do something. In our case, we want to just tell the player they don't have enough free-space/weight to receive the item. Then we're going to add a <strong class='bbc'>close;</strong> command to end the script early. And lastly close the check with <span style='color: #ff0000'><strong class='bbc'>}</strong></span>.<br />So let's go ahead and do that, it should look like this when it's done:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;mes "You don't have enough free inventory space or weight to receive this item.";
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Okay, now the script is finished, and you technically don't need to do anything else to it. But, we're here to learn! So we're going to clean up the script a bit using a loop.<br />The loop we will be using is called: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2073' class='bbc_url' title='External link' rel='nofollow external'>while (&lt;condition&gt;) &lt;statement&gt;;</a> There are other loops that can get the job done, but I feel like this one is best suited since it's simple.<br />Alright, so go ahead and delete the following from your script:<pre class='prettyprint lang-auto linenums:0'>
mes ""+ getitemname(.required_items&#91;0]) +" x"+ .required_amount&#91;0] +"";
mes ""+ getitemname(.required_items&#91;1]) +" x"+ .required_amount&#91;1] +"";
mes ""+ getitemname(.required_items&#91;2]) +" x"+ .required_amount&#91;2] +"";
mes ""+ getitemname(.required_items&#91;3]) +" x"+ .required_amount&#91;3] +"";
mes ""+ getitemname(.required_items&#91;4]) +" x"+ .required_amount&#91;4] +"";
</pre><br />Okay now where those <strong class='bbc'>mes</strong> commands used to be, we're going to add our loop. We're goign to be using a scope_variable <span style='color: #ff0000'><strong class='bbc'>.@</strong></span> and we're going to compare it to a value we obtain with this command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L2332' class='bbc_url' title='External link' rel='nofollow external'>getarraysize(&lt;array name&gt;)</a>.<br />So go ahead and add the following:<pre class='prettyprint lang-auto linenums:0'>
while (.@i &lt; getarraysize(.required_items)) {
</pre><br />Just a note, <em class='bbc'><strong class='bbc'>.@i</strong></em> can be any variable name. It doesn't even need to be a scope_variable. But since we only need the variable for this 1 loop, we use a scope_variable, so it's memory isn't saved once the script ends. However, <em class='bbc'><strong class='bbc'>.@i</strong></em> is most commonly used in cases like these. Now then let's continue.<br />Beneath that we're going to be adding 1 <strong class='bbc'>mes</strong> command followed by setting the variable <em class='bbc'><strong class='bbc'>.@i + 1</strong></em>.<br />On the line after that we're going to close the loop with <span style='color: #ff0000'><strong class='bbc'>}</strong></span>. I'm sure you've noticed I keep telling you to close either a script, if() statement, loop and the like with <em class='bbc'><strong class='bbc'>}</strong></em>. This is because we always need to make sure to close a command with a right-curly bracket <em class='bbc'><strong class='bbc'>}</strong></em> whenever a left-curly bracket <strong class='bbc'><em class='bbc'>{</em></strong> is used.<br /><br />Now, the <em class='bbc'><strong class='bbc'>mes</strong></em> command we're going to use is very similar to the ones we deleted. The only difference is, instead of using <em class='bbc'><strong class='bbc'>[0]</strong></em> or <em class='bbc'><strong class='bbc'> </strong></em> or <em class='bbc'><strong class='bbc'>[2]</strong></em>, we'll be replacing that with <em class='bbc'><strong class='bbc'>[.@i]</strong></em> as such:<pre class='prettyprint lang-auto linenums:0'>
&nbsp;&nbsp;&nbsp;&nbsp;mes ""+ getitemname(.required_items&#91;.@i]) +" x"+ .required_amount&#91;.@i] +"";
&nbsp;&nbsp;&nbsp;&nbsp;++.@i;
}
</pre><br />Okay since that's done we're about 80% done making this script nice and clean. There is only 1 more thing to do, and that's add 1 more <strong class='bbc'>while()</strong> loop. But this time, we're going to be replacing those <strong class='bbc'>delitem()</strong> commands with the loop. The difference is, instead of using <em class='bbc'><strong class='bbc'>.@i</strong></em> we're going to switch it to <em class='bbc'><strong class='bbc'>.@</strong></em><span style='font-size: 14px;'><strong class='bbc'><span style='color: rgb(255,0,0)'>j</span></strong></span> it is a lower-case J. If you're having a hard time reading that. So taking a look at our previous loop as an example, let's replace those <strong class='bbc'>delitem()</strong> commands with a loop:<pre class='prettyprint lang-auto linenums:0'>
while (.@j &lt; getarraysize(.required_items)) {
&nbsp;&nbsp;&nbsp;&nbsp;delitem .required_items&#91;.@j], .required_amount&#91;.@j];
&nbsp;&nbsp;&nbsp;&nbsp;++.@j;
}
</pre><br />Alright, now your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,154,180,4	script	Vending Machine	2_VENDING_MACHINE1,{
.@npc_name$ = "&#91;^FF0000 Vending Machine ^000000]";
mes .@npc_name$;
mes "I will give you "+ .reward_amount +" "+ getitemname(.reward_item) +",";
mes "for the following items:";
while (.@i &lt; getarraysize(.required_items)){
&nbsp;&nbsp;&nbsp;&nbsp;mes ""+ getitemname(.required_items&#91;.@i]) +" x"+ .required_amount&#91;.@i] +"";
&nbsp;&nbsp;&nbsp;&nbsp;++.@i;
}
if (select("Trade in items", "That's a rip off!") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
if ((countitem(.required_items&#91;0]) &lt; .required_amount&#91;0]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;1]) &lt; .required_amount&#91;1]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;2]) &lt; .required_amount&#91;2]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;3]) &lt; .required_amount&#91;3]) ||
&nbsp;&nbsp;&nbsp;&nbsp;(countitem(.required_items&#91;4]) &lt; .required_amount&#91;4])){
	mes "You don't have all the required items.";
	close;
}
if (!checkweight(.reward_item, .reward_amount)){
&nbsp;&nbsp;&nbsp;&nbsp;mes "You don't have enough free inventory space or weight to receive this item.";
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
while (.@j &lt; getarraysize(.required_items)){
&nbsp;&nbsp;&nbsp;&nbsp;delitem .required_items&#91;.@j], .required_amount&#91;.@j];
&nbsp;&nbsp;&nbsp;&nbsp;++.@j;
}
getitem .reward_item, .reward_amount;
close;

OnInit:
&nbsp;&nbsp;&nbsp;&nbsp;.reward_item = Valkyrie_Helm;
&nbsp;&nbsp;&nbsp;&nbsp;.reward_amount = 1;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_items&#91;0], Red_Potion, White_Potion, Blue_Potion, Jellopy, Poring_Card;
&nbsp;&nbsp;&nbsp;&nbsp;setarray .required_amount&#91;0], 10, 5, 1, 1000, 1;
&nbsp;&nbsp;&nbsp;&nbsp;end;
}
</pre>Go ahead and save that, because we are done.]]></description>
		<pubDate>Tue, 25 Nov 2014 18:30:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-94-basic-item-trader-script/</guid>
	</item>
	<item>
		<title><![CDATA[Basic Healer &#38; Buffer Script]]></title>
		<link>http://herc.ws/board/blog/29/entry-93-basic-healer-buffer-script/</link>
		<category></category>
		<description><![CDATA[<span style='font-size: 36px;'><strong class='bbc'>Basic Healer & Buffer Script <span style='color: #0000ff'><sup class='bbc'>(5 Parts)</sup></span></strong></span><br />A Basic Healer Script. Here we will cover most, if not all of the basics of scripting.<hr class='bbc' /><br /><strong class='bbc'><span style='font-size: 24px;'>Part 1</span></strong><br />Okay, for this healer were going to create one that heals you 100% HP&SP when you click on it and choose heal me.<br />So let's start off by wring the NPC header.<pre class='prettyprint lang-auto linenums:0'>
&lt;map name&gt;,&lt;x&gt;,&lt;y&gt;,&lt;facing&gt;%TAB%script%TAB%&lt;NPC Name&gt;%TAB%&lt;sprite id&gt;,{&lt;code&gt;}
 // Facing Directions, each number is the equivalent to a point on a compass.
 &#91;1]&#91;0]&#91;7]
 &#91;2]&nbsp;&nbsp; &#91;6]
 &#91;3]&#91;4]&#91;5]
</pre><br />Alright time to begin, starting with the NPC header:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;Healer&nbsp;&nbsp;&nbsp;&nbsp;4_F_ARUNA_POP,{
</pre><br />Now that we have the header out of the way it's time to write a little bit of dialogue.<br />To do that, we're going to use the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1175' class='bbc_url' title='External link' rel='nofollow external'>mes "&lt;text&gt;";</a> Additionally, we are going to be using the color codes, to make the name of the healer appear blue within the text box.<pre class='prettyprint lang-auto linenums:0'>
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
</pre><br />Okay, we got the little bit of dialogue out of the way. Now let's give them the choice of whether or not they want to be healed.<br />To do so, we're going to be using a combination of 2 commands. The first being: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1916' class='bbc_url' title='External link' rel='nofollow external'>if( &lt;condition&gt; ) { &lt;statement&gt; };</a> and Second: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1542' class='bbc_url' title='External link' rel='nofollow external'>select("&lt;option&gt;"{,"&lt;option&gt;",...})</a><br />But we are also going to end the script early, if they decided to choose: ' No thank you. ' by using the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1246' class='bbc_url' title='External link' rel='nofollow external'>close;</a><br />The reason we are using the <strong class='bbc'>close</strong> command, is because when we used <strong class='bbc'>mes</strong>, it caused a text window to open up. And we need to <em class='bbc'>close</em> that window. Simple right?<br />*Note - Options can be grouped together, separated by the character ' <span style='color: #ff0000'><strong class='bbc'>:</strong></span> '.*<br />If you are unsure what I mean by " condition " take a look at this: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L711' class='bbc_url' title='External link' rel='nofollow external'>Operators</a><pre class='prettyprint lang-auto linenums:0'>
if (select("Yes, heal me.", "No thank you.") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Now that we have that finished, it is time to heal them for 100% HP&SP using the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L4241' class='bbc_url' title='External link' rel='nofollow external'>percentheal &lt;hp&gt;,&lt;sp&gt;;</a><br />And also end the script. Again, using the <strong class='bbc'>close</strong> command.<pre class='prettyprint lang-auto linenums:0'>
percentheal 100,100;
close;
</pre><br />Now all we need to do is add the last <span style='color: #ff0000'><strong class='bbc'>}</strong></span> to the end of our script, so that it knows there is nothing more to add.<br />Once you're done, your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;Healer&nbsp;&nbsp;&nbsp;&nbsp;4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if (select("Yes, heal me.", "No thank you.") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
percentheal 100,100;
close;
}
</pre>And that's it for your first script. You just created a healer npc.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 2</strong></span><br />Okay, firstly you should have already completed <em class='bbc'><strong class='bbc'>Part 1</strong></em> of this tutorial. If not you need to do so to follow along.<br /><br />In <em class='bbc'>part 2</em>, we are going to be making a small edit to our script to let player's know it cost zeny to use the healer. Then we are going to check if they have enough zeny. If they do, we'll take some away and heal them.<br />Let's start by opening up the script we made in <em class='bbc'><strong class='bbc'>Part 1</strong></em>.<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4&nbsp;&nbsp;&nbsp;&nbsp;script&nbsp;&nbsp;&nbsp;&nbsp;Healer&nbsp;&nbsp;&nbsp;&nbsp;4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if (select("Yes, heal me.", "No thank you.") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
percentheal 100,100;
close;
}
</pre><br />Okay, let's add the following line above the menu options:<pre class='prettyprint lang-auto linenums:0'>
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
</pre><br />Next, directly above <strong class='bbc'>percentheal 100,100;</strong> we're going to be adding our check to see if they have enough zeny. If they do not, we'll be telling them that they don't have enough zeny. Then we'll end the script.<br />To do so, we're going to be using the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1916' class='bbc_url' title='External link' rel='nofollow external'>if( &lt;condition&gt; ) { &lt;statement&gt; };</a><br />If you are unsure what I mean by " condition " take a look at this: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L711' class='bbc_url' title='External link' rel='nofollow external'>Operators</a><pre class='prettyprint lang-auto linenums:0'>
if (Zeny &lt; 1000) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "I'm sorry, but you don't have enough zeny.";
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Okay we got the check out of the way. Now we just need to take the zeny away from them if they do have enough zeny.<br />To do that we'll be setting the <a href='https://github.com/HerculesWS/Hercules/blob/master/db/const.txt' class='bbc_url' title='External link' rel='nofollow external'>Constant Variable</a> Zeny to a value of Zeny - 1000. To see how this is done look here: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L577' class='bbc_url' title='External link' rel='nofollow external'>Assigning variables</a><br />Now then, lets add it in:<pre class='prettyprint lang-auto linenums:0'>
Zeny -= 1000;
</pre><br />And that's all there is to edit. When you're done it should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
if (select("Yes, heal me.", "No thank you.") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
if (Zeny &lt; 1000) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "I'm sorry, but you don't have enough zeny.";
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
Zeny -= 1000;
percentheal 100,100;
close;
}
</pre>And that's it, you just finished editing your script, and now it costs players 1,000 zeny to get healed.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 3</strong></span><br />Alright, to start this off. I'm assuming you already finished <strong class='bbc'><em class='bbc'>Part 1 & 2</em></strong>. If not, I recommend you do so,<br />since we will be using those scripts to make this one. I will attempt to continue this pattern until we deviate away from the healer and move on to a different type of script.<br /><br />So first, let's open up the script we made in <strong class='bbc'>Part 2</strong>.<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
if (select("Yes, heal me.", "No thank you.") == 2) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
if (Zeny &lt; 1000) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "I'm sorry, but you don't have enough zeny.";
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
Zeny -= 1000;
percentheal 100,100;
close;
}
</pre><br />Let's start by adding a MES to show how much they cost. For this script were going to make it nice and cheap. 5,000z to get both INCREASED AGI & BLESSING Lvl 10.<br />And were going to add this right above our menu options.<pre class='prettyprint lang-auto linenums:0'>
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
</pre><br />Now that people know we offer buffs, we need to give them the option to choose to get buffed.<br />So lets modify our menu to have a 3rd option.<pre class='prettyprint lang-auto linenums:0'>
if (select("Yes, heal me.", "I want buffs", "No thank you.") == 3) {
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Now that we got that out of the way. It's time to modify our zeny check. It's going to be customized a little bit.<br />Were now going to use <strong class='bbc'><span style='color: #ff0000'>| |</span></strong> and <strong class='bbc'><span style='color: #ff0000'>&&</span></strong> operators in our checks.<br />So go ahead and find our zeny check and change it to the below:<pre class='prettyprint lang-auto linenums:0'>
if ((Zeny &lt; 1000 && @menu == 1) || (Zeny &lt; 5000 && @menu == 2)) {
&nbsp;&nbsp;&nbsp;&nbsp;mes "I'm sorry, but you don't have enough zeny.";
&nbsp;&nbsp;&nbsp;&nbsp;close;
}
</pre><br />Your probably wondering why were using @menu == 1 or @menu == 2. This is because when ever a menu option is selected, the variable @menu is set to that option. So, the first option is equal to 1, and the second is equal to 2, so on and so forth.<br /><br />At anyrate, since we are still in the beginner section of scripting, were going to be adding 1 more check to our script.<br />So go ahead and add the following to your script beneath the checks we did above:<pre class='prettyprint lang-auto linenums:0'>
if (@menu == 1) {
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= 1000;
&nbsp;&nbsp;&nbsp;&nbsp;percentheal 100,100;
}
</pre><br />However, this isn't complete. We still need to add the last part, which deals with our buffs.<br />To do that we're going to be using the command: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L5399' class='bbc_url' title='External link' rel='nofollow external'>sc_start &lt;effect type&gt;,&lt;ticks&gt;,&lt;value 1&gt;{,&lt;rate&gt;,&lt;flag&gt;{,&lt;GID&gt;}};</a><br />Where, effect type is the buff we want to give them, ticks is how long it will last in 1/1000ths of a second, and value is the level of the buff.<br /><br />In our case, we are using Blessing Level 10 and AGI-UP Level 10. And to keep things simple, we're going to make it last for 5mins each.<br />If you wish to add other status-effects then look in this file: <a href='https://github.com/HerculesWS/Hercules/blob/master/db/const.txt#L703' class='bbc_url' title='External link' rel='nofollow external'>const.txt</a>. It will be the things starting with: SC_ .<br />So, let's start by finding our previous check and find: <strong class='bbc'><span style='color: #ff0000'>}</span></strong> . And add the following next to it:<pre class='prettyprint lang-auto linenums:0'>
else {
&nbsp;&nbsp;&nbsp;&nbsp;Zeny -= 5000;
&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_BLESSING,300000,10;
&nbsp;&nbsp;&nbsp;&nbsp;sc_start SC_INC_AGI,300000,10;
}
</pre><br />So your probably looking at the 300000 and wondering why it's like that. Well the answer is simple.<br />Ticks are 1/1,000ths of a second. So to find 5 minutes we do the following math.<br />1 * 1,000 = 1 second * 60 = 60,000 OR 1 Minute * 5 = 300,000 OR 5 Minutes. So now that we have our number we just put it in.<br />Okay, now that it's done. Your script should look like the following:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
if (select("Yes, heal me.", "I want buffs", "No thank you.") == 3) {
	close;
}
if ((Zeny &lt; 1000 && @menu == 1) || (Zeny &lt; 5000 && @menu == 2)) {
	mes "I'm sorry, but you don't have enough zeny.";
	close;
}
if (@menu == 1) {
	Zeny -= 1000;
	percentheal 100,100;
} else {
	Zeny -= 5000;
	sc_start SC_BLESSING,300000,10;
	sc_start SC_INC_AGI,300000,10;
}
Zeny -= 1000;
percentheal 100,100;
close;
}
</pre><br />Now we're just going to delete those last 2 lines above <em class='bbc'><strong class='bbc'>close;</strong></em><br />When you're finished deleting them, your script will be done. And it should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
if (select("Yes, heal me.", "I want buffs", "No thank you.") == 3) {
	close;
}
if ((Zeny &lt; 1000 && @menu == 1) || (Zeny &lt; 5000 && @menu == 2)) {
	mes "I'm sorry, but you don't have enough zeny.";
	close;
}
if (@menu == 1) {
	Zeny -= 1000;
	percentheal 100,100;
} else {
	Zeny -= 5000;
	sc_start SC_BLESSING,300000,10;
	sc_start SC_INC_AGI,300000,10;
}
close;
}
</pre>And that's it. You just finished editing your script and now players have the option to receive Increased AGI and Blessing Level 10 at the cost of 5,000 zeny.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 4</strong></span><br />Okay, so by now, you've learned how to make a pretty standard healing npc. But, it looks kind of messy. So in this lesson, we're going to clean it up, by getting rid of some of those <em class='bbc'>if( stantements )</em>.<br /><br />So as always, let's start by opening up the previous script:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
if (select("Yes, heal me.", "I want buffs", "No thank you.") == 3) {
	close;
}
if ((Zeny &lt; 1000 && @menu == 1) || (Zeny &lt; 5000 && @menu == 2)) {
	mes "I'm sorry, but you don't have enough zeny.";
	close;
}
if (@menu == 1) {
	Zeny -= 1000;
	percentheal 100,100;
} else {
	Zeny -= 5000;
	sc_start SC_BLESSING,300000,10;
	sc_start SC_INC_AGI,300000,10;
}
close;
}
</pre><br />What were going to do here is just delete everything after the last mes command. So highlight everything beneath that and just press DELETE or BACKSPACE ( your choice =P ).<br /><br />When your done your script should look like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
</pre><br />Looks like we went back to the drawing board. But don't worry, you'll be doing this a lot down the line when writing your own scripts. Finding better ways to write it and such. So, let's start by adding the following line beneath it.<br /><br />This will serve as our new menu:<pre class='prettyprint lang-auto linenums:0'>
switch(select("Yes, heal me.", "I want buffs", "No thank you")) {
</pre>I'm sure you've noticed the ' switch ' which took the place of ' if '. We also got rid of the ' == 3 ' part. This is because switch is much cleaner and easier to read. But, first let's explain what it does. Simply, all it does is cycle through labels called: <em class='bbc'><strong class='bbc'>case 1: case 2:</strong></em> etc... depending on the value of a variable or number. In our case, it's the variable @menu which will have either a value of 1, 2 or 3 because of our menu.<br /><br />If you want a further explanation, you can click the spoiler below for a bit more detail. Otherwise, let's continue to the next step.<div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;"><pre class='prettyprint lang-auto linenums:0'>
switch( select("Yes, heal me.", "I want buffs.", "No thank you.") ) { }
// When you select either of the above, it will assign the variable:
// @menu to it's corresponding slot in the menu.
// In our case:
// "Yes, heal me." = 1&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;"I want buffs." = 2&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;"No thank you." = 3

Utilizing the switch() command in combination with our menu we can clean up our scripts to do this:

switch( select("Yes, heal me.", "I want buffs.", "No thank you.") ) { 
&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You chose option 1, ' Yes, heal me. ' ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You chose option 2, ' I want buffs. ' ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;case 3:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
}
close; // &lt;--- This will end the script for all 3 options.

// Additionally the above is the exact same as this:

select("Yes, heal me.", "I want buffs.", "No thank you.");
switch( @menu ) {
&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You chose option 1, ' Yes, heal me. ' ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You chose option 2, ' I want buffs. ' ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;case 3:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
}
close;

// However, both of those have an unnecessary part. And that part is:
case 3:
&nbsp;&nbsp;&nbsp;&nbsp;break;
// We can remove it since it does nothing, or we just want the to end the script with close. 
// So we can make it look like this, which will be the final product:

switch( select("Yes, heal me.", "I want buffs.", "No thank you.") ) { 
&nbsp;&nbsp;&nbsp;&nbsp;case 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You chose option 1, ' Yes, heal me. ' ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;case 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mes "You chose option 2, ' I want buffs. ' ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
}
close; // &lt;--- This will end the script for all 3 options.
</pre></div></div>
</div>Okay, let's add the sub-label: <strong class='bbc'><em class='bbc'>case 1:</em></strong> to our script. This will deal with players click on " Yes, heal me. ". Let's also add the zeny check & percentheal in there as well.<br /><br />So add the following:<pre class='prettyprint lang-auto linenums:0'>
case 1:
	if (Zeny &lt; 1000) {
		mes "I'm sorry, you don't have enough zeny.";
		close;
	}
	Zeny -= 1000;
	percentheal 100,100;
	break;
</pre><br />That's done. I'm sure you see the command: <em class='bbc'><strong class='bbc'>break;</strong></em> there. What this does is allow us to ' exit ', a pair of <span style='color: #ff0000'><strong class='bbc'>{ }</strong></span><strong class='bbc'>. </strong>Doing so, will allow us to continue on with the script if there is some other things to do. You can take a look at the spoiler above to see how we utilize this. Other wise, let's go a head and make the second label: <strong class='bbc'><em class='bbc'>case 2:</em></strong> beneath all of that.<br /><br />This one will deal with when they click on " I want buffs. ", so we are going to be adding the zeny check for that, along with the buffs:<pre class='prettyprint lang-auto linenums:0'>
case 2:
	if (Zeny &lt; 5000) {
		mes "I'm sorry, but you don't have enough zeny.";
		close;
	}
	Zeny -= 5000;
	sc_start SC_BLESSING,300000,10;
	sc_start SC_INC_AGI,300000,10;
	break;
</pre><br />Now that we got that out of the way. Let's add <span style='color: #ff0000'><strong class='bbc'>}</strong></span> to the end of that, to let the script know were done with the: switch() command. Then directly beneath that, were going to add: close; To let the script knows that were ending it. Followed by the final <span style='color: #ff0000'><strong class='bbc'>}</strong></span> so that the script knows that there is nothing more to do.<pre class='prettyprint lang-auto linenums:0'>
}
close;
}
</pre><br />Once your done with that, your script should look something like the below:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
switch( select("Yes, heal me.", "I want buffs", "No thank you") ) {
	case 1:
		if (Zeny &lt; 1000) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= 1000;
		percentheal 100,100;
		break;
	
	case 2:
		if (Zeny &lt; 5000) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= 5000;
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;
}
</pre>And there you go, you just finished cleaning up your script. It looks much better, and it still does the exact same thing! Who would of thought.<hr class='bbc' /><br /><span style='font-size: 24px;'><strong class='bbc'>Part 5</strong></span><br />Alright, so far we've completed Parts 1 -&gt; 4. And we have a working script because of it. Now, what we need to do is, make it easily configurable. Sure, we could scroll through the script, and change the zeny prices. But if we do that, we might make a mistake. So what were going to do is, add a label called: <em class='bbc'><strong class='bbc'>OnInit:</strong></em> in our script. This label will active each and every time the server starts up, or scripts are reloaded.<br />And under this label we'll be adding our variables, which will be our focus for when we want to configure things in our script.<br /><br />For a list of all variable types look here: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L436' class='bbc_url' title='External link' rel='nofollow external'>Variables</a><br />So go ahead and open up the script from the last lesson:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
switch( select("Yes, heal me.", "I want buffs", "No thank you") ) {
	case 1:
		if (Zeny &lt; 1000) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= 1000;
		percentheal 100,100;
		break;
	
	case 2:
		if (Zeny &lt; 5000) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= 5000;
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;
}
</pre><br />We are going to add the: <em class='bbc'><strong class='bbc'>OnInit:</strong></em> label beneath the final: close; command. But let's also add a couple of <em class='bbc'>npc_variables</em> there as well. And let's name those variables: <em class='bbc'><strong class='bbc'>heal_price</strong></em> and <em class='bbc'><strong class='bbc'>buff_price</strong></em> .<br /><br />Remeber, those are NPC variables. So let's go ahead and add the following:<pre class='prettyprint lang-auto linenums:0'>
OnInit:
.heal_price = 1000;
.buff_price = 5000;
</pre><br />Here you can see we used the <strong class='bbc'><em class='bbc'>set</em></strong> command. This is because we are telling the script to set those variables, to those values. In this case, <strong class='bbc'>.heal_price to 1,000</strong> and <strong class='bbc'>.buff_price to 5,000</strong> since that is what our script uses as prices for healing and buffing. Now, we really should add this command beneath that: <a href='https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1281' class='bbc_url' title='External link' rel='nofollow external'>end;</a> .<br />Go ahead and click that link to find out why we need to add it.<pre class='prettyprint lang-auto linenums:0'>
end;
</pre><br />Alright, we have officially created variables. However as they are now, they aren't doing anything and just taking up space. So now were going to put them to use. Let's comb through our script and find all of our zeny checks. Let's replace all those: 1000 and 5000 with the corresponding variables.<br />When your done, your script should look like this so far:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs 1,000 zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs 5,000 zeny.* ^000000";
switch( select("Yes, heal me.", "I want buffs", "No thank you") ) {
	case 1:
		if (Zeny &lt; .heal_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .heal_price;
		percentheal 100,100;
		break;
	
	case 2:
		if (Zeny &lt; .buff_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .buff_price;
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
.heal_price = 1000;
.buff_price = 5000;
end;
}
</pre><br />Now, there being put to use! But wait, if you look at the mes commands, they still say 1,000 and 5,000 in them. This isn't good, because if we change the values of our variables, those mes commands won't show the proper amount. And we don't want to type it out EACH and EVERY time we make changes. So let's edit that text. So go over to the line that tells players how much healing costs.<br />And were going to make the following changes:<pre class='prettyprint lang-auto linenums:0'>
mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
</pre><br />So, as your looking at this, you'll see the following was removed: <em class='bbc'>1,000</em> and the following was added in it's place: <strong class='bbc'>"+ .heal_price +"</strong> pay close attention to this, as it's very important. Take a close look at these: <span style='color: #ff0000'><strong class='bbc'>"+</strong></span> and <span style='color: #ff0000'><strong class='bbc'>+"</strong></span> .<br />I'm going to go a bit into detail on why we need these in this spoiler. If you already know why we used them, continue on with the lesson.<div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;"><br />Firstly, when ever we use the <em class='bbc'>mes</em> command, we need to make a <em class='bbc'><strong class='bbc'>string</strong> of text</em> keyword here is: string. All strings begin with a quotation mark <span style='color: #ff0000'><strong class='bbc'>"</strong></span> and ends with a quotation mark <span style='color: #ff0000'><strong class='bbc'>"</strong></span>.<br />Everything in between those 2 quotation marks is considered text. And as such will be written out like a sentence. But when we add those "+ and +" we tell the script that we are going to be putting something in the middle of this string.<br />In our case it's the variable .heal_price . The server will then look at this variable and then put down it's data value in stead of its name. Which, we set to 1000. When it's all said and done, this is what a player will see:<br /><span style='color: #ff0000'>*Note - It costs 1000 zeny to get healed.*</span> Not bad huh.</div></div>
</div><br />Okay, now let's make the same changes to line where we tell players how much it costs to get buffed, but using the other variable this time:<pre class='prettyprint lang-auto linenums:0'>
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
</pre><br />After that we are done! So, your script should look something like this:<pre class='prettyprint lang-auto linenums:0'>
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "&#91;^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
mes "^FF0000 *Note - INCREASED AGI + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
switch( select("Yes, heal me.", "I want buffs", "No thank you") ) {
	case 1:
		if (Zeny &lt; .heal_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .heal_price;
		percentheal 100,100;
		break;
	
	case 2:
		if (Zeny &lt; .buff_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .buff_price;
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
.heal_price = 1000;
.buff_price = 5000;
end;
}
</pre>Now, every time we want to change how much getting healed or buffed costs, we just change the values of those variables.]]></description>
		<pubDate>Tue, 25 Nov 2014 05:03:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-93-basic-healer-buffer-script/</guid>
	</item>
	<item>
		<title>Scripting Techniques, Tutorials and Guides</title>
		<link>http://herc.ws/board/blog/29/entry-92-scripting-techniques-tutorials-and-guides/</link>
		<category></category>
		<description><![CDATA[Hey everyone, my Scripting Support topic has reached it's physical limits. Any more and the topic would just explode into a million characters!<br />So in order to continue helping everyone learn how to script, I'm going to be slowly migrating the Tutorials and Guides from my <a href='http://herc.ws/board/topic/7513-scripting-techniques-tutorialsguides/' class='bbc_url' title=''>Support Topic</a> to this blog.<br />As a result, this will also allow me to organize it easier ( no more spoiler spamming ). And as always, I'll try my best to make continuous posts with new scripts, so as to expand your scripting knowledge even further.<br /><br />Thank you for your patience and support <img src='http://herc.ws/board/public/style_emoticons/default/biggrin.png' class='bbc_emoticon' alt=':D' />]]></description>
		<pubDate>Tue, 25 Nov 2014 04:46:00 +0000</pubDate>
		<guid>http://herc.ws/board/blog/29/entry-92-scripting-techniques-tutorials-and-guides/</guid>
	</item>
</channel>
</rss>