Jump to content

Home

Remove Item from Player


Chaos0815

Recommended Posts

Posted

Hi,

I am trying to delete a series of objects from the player inventory.

 

DestroyObject(GetItemPossessedBy(OBJECT_SELF, "danceroutfit"));

 

Inventory_Item = GetNextItemInInventory();

 

if (GetBaseItemType(Inventory_Item) == BASE_ITEM_DATA_PAD){

DestroyObject(Inventory_Item);

}

 

It doesn't work so far and would appreciate any help

 

Thx in advance,

Chaos0815

Posted

You can use this script to take an item from your inventory.

 

void main() {
ActionTakeItem(GetObjectByTag("[color=red]OBJECT_TAG[/color]", 0), GetFirstPC());
}

 

Replace "OBJECT_TAG" with the tag of the object you want to take from your inventory.

 

Hope this helps :D

Posted

I am trying to delete a series of objects from the player inventory.

 

DestroyObject(GetItemPossessedBy(OBJECT_SELF, "danceroutfit"));

 

This would require the player character object to run the script for it to work, and it would not remove the dancer's outfit if it was worn by another party member. Also you've got a typo in the tag, it should be DancersOutfit (missing S in dancerS).

 

To use the same method to get rid of it from all party members, you could do:

void main() {
   DestroyObject(GetItemPossessedBy( GetPartyMemberByIndex(0), "DancersOutfit"));
   DestroyObject(GetItemPossessedBy( GetPartyMemberByIndex(1), "DancersOutfit"));
   DestroyObject(GetItemPossessedBy( GetPartyMemberByIndex(2), "DancersOutfit"));
}

 

Inventory_Item = GetNextItemInInventory();

 

if (GetBaseItemType(Inventory_Item) == BASE_ITEM_DATA_PAD){

DestroyObject(Inventory_Item);

}

 

The GetNextItemInInventory() function is used for advancing the inventory iterator pointer for an object and needs to be used in conjunction with GetFirstItemInInventory(), usually in a loop. Like:

 

void main() {
   object oPC = GetFirstPC();
   object oItem = GetFirstItemInInventory( oPC );

   while (GetIsObjectValid(oItem)) {
       if (GetBaseItemType(oItem) == BASE_ITEM_DATA_PAD){
           DestroyObject(oItem, 0.1);
       }

       oItem = GetNextItemInInventory( oPC );   
   }
}

 

 

ActionTakeItem(GetObjectByTag("OBJECT_TAG", 0), GetFirstPC());

 

This makes the object running the script (or the one the action is assigned to) take the item from the inventory of the main character and add it to their own inventory, provided that the object has an inventory, which is not the same as destroying it, since the object still exists in the game and could be looted back from the inventory of the object. Since it's an action it also requires the running object to be of a type that has an action queue.

Posted

Thx for the help.

 

The method with destroyobject worked but it only did so after i detached the script from the rest of the code that was running.

 

Well thx again. As soon as i am finished i gonna post it.

Chaos0815

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...