I am sorry for asking in this thread, but i figured since this thread is exactly what i'm trying to do, i shouldn't make a new topic.
I am trying to make it so when the player walks into a room, they walk into an area (door_close_trigger) that will close the door behind them IF they left it open.
under OnStart i have these two:
"AddEntityCollideCallback("storage_door1", "monster_scare3", "DoorState", true, 0);
AddEntityCollideCallback("Player", "door_close_trigger", "CloseDoor", true, 1);"
later in the script i have:
"void DoorState(string &in asParent, string &in asChild, int alState)
{
if (alState == 1)
{
SetLocalVarInt("DoorOpen", 1);
}
if (alState == -1)
{
SetLocalVarInt("DoorOpen", 0);
}
}"
and then:
"void CloseDoor(string &in asParent , string &in asChild , int alState)
{
if(GetLocalVarInt("DoorOpen") == 1)
{
SetSwingDoorLocked("storage_door1", true, true);
GiveSanityDamage(15.0f, true);
PlaySoundAtEntity("", "lock_door.snt", "monster_scare3", 0.0f, false);
PlaySoundAtEntity("", "react_breath.snt", "Player", 0.0f, false);
}
if(GetLocalVarInt("DoorOpen") == 0)
{
AddDebugMessage("Door is closed!
", false);
}
}
"
When i test this in-game i always get the debug message "Door is closed!
" even if it is obviously open, help would be very much appreciated.