| 
		
	
		| 1402News   Junior Member
 
 Posts: 4
 Threads: 1
 Joined: Jan 2018
 Reputation: 
0
 | 
			| Can't make an unlockable door 
 
				I've been trying all the solutions I can but nothing works! Here's my script.
 void OnStart()
 {
 AddUseItemCallback("", "CSBedroomKey", "CSBedroomDoor", "UseKeyOnCSBedroomDoor", true);
 }
 void FUNCTION(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 |  |  
	| 01-22-2018, 06:55 AM |  |  
	
		| Romulator   Not Tech Support ;-)
 
 Posts: 3,628
 Threads: 63
 Joined: Jan 2013
 Reputation: 
195
 | 
			| RE: Can't make an unlockable door 
 
				You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this: void UseKeyOnCSBedroomDoor(string &in asItem, string &in asEntity){
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
Provided your key and door names are correct in your map, then this script should work correctly now.   
 Discord: Romulator#0001
![[Image: 3f6f01a904.png]](https://puu.sh/zOxJg/3f6f01a904.png) |  |  
	| 01-22-2018, 06:17 PM |  |  
	
		| 1402News   Junior Member
 
 Posts: 4
 Threads: 1
 Joined: Jan 2018
 Reputation: 
0
 | 
			| RE: Can't make an unlockable door 
 
				 (01-22-2018, 06:17 PM)Romulator Wrote:  You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:
 
 void UseKeyOnCSBedroomDoor(string &in asItem, string &in asEntity){
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
Provided your key and door names are correct in your map, then this script should work correctly now.
  
So in other words, remove the FUNCTION part?
 
  (01-23-2018, 01:13 AM)1402News Wrote:   (01-22-2018, 06:17 PM)Romulator Wrote:  You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:
 
 void UseKeyOnCSBedroomDoor(string &in asItem, string &in asEntity){
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
Provided your key and door names are correct in your map, then this script should work correctly now.
  So in other words, remove the FUNCTION part?
 
Actually, I've tried it with the function saying FUNCTION and the door still wouldn't unlock.
			 
				
(This post was last modified: 01-23-2018, 01:21 AM by 1402News.)
 |  |  
	| 01-23-2018, 01:13 AM |  |  
	
		| 1402News   Junior Member
 
 Posts: 4
 Threads: 1
 Joined: Jan 2018
 Reputation: 
0
 | 
			| RE: Can't make an unlockable door 
 
				 (01-22-2018, 06:17 PM)Romulator Wrote:  You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:
 
 void UseKeyOnCSBedroomDoor(string &in asItem, string &in asEntity){
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
Provided your key and door names are correct in your map, then this script should work correctly now.
  I attempted it. It doesn't work. It still says "Cannot use item this way".
			 |  |  
	| 01-23-2018, 04:27 PM |  |  
	
		| Mudbill   Muderator
 
 Posts: 3,881
 Threads: 59
 Joined: Apr 2013
 Reputation: 
179
 | 
			| RE: Can't make an unlockable door 
 
				Can you screenshot the names of the objects in your level editor and upload them to https://imgur.com  and link them here?
			
 |  |  
	| 01-24-2018, 10:29 PM |  |  
	
		| Neelke   Senior Member
 
 Posts: 668
 Threads: 82
 Joined: Apr 2013
 Reputation: 
26
 | 
			| RE: Can't make an unlockable door 
 
				 (01-23-2018, 04:27 PM)1402News Wrote:   (01-22-2018, 06:17 PM)Romulator Wrote:  You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:I attempted it. It doesn't work. It still says "Cannot use item this way".
 
 void UseKeyOnCSBedroomDoor(string &in asItem, string &in asEntity){
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
Provided your key and door names are correct in your map, then this script should work correctly now.
  
As far as I know you've flipped the two string parameters? I could be wrong but the function is programmed to have the entity first, then the item parameter. This won't help your current issue but it would help later on I imagine since your code is dependant on the parameters.
 void UseKeyOnCSBedroomDoor(string &in asEntity, string &in asItem){
 SetSwingDoorLocked(asEntity, false, true);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
 Derp. 
				
(This post was last modified: 01-26-2018, 11:47 AM by Neelke.)
 |  |  
	| 01-26-2018, 11:45 AM |  |  
	
		| Mudbill   Muderator
 
 Posts: 3,881
 Threads: 59
 Joined: Apr 2013
 Reputation: 
179
 | 
			| RE: Can't make an unlockable door 
 
				No, the item comes first. ![[Image: uGyZChQ.png]](https://i.imgur.com/uGyZChQ.png) 
 |  |  
	| 01-27-2018, 01:12 AM |  |  |