Array Problems
I am hoping to be able to do some sort of system where I can have an array of quest rewards for each class. This is a very simple example of what I am trying to do.
Code:
sub EVENT_SAY |
you probably would be better off using a hash of arrays.
Code:
my $reward = { Code:
quest::summonitem( quest::ChooseRandom( @{ $reward->{$class} } ) ); Code:
quest::summonitem( $reward->{$class}->[ rand int @{ $reward->{$class} } ] ); |
This is what i use to reward based on class:
Code:
my %Reward = ("Warrior" => '132639', "Rogue" => '132667', "Monk" => '132672', "Berserker" => '132671', "Shadowknight" => '132670', "Paladin" => '132669', "Ranger" => '132662', "Bard" => '132668', "Beastlord" => '132673', "Cleric" => '132640', "Druid" => '132650', "Shaman" => '132651', "Wizard" => '132663', "Magician" => '132664', "Enchanter" => '132666', "Necromancer" => '132665'); Code:
quest::summonitem($Reward{$class}); |
Thanks for the quick responses. I like both of those methods a lot, so I'll bookmark this page haha.
|
you rarely ever want to use variables in variable names, even if you really think you do. it's generally not worth the headache.
http://perl.plover.com/varvarname.html |
All times are GMT -4. The time now is 04:01 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.