EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Check_hasitem, keys, and powersources (https://www.eqemulator.org/forums/showthread.php?t=38635)

Leetsauce 08-19-2014 03:15 PM

Check_hasitem, keys, and powersources
 
Context: I use keys on my server instead of qglobal "flags", and I generally make it an item or augment that the character can wear.

So I ran into an issue today where check_hasitem was crashing zones (due to checking corpses) and happened to stumble upon an issue with the check_hasitem.pl plugin that did NOT check the powersource slot. Simple fix was to take the powersource off, put it in your inventory, and the check worked successfully. So, it led me here:


#Check main inventory and cursor
for($slot1=0; $slot1<=9999; $slot1++) {
$itemid1=$client->GetItemIDAt($slot1);
for($i=0; $i<5; $i++) {
$augid1=$client->GetAugmentIDAt($slot1, $i);
if($augid1==$itmchk) {
return 1;
}
}

Changing the second variable:$slot1<=30(inventory slots minus the power source slot) to $slot1<=9999(9999 is the slot #peekinv tells you the power source is found) fixed the issue, and forced the routine to check the power source slot. I only had to alter it in this section alone for my intended purpose, but I figured I would share just in case someone runs into the same issue. I suck at perl, so this one took me a minute or two to solve and wish to pass on what I've learned.

Thanks!

Kingly_Krab 08-19-2014 03:32 PM

The issue with changing it from 30 to 9999 is the fact you're checking EVERY slot in between 0 and 9999 which has all bag slots, inventory slots, bank slots, bank bag slots, etc. Really, you'd want to do like they do it in the source where it increments to a certain point and is reassigned to the Powersource Slot ID. Code below.
Code:

#Check main inventory and cursor
for($slot1 = 0; $slot1 <= 31; $slot1++) {
    if ($slot1 == 31) {
        $slot1 = 9999;
    }
    $itemid1 = $client->GetItemIDAt($slot1);
    for($i = 0; $i < 5; $i++) {
        $augid1 = $client->GetAugmentIDAt($slot1, $i);
        if($augid1 == $itmchk) {
            return 1;
        }
    }
}


Leetsauce 08-19-2014 03:52 PM

Awwww, snap. Thanks for cleaning that up for me.

Kingly_Krab 08-19-2014 03:58 PM

You're welcome.


All times are GMT -4. The time now is 10:20 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.