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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a make a door that need two keys to unlock it?
Anxt Offline
Senior Member

Posts: 588
Threads: 12
Joined: Mar 2011
Reputation: 10
#4
RE: How to make a make a door that need two keys to unlock it?

An example of the code Tanshaydar mentioned would look something like this:

void OnStart()
{
AddUseItemCallback("UseKey1", "Key1", "LockedDoor", "KeyCounter", true);
AddUseItemCallback("UseKey2", "Key2", "LockedDoor", "KeyCounter", true);
SetLocalVarInt("KeysUsed", 0);
}

void KeyCounter(string &in asItem, string &in asEntity)
{
SetLocalVarInt("KeysUsed", GetLocalVarInt("KeysUsed")+1);

if(GetLocalVarInt("KeysUsed")==2)
{
SetSwingDoorLocked("LockedDoor", false, true);
}
}

You could also use two separate variables and set them equal to 1 when using the key, then add a similar if statement to check if both are 1, but I think the way above is a bit easier.

Sorry if there are any typos in the code.

03-07-2011, 07:27 PM
Find


Messages In This Thread
RE: How to make a make a door that need two keys to unlock it? - by Anxt - 03-07-2011, 07:27 PM



Users browsing this thread: 1 Guest(s)