Script #2: Door Guard
I also realize it is easy to automatically close a door. However, most of the scripts already made just close it. It gets you wondering when no-one is around, when all of a sudden the door closes behind you. This script actually has someone close it: The nearest person with the tag "DoorGuard". This script is placed on the door's OnOpen slot. Note that the script does not re-lock doors, or even check if the door has already been closed.




// This script, usually set to OnOpen, will command the nearest guard
// with the tag "DoorGuard" to wait 5 seconds, close the door, then
// return to where he was.
// Script created 8/14/2002 by Bokombur
void main()
{
object oGuard = GetNearestObjectByTag("DoorGuard", OBJECT_SELF, 1);
SetLocalLocation(oGuard, "BeforeDoorAction", GetLocation(oGuard));
AssignCommand(oGuard, ActionWait(5.0));
AssignCommand(oGuard, ActionCloseDoor(GetNearestObject(OBJECT_TYPE_DOOR,OBJECT_SELF,1)));
AssignCommand(oGuard, ActionMoveToLocation(
GetLocalLocation(oGuard, "BeforeDoorAction"),FALSE));
}






/* The change was in the ActionCloseDoor. It originally said OBJECT_SELF. I realized that the guard was trying to close himself. Unless he has his fly open he can't do that. Note that now you must place the guard close enough to the door so that it actually is the closest door. */