////////////////////////////////////////////////////////////////////// // wazoo_h_lschest - Leomund's Secret Chest Header // By Deva Bryson Winblood.4/5/2005 ////////////////////////////////////////////////////////////////////// //////////////////////////// // PROTOTYPES //////////////////////////// // FILE: wazoo_h_lschest FUNCTION: GetLSCPID() // Get the presonal ID used for recalling inventory string GetLSCPID(object oPlayer); // FILE: wazoo_h_lschest FUNCTION: RestoreContents() // This will put the contents this player had inside the // chest. void RestoreContents(object oChest,object oPlayer); // FILE: wazoo_h_lschest FUNCTION: PreserveContents() // This will preserve the contents of the chest and will // destroy the chest. sLDPID = Link Dead PID void PreserveContents(object oChest,object oPlayer,string sLDPID=""); /////////////////////////// // FUNCTIONS /////////////////////////// string GetLSCPID(object oPlayer) { return GetPCPublicCDKey(oPlayer)+GetPCPlayerName(oPlayer)+GetName(oPlayer); } // GetLSCPID() void RestoreContents(object oChest,object oPlayer) { object oMod=GetModule(); string sPID=GetLSCPID(oPlayer); int nC=GetLocalInt(oMod,"nWZLSC_Count_"+sPID); int nN; object oItem; string sS; int nSS; nN=1; while(nN<=nC) { // restore contents sS=GetLocalString(oMod,"sWZLSC_Res_"+sPID+"_"+IntToString(nN)); nSS=GetLocalInt(oMod,"nWZLSC_SS_"+sPID+"_"+IntToString(nN)); oItem=CreateItemOnObject(sS,oChest,nSS); DeleteLocalString(oMod,"sWZLSC_Res_"+sPID+"_"+IntToString(nN)); DeleteLocalInt(oMod,"nWZLSC_SS_"+sPID+"_"+IntToString(nN)); nN++; } // restore contents DeleteLocalInt(oMod,"nWZLSC_Count_"+sPID); SetLocalObject(oChest,"oOwner",oPlayer); SetLocalString(oChest,"sOwnerPID",sPID); } // RestoreContents() void PreserveContents(object oChest,object oPlayer,string sLDPID="") { object oMod=GetModule(); object oItem; string sRes; int nStack; int nN; string sPID=GetLSCPID(oPlayer); if (GetStringLength(sLDPID)>0) sPID=sLDPID; oItem=GetFirstItemInInventory(oChest); while(oItem!=OBJECT_INVALID) { // traverse sRes=GetResRef(oItem); nStack=GetItemStackSize(oItem); nN++; SetLocalString(oMod,"sWZLSC_Res_"+sPID+"_"+IntToString(nN),sRes); SetLocalInt(oMod,"nWZLSC_SS_"+sPID+"_"+IntToString(nN),nStack); DelayCommand(0.5,DestroyObject(oItem)); oItem=GetNextItemInInventory(oChest); } // traverse SetLocalInt(oMod,"nWZLSC_Count_"+sPID,nN); DelayCommand(0.8,DestroyObject(oChest)); } // PreserveContents() //void main(){}