EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Custom (https://www.eqemulator.org/forums/forumdisplay.php?f=671)
-   -   Custom Item Check Plugins (https://www.eqemulator.org/forums/showthread.php?t=41397)

Kingly_Krab 06-18-2017 09:46 PM

Custom Item Check Plugins
 
Included below are the following plugins:
  1. check_hasitem(client, item_id)
    • Used to check if a client has a specific item.
  2. check_hasitem_array(client, item_id_array)
    • Used to check if a client has any item within the specified item ID array.
  3. check_hasequipped(client, item_id)
    • Used to check if a client has a specific item equipped.
  4. check_hasequipped_array(client, item_id_array)
    • Used to check if a client has any item equipped within the specified item ID array.
Code:

sub check_hasitem {
    my $client = shift;
    my $itemid = shift;
    my @slots = (0..30, 251..340, 2000..2023, 2030..2270, 2500..2501, 2531..2550, 9999);
    foreach $slot (@slots) {
        if ($client->GetItemIDAt($slot) == $itemid) {
            return 1;
        }

        for ($i = 0; $i < 5; $i++) {
            if ($client->GetAugmentIDAt($slot, $i) == $itemid) {
                return 1;
            }
        }
    }
    return 0;
}

sub check_hasitem_array {
    my $client = shift;
    my @items = @_;
    my @slots = (0..30, 251..340, 2000..2023, 2030..2270, 2500..2501, 2531..2550, 9999);
    foreach $slot (@slots) {
        if ($client->GetItemIDAt($slot) ~~ @items) {
            return 1;
        }

        for ($i = 0; $i < 5; $i++) {
            if ($client->GetAugmentIDAt($slot, $i) ~~ @items) {
                return 1;
            }
        }
    }
    return 0;
}

sub check_hasequipped {
    my $client = shift;
    my $item = shift;
    my @slots = (0..21, 9999);
    foreach my $slot (@slots) {
        if ($client->GetItemIDAt($slot) == $item) {
            return 1;
        }

        for ($i = 0; $i < 5; $i++) {
            if ($client->GetAugmentIDAt($slot, $i) == $item) {
                return 1;
            }
        }
    }
}

sub check_hasequipped_array {
    my $client = shift;
    my @items = @_;
    my @slots = (0..21, 9999);
    foreach my $slot (@slots) {
        if ($client->GetItemIDAt($slot) ~~ @items) {
            return 1;
        }

        for ($i = 0; $i < 5; $i++) {
            if ($client->GetAugmentIDAt($slot, $i) ~~ @items) {
                return 1;
            }
        }
    }
}

return 1;



All times are GMT -4. The time now is 05:31 AM.

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