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?
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#11
RE: How to make a make a door that need two keys to unlock it?

yes, but

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

(This post was last modified: 03-09-2011, 10:34 AM by Tanshaydar.)
03-09-2011, 10:33 AM
Website Find
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#12
RE: How to make a make a door that need two keys to unlock it?

(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".

One World To Another [DEMO] coming soon.
03-09-2011, 02:47 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#13
RE: How to make a make a door that need two keys to unlock it?

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

03-09-2011, 04:33 PM
Website Find
Anxt Offline
Senior Member

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

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.

(This post was last modified: 03-09-2011, 06:32 PM by Anxt.)
03-09-2011, 06:30 PM
Find
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#15
RE: How to make a make a door that need two keys to unlock it?

Ok, i'll try checking Smile.

One World To Another [DEMO] coming soon.
03-13-2011, 06:36 AM
Find
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#16
RE: How to make a make a door that need two keys to unlock it?

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?

One World To Another [DEMO] coming soon.
(This post was last modified: 03-14-2011, 06:13 AM by Raymond.)
03-14-2011, 04:05 AM
Find
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#17
RE: How to make a make a door that need two keys to unlock it?

Now the it doesn't have effects, my .hps is like this:
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?

One World To Another [DEMO] coming soon.
03-16-2011, 07:22 AM
Find




Users browsing this thread: 1 Guest(s)