View Single Post
  #1  
Old 07-09-2015, 05:23 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default Clarification on Perl loop

Code:
sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount,8161=>1)) {
		quest::say("You have won! Take this as a reward. Defeat the Skeletal Lord within an hour for one of five random item rewards.");
		quest::summonitem(7967); #2h reward
	}
	if (plugin::check_handin(\%itemcount,8162=>3)) {
		quest::say("You have defeated the Skeletal Lord! Take this as a reward. Defeat the Skeletal Lord within half an hour for a powerful permanent version of the Soul-Caged Rapier.");
		for (1..2) {
			my $reward = quest::ChooseRandom(68752,68754,68756,68758,68768); #1h reward list
			redo if (plugin::check_hasitem($client, $reward)); #check ownership of chosen lore reward
			quest::summonitem($reward);
			last;
		}
	}
	if (plugin::check_handin(\%itemcount,8163=>3)) {
		quest::say("You are quite efficient at defeating the Lord of Undeath. Take this as a reward.");
		quest::summonitem(8164); #30m reward
	}
	else {
		plugin::return_items(\%itemcount);
	}
}
The code works fine in checking if the client turning in the 3 gems has the randomly selected reward and chooses another... until you have all 5 and attempt the turnin, which causes everything to pause. I guess I'm using the last; command incorrectly? or is it the for (1..2) ?
Reply With Quote