void main() { object oBox = OBJECT_SELF; object oItem = GetFirstItemInInventory(); object oKey; string sItem; string sOwner = GetLocalString(oBox, "OWNER"); string sResRef; int iNumKey = GetLocalInt(oBox, "OWNER_KEY"); int iStackSize; int n; if(sOwner != "") { SetLocalInt(oBox, "JUST_OPEN", 1); if(!GetIsObjectValid(oItem)) { if(!GetCampaignInt("PW_"+sOwner+"_CASSA", "HAS_KEY") && iNumKey > 0) { oKey = CreateObject(OBJECT_TYPE_ITEM, "pw_chest_key", GetLocation(oBox), FALSE, sOwner+"_key"); for (iNumKey ; iNumKey >0 ; iNumKey--) CopyItem(oKey, oBox); DestroyObject(oKey); SetCampaignInt("PW_"+sOwner+"_CASSA", "HAS_KEY", 1); } for(n = GetCampaignInt("PW_"+sOwner+"_CASSA", "ITEM_NUM"); n>0; n--) RetrieveCampaignObject("PW_"+sOwner+"_CASSA", "ITEM"+IntToString(n), GetLocation(oBox), oBox); } } }