So, I am trying to make a quest that will level characters by 1 level each time they turn in 4 ItemID 2835. I can't get it to work properly. I have 2 examples below which I have tried adjustments to, but neither seem to work properly.
First, I tried this script, which uses elsifs, but I haven't really used them much before so it is very possible there could be a mistake. This one does absolutely nothing if I turn in the items. In fact, it doesn't even return them.
Code:
sub EVENT_ITEM {
if (plugin::check_handin(\%itemcount, 2835=>4) {
if ($max_level == undef) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 71, 5, "F");
quest::level(71); }
elsif ($max_level == 71) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 72, 5, "F");
quest::level(72); }
elsif ($max_level == 72) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 73, 5, "F");
quest::level(73); }
elsif ($max_level == 73) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 74, 5, "F");
quest::level(74); }
elsif ($max_level == 74) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 75, 5, "F");
quest::level(75); }
}
else {
plugin::return_items(\%itemcount);
}
}
The script below is the code that I tried next and it actually works for the first turn in. It gives me the global of 71, the level and everything. But, if I turn in 4 more ItemID 2835s, it just eats them and does nothing. I verified it is putting the global on my character and that the NPC is recognizing globals. I made a simple EVENT_SAY to make sure it responded properly to hails when I had the global max_level at 71 and it responded properly. The npc is flagged for qglobals in the NPC_Entries table. I am stumped as to why it isn't working past the first turn in. My guess is it is something to do with it being the same item that is turned in, which is why I first tried the elseifs in the code above.
Code:
sub EVENT_ITEM {
if (plugin::check_handin(\%itemcount, 2835=>4) && $max_level == undef) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 71, 5, "F");
quest::level(71); }
if (plugin::check_handin(\%itemcount, 2835=>4) && $max_level == 71) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 72, 5, "F");
quest::level(72); }
if (plugin::check_handin(\%itemcount, 2835=>4) && $max_level == 72) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 73, 5, "F");
quest::level(73); }
if (plugin::check_handin(\%itemcount, 2835=>4) && $max_level == 73) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 74, 5, "F");
quest::level(74); }
if (plugin::check_handin(\%itemcount, 2835=>4) && $max_level == 74) {
quest::say("These are in excellent shape! They will be trophies in my collection!");
$client->Message(6, "Maximus Serilious rewards you with a new level!" );
quest::exp(9999999);
quest::setglobal("max_level", 75, 5, "F");
quest::level(75); }
else {
plugin::return_items(\%itemcount);
}
}
Any help would be greatly appreciated!