PDA

View Full Version : check_hasitem.pl


Almusious
11-27-2018, 02:03 PM
A recent post by Uleat (today) reminded me, that those already rolling with an EQEmu setup may not have updated their check_hasitem.pl much less know it should be. This is for those of whom the aforementioned apply:

It's a modified version of the one that used to be provided BEFORE the inventory changes in which made this necessary. Unsure who to credit for it, sorry.


## Plugin Name: check_hasitem.pl
## Description: Checks character's possession(s) throughout all inventory slots to determine if the requested item (ID) exists (ie. returns 1 for true, 0 for false)
## Usage: plugin::check_hasitem($client, itemid); -- (whereas itemid = the item number we're looking for)
sub check_hasitem
{
my $client = shift;
my $itemtocheckfor = shift;
my $individualslot;
my $founditem;
my $augmentid;
my $i;
my $body_count = $client->GetCorpseCount();
my $body_id;

my @slotsarray = ((quest::getinventoryslotid("possessions.begin"))..(quest::getinventoryslotid("possessions.end")),
(quest::getinventoryslotid("generalbags.begin"))..(quest::getinventoryslotid("generalbags.end")),
(quest::getinventoryslotid("cursorbag.begin"))..(quest::getinventoryslotid("cursorbag.end")),
(quest::getinventoryslotid("bank.begin"))..(quest::getinventoryslotid("bank.end")),
(quest::getinventoryslotid("sharedbankbags.begin"))..(quest::getinventoryslotid("sharedbankbags.end")),
(quest::getinventoryslotid("sharedbank.begin"))..(quest::getinventoryslotid("sharedbank.end")));


foreach my $individualslot (@slotsarray)
{
$founditem = $client->GetItemIDAt($individualslot);
if ($founditem == $itemtocheckfor) { return 1; }
for ($i = quest::getinventoryslotid("augsocket.begin"); $i < quest::getinventoryslotid("augsocket.end"); $i++)
{
$augmentid = $client->GetAugmentIDAt($individualslot, $i);
if ($augmentid == $itemtocheckfor) { return 1; }
}
}

## Check corpses contents
if ($body_count)
{
my $foundcorpseitem;
my @corpseslotsarray = ((quest::getinventoryslotid("possessions.begin"))..(quest::getinventoryslotid("possessions.end")),
(quest::getinventoryslotid("generalbags.begin"))..(quest::getinventoryslotid("generalbags.end")));
for ($i = 1; $i <= $body_count; $i++)
{
$body_id = $client->GetCorpseID($i);
foreach my $individualcorpseslot (@corpseslotsarray)
{
$foundcorpseitem = $client->GetCorpseItemAt($body_id, $individualcorpseslot);
if ($foundcorpseitem == $itemtocheckfor) { return 1; }
}
}
}
return 0;
}

1;

lctucker2999
08-25-2020, 05:42 PM
Apologies for necro'ing a 2 year old thread.

Is it just a matter of replacing the existing check_hasitem.pl with the code here? I ran into some quests that weren't working for me, and eventually figured out that it was the check_hasitem plugin that was causing the script to fail, which led me here.

So I saved backup of the original, and pasted this code into check_hasitem.pl but it doesn't seem to have had any effect. Restarted the server etc. I assume there is more to it that i'm missing

Uleat
08-25-2020, 06:52 PM
If you're in a particular zone and it's not working, double-check that there's not a lua script overriding the perl one.

You would have to check whatever parent script is calling this function (i.e., player.lua vs. player.pl)