What you need to do is loop through every item in the PC's inventory looking for your item, and perform an action on each one you find.

Two functions make it easy to loop through the whole inventory: GetFirstItemInInventory and GetNextItemInInventory.

Here's an example of how to use them to reward a PC for every item they have with the tag "goblin_ear":

// This script goes in the "Actions Taken" tab of a
// conversation.  It will reward the PC 10 gold and 
// 10 XP for every item they possess with the tag 
// "goblin_ear".
void main()
   // First, get the PC being spoken to
   object oPC = GetPCSpeaker();
   // Now, find the first item in that PC's inventory
   object oItem = GetFirstItemInInventory(oPC);
   // Start the loop.  The next statement says to
   // stay in the loop until "oItem" no longer points
   // to a valid object. This will happen as soon as 
   // we've looped through every one of the PC's items.
   while (GetIsObjectValid(oItem))
      // Check the tag on the current item
      if (GetTag(oItem) == "goblin_ear")
         // Statements within these brackets will
         // be run for each item that matches the
         // "goblin_ear" tag.
         // The next two lines give the rewards:
         // 10 gold and 10 XP.
         GiveGoldToCreature(oPC, 10);
         GiveXPToCreature(oPC, 10);
         // Now take the ear from the PC.  Note that
         // this doesn't really take the ear and give
         // it to the NPC; it just destroys it. Why
         // do NPCs give money for these things,
         // anyway? Who wants a bunch of rotting ears
         // in their pockets?
      // Now move on to the next item
      oItem = GetNextItemInInventory(oPC);
   } // End while loop
} // End script

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.