//:://///////////////////////////////////////////// //:: Persistent Container OnClose Script //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* usage: attach this script to the OnClose event of a container info: you can customize several parameters: specify maximum capacity using WillSafe property choose object TAG for ID generation (ReflexSafe = 0) !! use this to share inventories !! use this for moving inventories (like creatures) choose automatic ID generation for stationary containers (ReflexSafe = 1). !! probably the best, coz container does not need a specific tag use player for ID generation (ReflexSafe = 2) !! use this for player vaults. each player gets his own inventory !! from a single container you can easily map those properties to something else, in case you use this include file for creature/merchant inventory.. */ //::////////////////////////////////////////////// //:: Created By: Knat //:: Created On: 28.4.03 //::////////////////////////////////////////////// #include "PINV_inc" void main() { // lock that thing for real during this process SetLocked(OBJECT_SELF,TRUE); object oUser = GetLastClosedBy(); // restore inventory // "Will Safe" serves as maximum capacity parameter // simply edit placeable property in the toolset // "Reflex Safe" serves as ID_FLAG // reflex = 0 // non unique container ID. it will just use the placeable tag as container index // multiple containers can share the same space this way // reflex = 1 // unique container ID. area-tag + location used as container index. each container gets // his own space, tag is irrelevant. // placeable must be stationary !!!! // reflex = 2 // ID based on GetPCPlayerName() and GetName() // container inventory depends on opener // this is useful for player vaults int nID = (GetReflexSavingThrow(OBJECT_SELF) == 2) ? PINV_GetID(oUser,2) : PINV_GetID(OBJECT_SELF,GetReflexSavingThrow(OBJECT_SELF)); if( PINV_StoreInventory(nID, OBJECT_SELF, oUser, GetWillSavingThrow(OBJECT_SELF)) == -1 ) SendMessageToPC(oUser, "Warning: items are not stored persistently. Your name contains malicious characters..."); // unlock container SetLocalInt(OBJECT_SELF,"IMBUSY!",FALSE); SetLocked(OBJECT_SELF,FALSE); }