void DestroyItemInOwnerDB(string sOwner); void main() { object oBox = OBJECT_SELF; object oItem; string sOwner = GetLocalString(oBox, "OWNER"); string sResRef; int iStackSize; int n = 0; object oPC = GetLastClosedBy(); if(sOwner != "") { DestroyItemInOwnerDB(sOwner); SetLocked(oBox, TRUE); if(GetCampaignInt("PW_"+sOwner+"_CASSA", "HAS_KEY")) SetLocalInt(oBox, "JUST_CLOSED", 1); else SetLocalInt(oBox, "JUST_OPEN", 1); // Run through all - if container, then abort oItem = GetFirstItemInInventory(); int container = FALSE; while ( GetIsObjectValid( oItem ) && !container ) { container = GetHasInventory( oItem ); oItem = GetNextItemInInventory(); } if (container) { FloatingTextStringOnCreature( "There isn't enough room in the chest for containers. You should empty the chest of containers, and try again", oPC, FALSE ); return; } // Save all to chest oItem = GetFirstItemInInventory(); while(GetIsObjectValid(oItem)) { n = n+1; StoreCampaignObject("PW_"+sOwner+"_CASSA", "ITEM"+IntToString(n), oItem); oItem = GetNextItemInInventory(); } SetCampaignInt("PW_"+sOwner+"_CASSA", "ITEM_NUM", n); } } void DestroyItemInOwnerDB(string sOwner) { int n; for(n = GetCampaignInt("PW_"+sOwner+"_CASSA", "ITEM_NUM"); n > 0; n--) DeleteCampaignVariable("PW_"+sOwner+"_CASSA", "ITEM"+IntToString(n)); }