Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #18  
Old 12-04-2012, 07:17 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

here's an (untested except for syntax) example of how looping could greatly reduce your code, and due to that, the chance of syntax errors. i added comments directing you to information in the perl documentation (which i sent you links to in my first response) that applies to what i have done here.

Code:
# subroutines covered @ http://perldoc.perl.org/5.12.4/perlsub.html
sub customRoutine {
    # private variables covered @ http://perldoc.perl.org/5.12.4/perlsub.html#Private-Variables-via-my%28%29
    my $itemcount  = shift;
    # lists covered @ http://perldoc.perl.org/5.12.4/perldata.html#List-value-constructors
    # range operator covered @ http://perldoc.perl.org/5.12.4/perlop.html#Range-Operators
    my @validitems = (150009..150107);
    # foreach loop covered @ http://perldoc.perl.org/5.12.4/perlsyn.html#Foreach-Loops
    foreach my $itemid (@validitems) {
        # note: $itemcount is already a hashref, so we don't pass it like we did before
        if (plugin::check_handin($itemcount, $itemid => 1)) {
            quest::say("Well done, $name, you are now level 1 with an upgraded ring.");
            quest::level(1);
            # your reward item always seemed to be the itemid of the handin +1, so this does that
            quest::summonitem($itemid+1, 1);
            quest::ding();
        }
    }
}

sub EVENT_ITEM {
    if ($ulevel > 64) {
        # pass by reference covered @ http://perldoc.perl.org/5.12.4/perlsub.html#Pass-by-Reference
        customRoutine(\%itemcount);
    }
    else {
        quest::say("You're not level 65 yet, $name.");
    }
    plugin::return_items(\%itemcount);
}
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:11 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3