Hidden: show
Code: Select all
// Amount of seconds door will delay to check for nearby PC or close
// Change this to desired time
const float fDELAY = 9.0;
// If someone is standing 5 meters or less
// to the door, check again in fDELAY seconds
void CloseCheck();
void main()
{
DelayCommand( fDELAY, CloseCheck() );
}
void CloseCheck()
{
object oPC = GetNearestCreature( CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC );
if( GetIsObjectValid( oPC ) &&
GetDistanceToObject( oPC ) <= 5.0 )
{// PC is near me so don't close
DelayCommand( fDELAY, CloseCheck() );
return;
}
// No PC nearby so go ahead and close
ActionCloseDoor( OBJECT_SELF );
}