Files
Anphillia_PRC8/_module/nss/pcnt_close.nss
Jaysyn904 28cdb617b3 Initial commit
Adding all of the current content for Anphillia Unlimited.
2024-01-04 07:49:38 -05:00

71 lines
2.7 KiB
Plaintext

//::///////////////////////////////////////////////
//:: 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..
- added fix to prevent action-spam exploit
*/
//:://////////////////////////////////////////////
//:: Created By: Knat
//:: Created On: 28.6.03
//:://////////////////////////////////////////////
#include "PINV_inc"
void main()
{
// this will fix a dangerous action-spam exploit
// finally some use for GetTimeMillisecond
int nThisTime = GetTimeMillisecond();
int nLastTime = GetLocalInt(OBJECT_SELF,"EVT_LASTTIME");
SetLocalInt(OBJECT_SELF,"EVT_LASTTIME",nThisTime);
if(nThisTime != nLastTime) // proceed only if internal time moved forward
{
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);
}
}