PDA

View Full Version : Remove Item from Player


Chaos0815
07-03-2007, 10:25 AM
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

Master Zionosis
07-03-2007, 11:12 AM
You can use this script to take an item from your inventory.

void main() {
ActionTakeItem(GetObjectByTag("OBJECT_TAG", 0), GetFirstPC());
}

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

Hope this helps :D

Chaos0815
07-03-2007, 11:54 AM
Thx for the suggestion but it doesnt work.

Maybe it helps when i say that this is pure script which is not attached to an dialogue.

Master Zionosis
07-03-2007, 12:05 PM
Ahh then it won't work, it needs to be fired, and a dialog is the best solution, there are otehr ways, but attaching it to a dialog is by far the easiest way to do it.

stoffe
07-03-2007, 03:08 PM
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.

Chaos0815
07-03-2007, 05:46 PM
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