Hmm, all these nested if / elsif / else ... not too easy to work on.
Why not try a different scheme : store values for your quest in an array, and test them. Much easier to read and modify imho :
Code:
sub EVENT_ITEM{
my @data=(
{ "minlevel" => 1,
"maxlevel" =>9,
"plat" => 100,
"copper" => 1,
"spellid" => 1200,
"saying" => "Good luck on your journey, $name"
},
{ "minlevel" => 10,
"maxlevel" =>19,
"plat" => 200,
"copper" => 1,
"spellid" => 1200,
"saying" => "Good luck on your journey, $name"
},
{ "minlevel" => 20,
"maxlevel" => 30,
"plat" => 300,
"copper" => 1,
"spellid" => 1200,
"saying" => "Good luck on your journey, $name"
}
);
foreach $entry (@data){
if($ulevel >= $entry->{'minlevel'}
&& $ulevel <= $entry->{'maxlevel'}
&& $copper == $entry->{'copper'}
&& $platinum == $entry->{'plat'}
){
quest::castspell($userid, $entry->{'spellid'});
quest::say($entry->{'saying'});
last;
}
}
}
#the following is for testing only, remove or comment out if you want to include this in a real quest
sub wannatry{
$userid=1234;
$name="MyCharName";
$platinum=100; $copper=1;
$ulevel=7;
EVENT_ITEM();
}
package quest;
sub say{
print shift, "\n";
}
sub castspell{
print "NPC now casting spell ", shift, "\n";
}
package main;
wannatry();
i ddn't test it fully, but should work for a start. i hope this helps.