View Single Post
  #4  
Old 09-19-2009, 10:42 PM
Shin Noir's Avatar
Shin Noir
Legendary Member
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
Default

Instead of copy pasting the code 15 times, you could do something like this:

Code:
sub EVENT_LEVEL_UP {
	my $maxlvl = 50;
	my @classlist = ("Warrior", "Cleric", "Paladin", "Ranger", "ShadowKnight", "Druid", "Monk", "Bard", "Rogue", "Shaman", "Necromancer", "Wizard", "Magician", "Enchanter", "Beastlord", "Berserker");
	foreach my $curclass (@classlist) {
       if(!defined($qglobals{$curclass."maxlvl"}) && $ulevel == $maxlvl && $curclass eq $class) {
            quest::setglobal($curclass."maxlvl",$name,2,"F");
            quest::shout2("$name has made the server first level $ulevel $class!");
            return;
	   }
	}
}
I think that may work. I'm storing the player's name in the variable instead of just a boolean flag in hopes that who knows, one day $pglobal will be loadable on NPC's.

If that ever occurs, I wrote a reporter NPC too, $qglobals are a little weird scope wise, NPC's don't load no NPC ID vars (aka Player vars). I may ask the coders to add a $pglobal that when you talk to a NPC, it loads non-NPC ID globals for the zone are loaded into $pglobal{}. Would be handy for this situation, and I can think of a few others.

This code doesn't work, but I wrote it anyways if the theory of player global vars non-NPC specific ever get written in.
Code:
sub EVENT_SAY
{
    if ($text=~/Hail/i) { #Initial Hail
        my @classlist = ("Warrior", "Cleric", "Paladin", "Ranger", "ShadowKnight", "Druid", "Monk", "Bard", "Rogue", "Shaman", "Necromancer", "Wizard", "Magician", "Enchanter", "Beastlord", "Berserker");;
        my $buffer = "";
        foreach my $curclass (@classlist) {
            $buffer = $buffer . $pglobals{$curclass."maxlvl"} . " [$curclass], " if (defined($qglobals{$curclass."maxlvl"}));
            if (defined($qglobals{Bardmaxlvl})) { $buffer = $buffer . $pglobals{Bardmaxlvl} . " [$curclass], "; }
        }
        if (length($buffer) > 3) {
            $buffer = substr $buffer, 0, length($buffer)-3;
            quest::say("Server First Classes: " . $buffer);
        }
        quest::say("end");
    }
}
__________________

~Shin Noir
DungeonEQ.com
Reply With Quote