View Single Post
  #13  
Old 02-10-2015, 01:06 PM
utbbop
Sarnak
 
Join Date: May 2009
Location: Mentor
Posts: 58
Default

Quote:
Originally Posted by trevius View Post
This is a much cleaner way of doing it via hashes:

Note that I only updated the first hash with your item IDs and the second one was just a copy/paste of the first one because I was too lazy to copy your item IDs all over for it. So, you will need to update the second hash (HandInHash2). Also, note that I am not sure what class order you had for your arrays @t1chestarmor or @t1legarmor, so please make sure to review the Turn-In column of the hash and ensure it is the correct one for each class.

Code:
sub EVENT_ITEM {

	my $RewardReceived = 0;
	
	# t1chestarmor
	# Class => [ Turn-In, Reward ],
	my %HandInHash = (
		"Warrior"		=> [ 1591, 1563 ],
		"Rogue"			=> [ 2845, 2828 ],
		"Monk"			=> [ 2868, 2444 ],
		"Berserker"		=> [ 2835, 2684 ],
		"Shadowknight"	=> [ 2861, 1819 ],
		"Paladin"		=> [ 2886, 1810 ],
		"Ranger"		=> [ 2958, 2493 ],
		"Bard"			=> [ 3540, 1846 ],
		"Beastlord"		=> [ 3680, 2562 ],
		"Cleric"		=> [ 3235, 1803 ],
		"Druid"			=> [ 3295, 2434 ],
		"Shaman"		=> [ 3484, 2665 ],
		"Wizard"		=> [ 3226, 2422 ],
		"Magician"		=> [ 2995, 2278 ],
		"Enchanter"		=> [ 3854, 2561 ],
		"Necromancer"	=> [ 3137, 2381 ]
	);
	
	# t1legarmor (Note that this is just a copy of the above array - Make sure you update the IDs!)
	# Class => [ Turn-In, Reward ],
	my %HandInHash2 = (
		"Warrior"		=> [ 1591, 1563 ],
		"Rogue"			=> [ 2845, 2828 ],
		"Monk"			=> [ 2868, 2444 ],
		"Berserker"		=> [ 2835, 2684 ],
		"Shadowknight"	=> [ 2861, 1819 ],
		"Paladin"		=> [ 2886, 1810 ],
		"Ranger"		=> [ 2958, 2493 ],
		"Bard"			=> [ 3540, 1846 ],
		"Beastlord"		=> [ 3680, 2562 ],
		"Cleric"		=> [ 3235, 1803 ],
		"Druid"			=> [ 3295, 2434 ],
		"Shaman"		=> [ 3484, 2665 ],
		"Wizard"		=> [ 3226, 2422 ],
		"Magician"		=> [ 2995, 2278 ],
		"Enchanter"		=> [ 3854, 2561 ],
		"Necromancer"	=> [ 3137, 2381 ]
	);

	if($HandInHash{$class})
	{
		# $HandInHash{$class}[0]; # Item Turned In
		# $HandInHash{$class}[1]; # Reward
	
		if (plugin::check_handin(\%itemcount, $HandInHash{$class}[0] => 1))
		{
			quest::summonitem($HandInHash{$class}[1]);
			quest::emote("Works to make a piece of armor from the instructions you provided to him." );
			quest::say ("Here you go $name.");
			# Example for below: Percent Experience (5), Max Level to give full exp percentage (level 45)
			$client->AddLevelBasedExp(5, 45);
			quest::ding();
			$RewardReceived = 1;
		}
	}
	
	if ($HandInHash2{$class})
	{
		# $HandInHash2{$class}[0]; # Item Turned In
		# $HandInHash2{$class}[1]; # Reward
	
		if (plugin::check_handin(\%itemcount, $HandInHash2{$class}[0] => 1))
		{
			quest::summonitem($HandInHash2{$class}[1]);
			quest::emote("Works to make a piece of armor from the instructions you provided to him." );
			quest::say ("Here you go $name.");
			# Example for below: Percent Experience (5), Max Level to give full exp percentage (level 45)
			$client->AddLevelBasedExp(5, 45);
			quest::ding();
			$RewardReceived = 1;
		}
	}
	
	if ($RewardReceived == 0)
	{
		quest::say ("Sorry, $name, but I cannot accept that.");
	}
	
	plugin::return_items(\%itemcount);
}
Going to work with this now, will let you know the results!
Thanks Trev.
Reply With Quote