View Single Post
  #3  
Old 09-11-2009, 04:08 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Just an FYI, but, you should never use quest globals like this:

Code:
 elsif($text=~/Hail/i && $rin_quest == 1)
By doing that, it will pull the qglobal information, but it will also save the value of $rin_quest as a variable in that particular script. This means that once one person that has that qglobal hails this NPC, the next person to hail it will also get the same response. This is because the NPC will then see $rin_quest as being equal to 1 since that is what the last player set the variable to on that particular script when they spoke to it.

To use qglobals the right way and ensure that you never run into issues that could cause you major headaches (believe me, I have been through this myself lol), then use them in this way instead:

Code:
 elsif($text=~/Hail/i && $qglobals{rin_quest} == 1)
Doing this will ensure 100% that the variable value does not get saved on the NPC. So, each player that interacts with it will get the actual results of the qglobals they have set instead of possibly gaining access to things that others have earned before them.

Also, I didn't review the full script you have there completely, but your elsif here would definitely be a problem:

Code:
if($text=~/Hail/i)
 	{
 	quest::emote("jumps at your voice, and begins breathing heavily...");
 	$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
 	}

 elsif($text=~/Hail/i && $rin_quest == 1)
	{
	$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
	}
An elsif will only trigger if the first "if" was false. In this case, if a player hails an NPC, the first one will always be true, so it will never get to the second elseif.

A better way to write this might be the following:

Code:
	if($text=~/Hail/i)
 	{
 	 	if($qglobals{rin_quest} == 1)
		{
			$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
		else
		{
 			quest::emote("jumps at your voice, and begins breathing heavily...");
 			$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
		}
	}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 09-11-2009 at 04:14 AM..
Reply With Quote