| 
		
	
		| Tanshaydar   From Beyond
 
 Posts: 3,085
 Threads: 17
 Joined: Mar 2009
 Reputation: 
67
 | 
			| 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 |  |  
	
		| Raymond   Member
 
 Posts: 126
 Threads: 24
 Joined: Feb 2011
 Reputation: 
0
 | 
			| 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 |  |  
	
		| Tanshaydar   From Beyond
 
 Posts: 3,085
 Threads: 17
 Joined: Mar 2009
 Reputation: 
67
 | 
			| 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 |  |  
	
		| 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? 
 
				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    
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 |  |  
	
		| Raymond   Member
 
 Posts: 126
 Threads: 24
 Joined: Feb 2011
 Reputation: 
0
 | 
			| RE: How to make a make a door that need two keys to unlock it? 
 
				Ok, i'll try checking   .
			
 One World To Another [DEMO] coming soon. |  |  
	| 03-13-2011, 06:36 AM |  |  
	
		| Raymond   Member
 
 Posts: 126
 Threads: 24
 Joined: Feb 2011
 Reputation: 
0
 | 
			| 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 |  |  
	
		| Raymond   Member
 
 Posts: 126
 Threads: 24
 Joined: Feb 2011
 Reputation: 
0
 | 
			| 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 |  |  |