Rune_PRC8/_module/nss/xa_bank_onclose.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

38 lines
1.1 KiB
Plaintext

void EndSaveRoutine(object oStore, string sCampName, string sChest, object oPC)
{
StoreCampaignObject(sCampName,sChest,oStore, oPC);
DestroyObject(oStore);
SetLocked(OBJECT_SELF, TRUE);
DelayCommand(10.0,SetLocked(OBJECT_SELF, FALSE));
}
void RecursiveChestSave(object oStore, string sCampName, string sChest, object oPC, int iFirst=TRUE)
{
object oItem = GetFirstItemInInventory();
while(oItem != OBJECT_INVALID)
{
if(!iFirst || GetHasInventory(oItem))
{
ActionGiveItem(oItem, oStore);
}
oItem = GetNextItemInInventory();
}
if(iFirst)
{
AssignCommand(OBJECT_SELF, ActionDoCommand(RecursiveChestSave(oStore, sCampName, sChest,oPC, FALSE)));
return;
}
AssignCommand(OBJECT_SELF, ActionDoCommand(EndSaveRoutine(oStore, sCampName, sChest, oPC)));
}
void main()
{
object oPC = GetLastClosedBy();
string sName = GetName(oPC);
string sLeft = GetStringLeft(sName,4);
string sCampName = "BankVaults_" + sLeft;
object oStore = CreateObject(OBJECT_TYPE_CREATURE, "storage", GetLocation(OBJECT_SELF), FALSE);
RecursiveChestSave(oStore, sCampName, "Chest", oPC);
}