RE: Help with script
The power of variables! Here ya go:
void OnStart()
{
AddUseItemCallback("", "key_hall", "mansion_6", "UnlockDoorWithKey", true);
SetEntityPlayerInteractCallback("mansion_6", "Fade", false);
SetLocalVarInt("door_var", 0);
}
void UnlockDoorWithKey(string &in asItem, string &in asEntity)
{
CompleteQuest("keyquest", "KeyQuest");
SetSwingDoorLocked("mansion_6", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_6", 0, false);
RemoveItem("key_hall");
AddLocalVarInt("door_var", 1);
}
void Fade(string &in asEntity)
{
if(GetSwingDoorLocked("mansion_6") == false && GetLocalVarInt("door_var") == 1)
{
SetSwingDoorClosed("mansion_3", true, true);
SetSwingDoorLocked("mansion_3", true, true);
PlaySoundAtEntity("", "guardian_activated.snt", "Player", 0, false);
GiveSanityDamage(10, true);
StartScreenShake(0.05f, 3.5f, 1.25f, 3.5f);
FadePlayerRollTo(-50, 33, 33);
MovePlayerHeadPos(0, -1, 0, 1, 0);
PlaySoundAtEntity("", "player_bodyfall.snt", "Player", 0, false);
SetPlayerCrouching(true);
SetPlayerActive(false);
FadeOut(7);
AddTimer("", 13, "Fog");
SetLocalVarInt("door_var", 0);
}
}
I added a local variable that is added when the key is used to unlock the door; if the player interacts with the door while it is unlocked it will trigger the event (by adding the variable), then disable it from occuring again by setting the variable back to 0.
Hope that helped!
I rate it 3 memes.
|