//ScarFace's Persistent Baking system -OnClose- void main() { ActionLockObject(OBJECT_SELF); object oPC = GetLastUsedBy(); string sKey = GetPCPublicCDKey(oPC); object oItem = GetFirstItemInInventory(OBJECT_SELF); int iCount = 1; while (GetIsObjectValid(oItem)) { oItem = GetNextItemInInventory(OBJECT_SELF); iCount++; } if (iCount >=101) { FloatingTextStringOnCreature("**WARNING** You can't store more than 100 items. You have "+IntToString(iCount)+" items in the chest. No items were saved. Please remove some items", oPC); ActionUnlockObject(OBJECT_SELF); return; } iCount = 1; oItem = GetFirstItemInInventory(OBJECT_SELF); if (!GetIsObjectValid(oItem)) { iCount = 0; } string sCount; while (GetIsObjectValid(oItem)) { sCount = IntToString(iCount); StoreCampaignObject("STORAGE", sKey+sCount, oItem, oPC); DestroyObject(oItem); oItem = GetNextItemInInventory(OBJECT_SELF); iCount++; } if (iCount == 0) { FloatingTextStringOnCreature("Chest empty, No items saved", oPC); ActionUnlockObject(OBJECT_SELF); return; } FloatingTextStringOnCreature("Items successfully saved", oPC); ActionUnlockObject(OBJECT_SELF); }