Frictional Games Forum (read-only)
How to make a make a door that need two keys to unlock it? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: How to make a make a door that need two keys to unlock it? (/thread-6807.html)

Pages: 1 2


RE: How to make a make a door that need two keys to unlock it? - Tanshaydar - 03-09-2011

yes, but

SetLocalVarInt("KeysUsed", GetLocalVarInt("KeysUsed")+1); is too long
AddLocalVarInt("KeysUsed", 1); is enough, and does the same thing.


RE: How to make a make a door that need two keys to unlock it? - Raymond - 03-09-2011

(03-09-2011, 10:33 AM)Tanshaydar Wrote: yes, but

SetLocalVarInt("KeysUsed", GetLocalVarInt("KeysUsed")+1); is too long
AddLocalVarInt("KeysUsed", 1); is enough, and does the same thing.

But i got an error said "Unexpected end of file".


RE: How to make a make a door that need two keys to unlock it? - Tanshaydar - 03-09-2011

Then there is something wrong, but the code I wrote works. I use it.


RE: How to make a make a door that need two keys to unlock it? - Anxt - 03-09-2011

Yes, that should work. Assuming, of course, the names of the keys are prisonkeylight_1 and prisonkeydark_1, and the door name is mansion_3. You can also add in a sanity boost inside the if statement, and anything else you want to happen, since it basically works as its own function. For example, if you wanted it to play a door unlocking sound, you would just place the PlaySoundAtEntity function with the SetSwingDoorLocked function.

Edit: whoops, sorry, didn't see that this had reached 2 pages. Ignore me Tongue

Edit 2: If you are getting an error that says unexpected end of file, it means you need to go back and look at where your "{ }" are, and make sure they are closing properly. Also check to make sure semicolons are placed in the right spots.


RE: How to make a make a door that need two keys to unlock it? - Raymond - 03-13-2011

Ok, i'll try checking Smile.


RE: How to make a make a door that need two keys to unlock it? - Raymond - 03-14-2011

Code:
void OnStart()
{
AddUseItemCallback("UseKey1", "prisonkeylight_1", "mansion_3", "KeyCounter", true);
SetLocalVarInt("KeysUsed", 0);
AddUseItemCallback("UseKey2", "prisonkeydark_1", "mansion_3", "KeyCounter", true);
}

void KeyCounter(string &in asItem, string &in asEntity)
{
SetLocalVarInt("KeysUsed", GetLocalVarInt("KeysUsed")+1);
if(GetLocalVarInt("KeysUsed")==2)
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
}

The error changed, now it says "a function with a same name and parameters already exist", did i put something wrong?


RE: How to make a make a door that need two keys to unlock it? - Raymond - 03-16-2011

Now the it doesn't have effects, my .hps is like this:
Code:
void Onstart()
{
AddUseItemCallback("UseKey1", "prisonkeylight_1", "mansion_3", "KeyCounter", true);
SetLocalVarInt("KeysUsed", 0);
AddUseItemCallback("UseKey2", "prisonkeydark_1", "mansion_3", "KeyCounter", true);
}

void KeyCounter(string &in asItem, string &in asEntity)
{
AddLocalVarInt("KeysUsed", 1);
if(GetLocalVarInt("KeysUsed")==2)
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
}

I use the first key and it says: "Cannot Use This Item Away!" Could someone please help?