Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 11-06-2011, 11:46 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

This is a way to do what you want. I added some error handling, so the npc will ignore anything said to it that isn't in the hash.

You had a few errors. A missing ; at the end of the hash statement, using () instead of {} to extract data from the hash, and some case issues.

As you go forward with this it might help to have the npc echo back the text you're sending it, by adding a quest::say($text); at the top. This would help you to see why it wouldn't have worked the way you were doing it. Specifically, hailing sends more than "Hail", which is what the split is for, and your saylink sends "Cookie" but the hash uses "cookie" as a key, which is what the lc() is for. It will also let someone say "No", "no", "nO", etc to the npc and still get the proper result.

Code:
sub EVENT_SAY
{
	my $cookie = quest::saylink("Cookie");
	my $cookieid = quest::varlink("19732");

	my %dadscookies = ("hail" => "Would you like a [$cookie]?",
			  "cookie" => "Yes, a Cookie! Here is what it looks like [$cookieid]",
			  "no" => "Okay, I will eat it!"
			  );
			  
	my @txt = split(",",lc($text));
	if(exists($dadscookies{$txt[0]}))
	{
		quest::say($dadscookies{$txt[0]});
	}
}

Last edited by lerxst2112; 11-06-2011 at 11:53 PM.. Reason: Added error handling.
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:08 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3