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!