View Single Post
  #1  
Old 10-06-2010, 07:36 PM
abooble24
Fire Beetle
 
Join Date: Sep 2010
Posts: 3
Default Plugin to obtain class ID

I couldn't believe there wasn't a global $classid, so I had to make a plugin to pull it. I am using it to assign a class specific start task to a character as they are created without having to compare class string names over and over. I am sure there will be other uses for it that someone out there can come up with.

The Plugin:
Code:
sub getClassId{
	my $class = $_[0];
	%classes = (	  'Warrior', 1,
				  'Cleric', 2,
				  'Paladin', 3,
     				  'Ranger', 4,
				  'Shadowknight', 5,
				  'Druid', 6,
				  'Monk', 7,
				  'Bard', 8,
				  'Rogue', 9,
				  'Shaman', 10,
				  'Necromancer', 11,
				  'Wizard', 12,
				  'Mage', 13,
				  'Enchanter', 14,
				  'Beastlord', 15,
				  'Berserker', 16
	);
	return $classes{$class};
}
Example Usage: (Player enters zone and is assigned task if not on/completed)
Code:
sub EVENT_ENTERZONE{
	my $ClassID = plugin::getClassId($class);
	
	if(!quest::istaskactive($ClassID) && !quest::istaskcompleted($ClassID)){
		quest::assigntask($ClassID);
	}
}
Reply With Quote