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

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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2013, 01:18 AM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default Quest crashing zone and client

I posted earlier about keeping a tally of quests completed. I couldn't figure it out. So I decided to use repetitive if statements and setting the global in each if statement manually. However, It now crashes my client and the zone on the 4th turn in.

Here is the error I get:



Here is the code:

Code:
my $luck = quest::saylink("luck");
my $pay = quest::saylink("pay");
my $someone = quest::saylink("some one");

sub EVENT_SAY
{
	if ($text=~/Hail/i)
	{
		if (( defined $qglobals{fish_mort} && $qglobals{fish_mort} == 4))
		{
			plugin::Whisper("Thanks for helping me with the fish, %name. Now that I have all this food, I wish I had $someone to share it with.");
		}
		
		else
		{
			quest::doanim(28);
			quest::emote("sighs heavily.");
			plugin::Whisper("Oh, hey there, $name. You're new here. Welcome to town. I hope you've made some friends. Not me... Anyway, I've not had much $luck here today.");
		}
	}
	
	elsif($text=~/luck/i)
	{
		plugin::Whisper("No, my luck has been pretty abysmal. I'm trying to catch some Red Fin fish. I'll $pay you for any you may have.");
	}
	
	elsif($text=~/pay/i)
	{
		plugin::Whisper("Of course. They aren't worth much, but none the less, I'll pay you for every four you bring me.");
	}
}

sub EVENT_ITEM
{
	if ((plugin::check_handin(\%itemcount, 1374 => 4)))
	{
		if ((!defined $qglobals{fish_mort}))
		{
			quest::setglobal("fish_mort","1","4","F");
			plugin::Whisper("Well thanks, friend.. er.. stranger. ");
			quest::givecash(2,0,0,0);
			quest::exp("5000");
			quest::ding();
			
		}
		
		elsif ((defined $qglobals{fish_mort} && $qglobals{fish_mort} == 1))
		{
			quest::setglobal("fish_mort","2","4","F");
			plugin::Whisper("Well thanks, $name");
			quest::givecash(2,0,0,0);
			quest::exp("5000");
			quest::ding();
			
		}
		
		elsif ((defined $qglobals{fish_mort} && $qglobals{fish_mort} == 2))
		{
			quest::setglobal("fish_mort","3","4","F");
			plugin::Whisper("Well thanks, friend. Here is your payment.");
			quest::givecash(2,0,0,0);
			quest::exp("5000");
			quest::ding();
			
		}
		
		elsif ((defined $qglobals{fish_mort} && $qglobals{fish_mort} == 3))
		{
			quest::setglobal("fish_mort","4","4","F");
			plugin::Whisper("Thanks for helping me with the fish, %name. Now that I have all this food, I wish I had $someone to share it with.");
			quest::givecash(2,0,0,0);
			quest::exp("5000");
			quest::ding();
			
		}
		
		
	}
	
	my $return_count = ( ( scalar keys %itemcount ));
	
	if ( $return_count > 1 ) 
	{      
        my $return_template = "I don't want %s. Here, take %s back, $name.";       
        my @return_noun =
          $return_count > 2
          ? ( "these", "them" )
          : ( "this", "it" );      
        plugin::Whisper( sprintf $return_template, @return_noun );
    }
	 plugin::return_items( \%itemcount );
}
The goal is to turn in item 1374 x 4. On the fourth turn in, fish_mort is set to 4, enabling a new quest. I'd prefer not use repetitive tasks, but the more technical way of adding to the global value per turn in is beyond my understanding. I decided to keep it simple for the time being.

Also, I tried deleting the global in the last three if statements before resetting it. However, it just got stuck in a loop of setting the value to 1, 2, 1, 2, etc.

I deleted my global value for the character and retested it several times with the same results.

Also note:

Code:
elsif ((defined $qglobals{fish_mort} && $qglobals{fish_mort} == 1))
If I do not use double parenthesis the quest either stops functioning completely to all client input (ie hail) or crashes the client and zone. This seems to be different than most people's quests. Losing my mind here.

Thanks in advance!
__________________
Disorder
Reply With Quote
  #2  
Old 02-26-2013, 02:52 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

*edit: nevermind, let me look again.. you said you made multiple if statements, yet, they are elsifs. Be back, unless someone beats me to the punch.
Reply With Quote
  #3  
Old 02-26-2013, 03:01 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

use $name, not %name.

it's crashing because it's trying to use the %n part of '%name' in your last message as a format specifier.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #4  
Old 02-26-2013, 03:07 AM
Zamthos
Discordant
 
Join Date: Jan 2013
Posts: 284
Default

Well, yeah, I didn't see the %name but that would make sense. Tried helping him, didn't see that. Hehe.
Reply With Quote
  #5  
Old 02-26-2013, 03:11 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

always test your scripts from a command line like this to easily catch syntax errors and other such things:

Code:
perl -cW path/to/script.pl
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #6  
Old 02-26-2013, 03:21 AM
Zamthos
Discordant
 
Join Date: Jan 2013
Posts: 284
Default

I use this:
What does the W do?

Code:
 perl -c path/to/script.pl
Reply With Quote
  #7  
Old 02-26-2013, 03:26 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

thw W enables all warnings (like telling you that you are using a variable only once)

running this file that way

warnMe.pl
Code:
$warnMe;
results in this

Code:
perl -cW warnMe.pl
Useless use of a variable in void context at warnMe.pl line 1.
Name "main::warnMe" used only once: possible typo at warnMe.pl line 1.
warnMe.pl syntax OK
http://perldoc.perl.org/perlrun.html#Command-Switches
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #8  
Old 02-26-2013, 03:28 AM
Drajor's Avatar
Drajor
Developer
 
Join Date: Nov 2012
Location: Halas
Posts: 355
Default

Quote:
Originally Posted by Zamthos View Post
I use this:
What does the W do?

Code:
 perl -c path/to/script.pl
Quote:
prints warnings about dubious constructs, such as variable names mentioned only once and scalar variables used before being set; redefined subroutines; references to undefined filehandles; filehandles opened read-only that you are attempting to write on; values used as a number that don't look like numbers; using an array as though it were a scalar; if your subroutines recurse more than 100 deep; and innumerable other things.
http://perldoc.perl.org/perlrun.html#Command-Switches

Use google, saves everyone time with trivialities.
__________________
Drajor regards you indifferently -- what would you like your tombstone to say?
Reply With Quote
  #9  
Old 02-26-2013, 03:31 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

yup.

http://perldoc.perl.org/5.12.3/index.html
http://www.perl.org/books/library.html
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #10  
Old 02-26-2013, 03:36 AM
Drajor's Avatar
Drajor
Developer
 
Join Date: Nov 2012
Location: Halas
Posts: 355
Default

As a minor countargument to using google. Asking simple/redundant questions does provide learning opportunities for others. For example I did not know what -W was for :p
__________________
Drajor regards you indifferently -- what would you like your tombstone to say?
Reply With Quote
  #11  
Old 02-26-2013, 03:41 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

i'll agree that it's sometimes easier to learn a thing within a certain context (like expected behavior in the game) than through technical documentation. it's easy to learn the basics via reading tutorials, however. then there is no reason to not write short scripts to run outside of the game to determine if your understanding of something is correct or not.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #12  
Old 02-26-2013, 06:59 PM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

Thanks for the suggestions. perl -cW is quite useful. Any one know why I am required to use double parenthesis? Its not a problem for me, but different than others. Maybe it is my version of perl?

Thanks again, everyone.
__________________
Disorder
Reply With Quote
  #13  
Old 02-26-2013, 07:24 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

take them all out and run -cW again and also check logs if the script won't run.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
Reply


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 04:13 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3