Vault maker

What it does
Allows players in single or multiplayer to create their own vaults that no one else can unlock.

The Script
And finally, place the following scripts in your module

In "Vault"'s OnUsed
void main { ClearAllActions; object oPC = GetLastUsedBy; int nCount = GetLocalInt (OBJECT_SELF, "Count"); int iUserCode = GetLocalInt (oPC, "MyCode"); int iVaultCode = GetLocalInt (OBJECT_SELF, "MyCode"); string sRPGTag = GetLocalString (OBJECT_SELF, "RPG_TAG"); if (iUserCode ==iVaultCode) {   SetLocked (OBJECT_SELF, FALSE); if (GetLocalInt (OBJECT_SELF, "Locked") ==1) {       FloatingTextStringOnCreature ("VAULT UNLOCKED", oPC); SetLocalInt (OBJECT_SELF, "Locked", 0); }   } else if (!(iUserCode ==iVaultCode)) {   FloatingTextStringOnCreature (""+sRPGTag+"'s Vault.", oPC); } }

In "Vault"'s OnClose
void main { object oPC = GetLastUsedBy ; DelayCommand (0.2, SetLocked (OBJECT_SELF, TRUE)); DelayCommand (0.2, SetLocalInt (OBJECT_SELF, "Locked", 1)); FloatingTextStringOnCreature ("The Vault is Locked", oPC); }

In your module's OnActivateItem
void main { int iMyLock = Random (1000000); object oVaultMaker = GetObjectByTag ("VaultMaker"); object oItem = GetItemActivated; object oPC = GetItemActivator; object oOldVault = GetLocalObject (oPC, "HasVault"); object oSlot1 =GetFirstItemInInventory (oOldVault); location lVault = GetLocation (oPC); string sRPGTag = GetName (oPC); if (oItem ==oVaultMaker) {   if  (!(GetIsObjectValid (oOldVault))) {       CreateObject (OBJECT_TYPE_PLACEABLE, "vault", lVault, FALSE); object oVault = GetObjectByTag("Vault"); SetLocalInt (oVault, "MyCode", iMyLock); SetLocalInt (oPC, "MyCode", iMyLock); SetLocalString (oVault, "RPG_TAG", sRPGTag); SetLocalObject (oPC, "HasVault", oVault); FloatingTextStringOnCreature ("VAULT UNLOCKED", oPC); }   if ((GetIsObjectValid (oOldVault)) && !(GetIsObjectValid (oSlot1)) ||    (GetLocalInt (oPC, "DestroyAnyway") ==1)) {       CreateObject (OBJECT_TYPE_PLACEABLE, "vault", lVault, FALSE); object oVault = GetObjectByTag("Vault"); SetLocalInt (oVault, "MyCode", iMyLock); SetLocalInt (oPC, "MyCode", iMyLock); SetLocalString (oVault, "RPG_TAG", sRPGTag); SetLocalObject (oPC, "HasVault", oVault); FloatingTextStringOnCreature ("Old Vault Destroyed", oPC); DelayCommand (1.5, FloatingTextStringOnCreature ("VAULT UNLOCKED", oPC)); DestroyObject (GetFirstItemInInventory (oOldVault)); int a=0; while (a<300) {            SetLocalInt (OBJECT_SELF, "Full", 1); DestroyObject (GetNextItemInInventory (oOldVault)); a++; }       DestroyObject (oOldVault); SetLocalInt (oPC, "DestroyAnyway", 0); }      else if ((GetIsObjectValid (oSlot1))) {      FloatingTextStringOnCreature ("Your old Vault has items!", oPC, FALSE); DelayCommand (1.0, FloatingTextStringOnCreature ("Use VaultMaker again to destroy anyway?", oPC, FALSE)); SetLocalInt (oPC, "DestroyAnyway", 1); }   } }