Haven't used CEP in some time but this is what I used to use with it:
[nwscript]
//:://////////////////////////////////////
// void AutoCloseDoor( object oDoor, int bAutoLock. float fDelay = 12.50f)
// Automatically closes the specified door and optionally lock it after the given
// number of seconds. The door can be either a standard toolset door or a CEP style
// placeable door. Doors with no locks on them will not be locked even if the auto-lock
// option is used. The default is to wait 12.5 seconds before closing and the door is
// left unlocked.
//:://////////////////////////////////////
// Parameters: object oDoor - the door to be closed.
// int bAutoLock - if TRUE the door will also lock if it has a lock on it.
// if FALSE the door will remain unlocked even if it has a lock on it.
// default = FALSE.
// float fDelay - how long to wait before closing the door. default = 12.5 seconds.
//
// Returns: None.
//:://////////////////////////////////////
void AutoCloseDoor( object oDoor, int bAutoLock = FALSE, float fDelay = 12.50f);
void AutoCloseDoor( object oDoor, int bAutoLock = FALSE, float fDelay = 12.50f)
{ if( fDelay <= 0.0f) fDelay = 12.5f;
if( !GetIsObjectValid( oDoor)) return;
if( GetObjectType( oDoor) == OBJECT_TYPE_DOOR)
{ // Standard toolset door
if( GetIsOpen( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay, ActionCloseDoor( oDoor)));
if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.1f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
}
else if( GetObjectType( oDoor) == OBJECT_TYPE_PLACEABLE)
{ string sGateBlock = GetLocalString( oDoor, "CEP_L_GATEBLOCK");
if( sGateBlock != "")
{ // CEP placeable door
if( GetIsOpen( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay, PlayAnimation( ANIMATION_PLACEABLE_CLOSE)));
if( !GetIsObjectValid( GetLocalObject( oDoor, "GateBlock")))
{ object oGateBlock = CreateObject( OBJECT_TYPE_PLACEABLE, sGateBlock, GetLocation( oDoor));
if( GetIsObjectValid( oGateBlock)) AssignCommand( oDoor, DelayCommand( fDelay +0.1f, SetLocalObject( oDoor, "GateBlock", oGateBlock)));
else AssignCommand( oDoor, DelayCommand( fDelay +0.1f, DeleteLocalObject( oDoor, "GateBlock")));
}
if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.2f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
}
else
{ // Standard toolset placeable door.
if( GetLocalInt( oDoor, "IsOpen"))
{ AssignCommand( oDoor, DelayCommand( fDelay, PlayAnimation( ANIMATION_PLACEABLE_CLOSE)));
AssignCommand( oDoor, DelayCommand( fDelay +0.1f, DeleteLocalInt( oDoor, "IsOpen")));
}
if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.2f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
}
}
}
[/nwscript]
Modifié par Axe_Murderer, 08 septembre 2011 - 05:48 .