Log in

View Full Version : y is this not working return item


spider661
06-22-2008, 05:14 PM
sub EVENT_ITEM
{
if (plugin::check_handin(\%itemcount, 1389 => 1) && $epic15 == 3)
{
quest::say("Good report to Sergeant Zind and see if he needs any help. Here you hang onto the jewel for safekeeping.");
quest::summonitem("1389");
quest::setglobal("epic15", 4, 5, "F");
}
else
{
quest::say ("Hang on to this");
plugin::return_items(\%itemcount);
}
}


it should take an item with id 1389 if you have the quest and give it back and if you don't have the quest give it back say he don't need it and if you already done the quest give it back then if you give him an item he don't need he should give it back.

i have tried it 4 diff ways he takes the item if you have the quest and gives it back if you give him the wrong item he gives it back but if you give him the quest item and you have already don't the quest or are not at this point yet he will not give it back.

with the way it is above he don't even say anything just takes the item if you don't have the quest.

whats up?

spider661
06-22-2008, 05:28 PM
i got it


sub EVENT_ITEM
{
if (plugin::check_handin(\%itemcount, 1389 => 1))
{
if($epic15 == 3)
{
quest::say("Good report to Sergeant Zind and see if he needs any help. Here you hang onto the jewel for safekeeping.");
quest::summonitem("1389");
quest::setglobal("epic15", 4, 5, "F");
}
elsif($epic15 != 3)
{
quest::say ("Hang on to this, till its needed again");
quest::summonitem("1389");
}
}
else
{
quest::say ("Hang on to this");
plugin::return_items(\%itemcount);
}
}

xxarthurxx
06-22-2008, 06:04 PM
Nice, i was about to reply but you fixed it yourself before i could get it posted

trevius
06-22-2008, 06:06 PM
Perhaps a better way to write that would be the following:

sub EVENT_ITEM {

if (plugin::check_handin(\%itemcount, 1389 => 1)) {

if (defined($qglobals{epic15})) {

if($qglobals{epic15} == 3) {

quest::say("Good report to Sergeant Zind and see if he needs any help. Here you hang onto the jewel for safekeeping.");
plugin::return_items(\%itemcount);
quest::setglobal("epic15",4,5,"F"); }

else {
quest::say ("Hang on to this, till its needed once again.");
plugin::return_items(\%itemcount); }

}

else {
quest::say ("Hang on to this, till its needed once again.");
plugin::return_items(\%itemcount); }

}

else {
quest::say ("I have no use for this item, $name.");
plugin::return_items(\%itemcount); }

}

This will first check if the player turned in the correct item. If not, it will return it. Then, it checks if the player has the quest global defined at all (if they have even started the quest line) and if not, it returns the item but tells them to hang on to it. Finally, it checks if the player has the 3 value for the global and if not, it returns the item and tells them to hang onto it.

I haven't tested this, but I think it should work. You might have to adjust it slightly to get it working in case I missed something. But, this should probably be the best way to do it. The only part I am not sure about is all of the elses for returning items. You might not need all of them. I have had issues in the past where it will do all of the elses for some reason, when I think it should really only be doing 1 of them. You can tell if that is happening easily by testing to see if you get multiple return messages. If that happens, you should be able to just remove some of the quest::say's in the else returns.

I also wanted to mention that I changed the format so that it is easier to read. It is hard to tell what is going on when all of the brackets are on the left side and all of the lines are lined up as well.