Author Topic: Take Inventory From Creature  (Read 610 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Take Inventory From Creature
« on: April 06, 2011, 01:10:18 am »


               Someone asked me to write a function for them that takes all of a creature's inventory. Place this script in the OnEnter event of a module, area, or trigger. This script does NOT remove items equipped in the "creature item" slots (e.g. creature skins).

// Removes (and destroys) all items from the inventory of object oTarget, including equipped items
void TakeInventoryFromCreature(object oTarget);

void TakeInventoryFromCreature(object oTarget)
{
    object oEquip;
    int nSlot = 0;
       
    //Take equipped items
    while (nSlot <= 13)
    {
        nSlot ++;
        oEquip = GetItemInSlot(nSlot, oTarget);
        if (GetIsObjectValid(oEquip))
        {
            DestroyObject(oEquip);
        }
    }

    //Take non-equipped items
    oEquip = GetFirstItemInInventory(oTarget);
   
    while(GetIsObjectValid(oEquip))
    {
        DestroyObject(oEquip);
        oEquip = GetNextItemInInventory(oTarget);
    }
}
               
               

               


                     Modifié par Pstemarie, 06 avril 2011 - 12:13 .