Amon_PRC8/_module/nss/pcnt_close.nss
Jaysyn904 c5cffc37af Initial Commit
Initial Commit [v1.01]
2025-04-03 19:00:46 -04:00

84 lines
2.0 KiB
Plaintext

//*****************************************************************************
/*
Filename: pcnt_close
To Use:
attach this script to the OnClose event of a container
you can customize several parameters:
choose object TAG for ID generation (ReflexSafe != 2)
!! use this to share inventories
!! use this for moving inventories (like creatures)
use player for ID generation (ReflexSafe = 2)
!! use this for player vaults. each player gets his own inventory
!! from a single container
Created By: Unknown??
Modified By: Gregg Anderson
10/9/2006
*/
//*****************************************************************************
#include "horse_include"
void main()
{
string sTag = GetTag(OBJECT_SELF);
int nType = GetReflexSavingThrow(OBJECT_SELF);
if(nType == 2)
sTag = GetPCPlayerName(GetLastOpenedBy());
string sVarName;
int i = 0;
object obj = GetFirstItemInInventory();
object bag;
while( obj != OBJECT_INVALID )
{
if( GetHasInventory( obj ) )
{
bag = obj;
obj = GetFirstItemInInventory(bag);
while( obj != OBJECT_INVALID )
{
SetLocalInt(obj, "bagged", TRUE);
obj = GetNextItemInInventory(bag);
}
}
obj = GetNextItemInInventory();
}
int iMax = 0;
object oItem = GetFirstItemInInventory();
while (oItem != OBJECT_INVALID)
{
sVarName = sTag + "_" + IntToString(i);
if ((GetLocalObject(OBJECT_SELF, sVarName) != oItem) && (!GetLocalInt(oItem, "bagged")))
{
StoreCampaignObject(CAMPAIGN_DATABASE, sVarName, oItem);
SetLocalObject(OBJECT_SELF, sVarName, oItem);
}
if (!GetLocalInt(oItem, "bagged"))
{
iMax++;
i++;
}
else
{
DeleteLocalInt(oItem, "bagged");
}
oItem = GetNextItemInInventory();
}
SetCampaignInt(CAMPAIGN_DATABASE, sTag + "_n", iMax);
}