View Single Post
  #1  
Old 11-27-2018, 02:03 PM
Almusious
Fire Beetle
 
Join Date: Sep 2012
Posts: 25
Default check_hasitem.pl

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.

Code:
## 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;
Reply With Quote