This destroy complete inventory script destroys all items (including equipped items) and gold on a player character (PC). This can be used to cause all PCs to start on an even footing.
This script is configured for use in an OnEnter or OnClientEnter event handler.
/******************************
* This script clears the inventory of the entering player character.
* It is suitable for use in an OnEnter or OnClientEnter event.
*******************************/
void main()
{
int nSlot;
object oPC = GetEnteringObject(); // Change this line for use in other events.
// Make sure oPC is a PC (not necessary in a module's OnClientEnter).
if ( !GetIsPC(oPC) )
return;
// Destroy the items in the main inventory.
object oItem = GetFirstItemInInventory(oPC);
while ( oItem != OBJECT_INVALID ) {
DestroyObject(oItem);
oItem = GetNextItemInInventory(oPC);
}
// Destroy equipped items.
for ( nSlot = 0; nSlot < NUM_INVENTORY_SLOTS; ++nSlot )
DestroyObject(GetItemInSlot(nSlot, oPC));
// Remove all gold.
AssignCommand(oPC, TakeGoldFromCreature(GetGold(oPC), oPC, TRUE));
}