Anxt
Senior Member
Posts: 588
Threads: 12
Joined: Mar 2011
Reputation:
10
|
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 |
|