int GetNumItems(object oInventory); void main() { object oBox = OBJECT_SELF; // Test for containers if ( GetInventoryDisturbType() == INVENTORY_DISTURB_TYPE_ADDED ) { object oItem = GetInventoryDisturbItem(); object oOwner = GetLastDisturbed(); if ( GetHasInventory( oItem ) ) { AssignCommand(oOwner, ActionTakeItem( oItem, oBox)); SendMessageToPC( oOwner, "You cannot place a container in the chest" ); return; } } if(GetLocalInt(oBox, "MAX_NUM_ITEMS") > 0) { string sOwner = GetLocalString(oBox, "OWNER"); int iMaxNumItems = GetLocalInt(oBox, "MAX_NUM_ITEMS"); int iNumItems = GetNumItems(oBox); if(iNumItems > iMaxNumItems) { object oItem = GetInventoryDisturbItem(); object oOwner = GetLastDisturbed(); AssignCommand(oOwner, ActionTakeItem(oItem, oBox)); SendMessageToPC(oOwner, "The container is full"); } } } int GetNumItems(object oInventory) { object oItem = GetFirstItemInInventory(oInventory); int n = 0; while(GetIsObjectValid(oItem)) { n = n+1; oItem = GetNextItemInInventory(oInventory); } return n; }