PDA

View Full Version : Quest to see if client is wearing any equipment


kedra
02-25-2008, 06:44 AM
The subject says it all. I'm looking for the most effective way to check a client's inventory (worn items only) to see if he is wearing any item in any slot.

Basically, I want an NPC to be able to determine if the player has any equipped gear.

Any suggestions?

AndMetal
02-25-2008, 07:44 AM
Using this (http://www.eqemulator.net/wiki/wikka.php?wakka=QuestObjects) as a reference, I would imagine you could use the following command:

$client->GetItemIDAt(slot_id)

You would then need a loop (http://perl.about.com/od/perltutorials/a/forloop_2.htm) to test each possible visible slot (http://www.eqemulator.net/wiki/wikka.php?wakka=DevInventorySlots), which would be 0 through 21. This should do what you're looking for (although I haven't tested it):


sub EVENT_SAY {
if ($text=~/i'm a noob/i) {
my $s_id; #slot_id that will be looked at, defined in the for loop
my $ii = 0; #how many total items you have in your inventory
for ($s_id = 0; $s_id <= 21; $s_id++) { #look at just visible slots 0-21
if ($client->GetItemIDAt($s_id) != 0) {
$ii++;
}
}
if ($ii > 0) {
quest::say("If you were a noob, then how did you get $ii pieces of armor?");
} elseif ($ii == 0) {
quest::say("Yes. Yes, you are certainly a noob. A very naked noob.");
quest::emote("sees you cutting diamonds.");
}
}


To be honest, I'm not even sure if you have to define the variables at the beginning (so that they're only for the script), but it should prevent them from carrying over to the next call of the script (I think).

kedra
02-25-2008, 08:24 AM
Perfect, Andmetal, that's exactly what I needed. I had tried using
$client->GetItemIDAt(slot_id)
last night, but I was passing it the slot id in the wrong format.

Thanks tons. ;)