Thread: Array Problems
View Single Post
  #2  
Old 02-06-2013, 12:40 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

you probably would be better off using a hash of arrays.

Code:
my $reward = {
    Shadowknight => [1001, 1002, 1003],
    Druid        => [1004, 1005, 1006],
    # etc
};

quest::say($class);
quest::summonitem($reward->{$class}->[1]);
assuming you want it to choose a random element from the array, you'd use
Code:
quest::summonitem( quest::ChooseRandom( @{ $reward->{$class} } ) );
or
Code:
quest::summonitem( $reward->{$class}->[ rand int @{ $reward->{$class} } ] );
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;

Last edited by c0ncrete; 02-06-2013 at 01:00 AM.. Reason: capitalization fix
Reply With Quote