Aschbourne_PRC8/_module/nss/per_safe_item_st.nss

51 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2024-06-14 10:48:20 -04:00
//ScarFace's Persistent Baking system -OnClose-
void main()
{
ActionLockObject(OBJECT_SELF);
object oPC = GetLastUsedBy();
string sKey = GetPCPublicCDKey(oPC);
object oItem = GetFirstItemInInventory(OBJECT_SELF);
int iCount = 1;
while (GetIsObjectValid(oItem))
{
oItem = GetNextItemInInventory(OBJECT_SELF);
iCount++;
}
if (iCount >=101)
{
FloatingTextStringOnCreature("**WARNING** You can't store more than 100 items. You have "+IntToString(iCount)+" items in the chest. No items were saved. Please remove some items", oPC);
ActionUnlockObject(OBJECT_SELF);
return;
}
iCount = 1;
oItem = GetFirstItemInInventory(OBJECT_SELF);
if (!GetIsObjectValid(oItem))
{
iCount = 0;
}
string sCount;
while (GetIsObjectValid(oItem))
{
sCount = IntToString(iCount);
StoreCampaignObject("STORAGE", sKey+sCount, oItem, oPC);
DestroyObject(oItem);
oItem = GetNextItemInInventory(OBJECT_SELF);
iCount++;
}
if (iCount == 0)
{
FloatingTextStringOnCreature("Chest empty, No items saved", oPC);
ActionUnlockObject(OBJECT_SELF);
return;
}
FloatingTextStringOnCreature("Items successfully saved", oPC);
ActionUnlockObject(OBJECT_SELF);
}