Frictional Games Forum (read-only)

Full Version: Prison section door close?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying out a script that will only trigger when a prison_section type of door is closed. It works fine if I run the script before I open the door, but if I open it and then close it, the script keeps coming back as saying that it's open. I've tried shutting it and closing the padlock latch too, but the script still says the door is open. Is there a way to fix this?

I've already looked in the entity to try and enable auto-closing it, but there doesn't seem to be an option for it.
What kind of door? A normal one, a vertical one? Also, put your .hps file, please. Or the problematic part, if you wish.
It's a swing door. But it's different from the others in that it doesn't auto-close and has another latch for the padlock.

PHP Code:
void OnStart()
{
AddUseItemCallback("""padlock1""prison_section_1""UsePadlock1"false);
}

void UsePadlock1(string &in asItemstring &in asEntity)
{
    if (
GetSwingDoorClosed("prison_section_1") == true)
    {
        
SetSwingDoorLocked("prison_section_1"truetrue);
        
PlaySoundAtEntity("""lock_door""prison_section_1"0false);
        
SetEntityActive("padlock_1"true);
        
RemoveItem("padlock1");
    }
    else
    {
        
SetMessage("Ch05Misc""dooropen"0);
    }


Basically it's playing the "dooropen" message even after I've closed the door and the latch. And to head off any questions, I have also tried simply "if (GetSwingDoorClosed("prison_section_1"))" but I get the same result.
Okay, I actually solved the problem in a really easy way, so never mind!

PHP Code:
void OnStart()
{
AddUseItemCallback("""padlock1""prison_section_1""UsePadlock1"false);
}

void UsePadlock1(string &in asItemstring &in asEntity)
{
    
SetSwingDoorClosed("prison_section_1"truetrue);
    
SetEntityInteractionDisabled("prison_section_1"true);
    
RemoveItem(asItem);
    
AddTimer("1lock1"0.25f"TimerLock1");
    
AddTimer("1lock2"1.0f"TimerLock1");
}

void TimerLock1(string &in asTimer)
{
    if(
asTimer == "1lock1")
    {
        
AddPropForce("prison_section_1"100000"world");
    }
    if(
asTimer == "1lock2")
    {
        
SetSwingDoorLocked("prison_section_1"truetrue);
        
PlaySoundAtEntity("""lock_door""prison_section_1"0false);
        
SetEntityInteractionDisabled("prison_section_1"false);
        
SetEntityActive("padlock_1"true);
    }


Now when I use the padlock, the door will close, then the latch will close, and it locks with the padlock on it!