View Single Post
  #5  
Old 10-14-2011, 09:01 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

You should probably google "perl tutorial" or really any basic computer logical expression explanations. If you think an else can go after a foreach(not knocking you, we all start somewhere), then its going to be really frustrating for you to attempt to get things done. Most people spend a lot of time on the DB and spells, etc... spend a fraction of that time doing perl tutorials or C++ tutorials and in a few weeks you will be shocked.

Havent tested this, but may work.

Code:
sub EVENT_ITEM
{
	my @factions = (69,70,87,88,117,137,155,177,256,260,268,322,331);
	my @req_items = (1804,1805,1806,1807);
	my %exp_rewards = (1804 => 4000, 1805 => 6000, 1806 => 8000, 1807 => 10000);
	my %faction_rewards = (1804 => 5, 1805 => 10, 1806 => 15, 1807 => 20);
	## Iterate through all items handed in	
	for my $item ( keys %itemcount ) {
		my $item_count = $itemcount{$item};
		## Compare current item with all available turn ins
		foreach my $req_item(@req_items) {
			if($item == $req_item) {
				foreach $faction(@factions) { quest::faction($faction,($exp_rewards{$item}*$item_count)); }
				quest::exp($exp_rewards{$item});
				quest::ding;
				quest::say("I see you have been skulking about for Noble Villifar. You are wise to aid us and your effort shall not go unnoticed, $name.");	
				quest::givecash("0","0","8","0");
				delete $itemcount->{$item}; ## Remove used items from itemcount
				last; ## End this loop and continue onto next handed in item
			}
		}
	}
	## Return all items that didnt get used
	plugin::return_items(\%itemcount);
}
Reply With Quote