PDA

View Full Version : Quest crashing zone and client


Disorder
02-26-2013, 01:18 AM
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:

http://i.imgur.com/lWFi5Ev.jpg

Here is the 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:

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. :shock:

Thanks in advance!

ghanja
02-26-2013, 02:52 AM
*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.

c0ncrete
02-26-2013, 03:01 AM
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.

Zamthos
02-26-2013, 03:07 AM
Well, yeah, I didn't see the %name but that would make sense. Tried helping him, didn't see that. Hehe.

c0ncrete
02-26-2013, 03:11 AM
always test your scripts from a command line like this to easily catch syntax errors and other such things:

perl -cW path/to/script.pl

Zamthos
02-26-2013, 03:21 AM
I use this:
What does the W do?

perl -c path/to/script.pl

c0ncrete
02-26-2013, 03:26 AM
thw W enables all warnings (like telling you that you are using a variable only once)

running this file that way

warnMe.pl
$warnMe;

results in this

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

Drajor
02-26-2013, 03:28 AM
I use this:
What does the W do?

perl -c path/to/script.pl

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.

c0ncrete
02-26-2013, 03:31 AM
yup.

http://perldoc.perl.org/5.12.3/index.html
http://www.perl.org/books/library.html

Drajor
02-26-2013, 03:36 AM
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

c0ncrete
02-26-2013, 03:41 AM
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.

Disorder
02-26-2013, 06:59 PM
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.

c0ncrete
02-26-2013, 07:24 PM
take them all out and run -cW again and also check logs if the script won't run.