Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with script
amusei Offline
Junior Member

Posts: 23
Threads: 8
Joined: Aug 2012
Reputation: 2
#5
RE: Help with script

(08-28-2012, 07:12 AM)andyrockin123 Wrote: 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!
Thanks. That solved the problem. I will never underestimate the power of variables again!
08-28-2012, 07:22 AM
Find


Messages In This Thread
Help with script - by amusei - 08-27-2012, 10:16 AM
RE: Help with script - by Adny - 08-27-2012, 10:36 AM
RE: Help with script - by amusei - 08-28-2012, 07:02 AM
RE: Help with script - by Adny - 08-28-2012, 07:12 AM
RE: Help with script - by amusei - 08-28-2012, 07:22 AM



Users browsing this thread: 1 Guest(s)