dailycreepypasta 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 32 
	Threads: 18 
	Joined: Aug 2014
	
 Reputation: 
0
		
	 | 
	
		
			
AddUseItem Callback Not Working 
			 
			
				To my luck, something else didn't work. I have a crowbar item in one of my maps named "Crowbar". I have a script that requires the item to function properly. So, while testing the mod I got the crowbar and went to the level with the script. The script isn't working for me! Here's the script I'm using: 
void OnStart() {         AddUseItemCallback("", "Crowbar", "Door", "UseCrowbarOnDoor", true); }
  void UseCrowbarOnDoor(string &in asItem, string &in asEntity) {         RemoveItem(asItem);         PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);         AddTimer(asEntity, 0.2, "TimerPlaceCrowbar"); }   void TimerPlaceCrowbar(string &in asTimer) {         SetEntityActive("Joint", true);         PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false); }   void BreakDoor(string &in asParent, string &in asChild, int alState) {         SetEntityActive("Joint", false);         SetEntityActive("Broken", true);           SetSwingDoorLocked("Door", false, false);         SetSwingDoorClosed("Door", false, false);         SetSwingDoorDisableAutoClose("Door", true);           AddPropImpulse("Door", 0, 0, 3, "world");           CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);         PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false);           GiveSanityBoostSmall();           PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);           AddTimer("", 0.1, "TimerPushDoor"); }   void TimerPushDoor(string &in asTimer) {         AddPropImpulse("Door", -4, 2, 1, "world");         AddTimer("", 1.1, "TimerDoorCanClose"); }   void TimerDoorCanClose(string &in asTimer) {         SetSwingDoorDisableAutoClose("Door", false); } 
 
 
I made sure that the names match and that the casing is the same, and I don't use the crowbar in any script except for one to set an entity inactive. What could be the problem?
			  
			
			
 
			
		 |  
	 
 | 
 
	| 04-06-2015, 05:46 AM  | 
	
		
	 | 
 
 
	
		
		DnALANGE 
 
 
		
			Banned 
			
			
			
 
			
	Posts: 1,549 
	Threads: 73 
	Joined: Jan 2012
	
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				Are you 100% sure the names are right and you use the Crowbar in the RIGHT door? 
Is this the entre script? 
This script looks quite standard to me, so i guess that should work fine. 
Let us know if the door and Crowbar or good.
			 
			
			
			
		 |  
	 
 | 
 
	| 04-06-2015, 10:30 AM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				You're missing the collide callback for the crowbar and the area. 
AddEntityCollideCallback("Crowbar", "NAME_OF_AREA", "BreakDoor", true, 1);
  
			 
			
			
 
Derp. 
			
		 |  
	 
 | 
 
	| 04-06-2015, 12:29 PM  | 
	
		
	 | 
 
 
	
		
		FlawlessHappiness 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 3,980 
	Threads: 145 
	Joined: Mar 2012
	
 Reputation: 
171
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				 (04-06-2015, 12:29 PM)Neelke Wrote:  You're missing the collide callback for the crowbar and the area. 
 
AddEntityCollideCallback("Crowbar", "NAME_OF_AREA", "BreakDoor", true, 1);
  
It's an AddUseItemCallback, not an AddEntityCollideCallback.
 
OT: 
I can't see any problems. As Lange said, check your names again. For capitals and numbers.
			  
			
			
 
Trying is the first step to success. 
			
		 |  
	 
 | 
 
	| 04-07-2015, 07:14 AM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				 (04-07-2015, 07:14 AM)FlawlessHappiness Wrote:   (04-06-2015, 12:29 PM)Neelke Wrote:  You're missing the collide callback for the crowbar and the area. 
 
AddEntityCollideCallback("Crowbar", "NAME_OF_AREA", "BreakDoor", true, 1);
   
It's an AddUseItemCallback, not an AddEntityCollideCallback. 
 
OT: 
I can't see any problems. As Lange said, check your names again. For capitals and numbers. 
Then what's this for?
 void BreakDoor(string &in asParent, string &in asChild, int alState) 
{ 
        SetEntityActive("Joint", false); 
        SetEntityActive("Broken", true); 
  
        SetSwingDoorLocked("Door", false, false); 
        SetSwingDoorClosed("Door", false, false); 
        SetSwingDoorDisableAutoClose("Door", true); 
  
        AddPropImpulse("Door", 0, 0, 3, "world"); 
  
        CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false); 
        PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false); 
  
        GiveSanityBoostSmall(); 
  
        PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false); 
  
        AddTimer("", 0.1, "TimerPushDoor"); 
}
 
If you check the Guest Room in the main game, they use a collide function for being able to determine where the crowbar is located. If this script does not require collide function, then why is this function even here? This script require both an AddUseItemCallback and an AddEntityCollideCallback.
			  
			
			
 
Derp. 
			
				
(This post was last modified: 04-07-2015, 07:54 AM by Neelke.)
 
				
			 
		 |  
	 
 | 
 
	| 04-07-2015, 07:50 AM  | 
	
		
	 | 
 
 
	
		
		FlawlessHappiness 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 3,980 
	Threads: 145 
	Joined: Mar 2012
	
 Reputation: 
171
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				It's true it does, but perhaps he hasn't gotten that far yet, and just wants to check whether his AddUseItemCallback is working. 
 
He says it isn't, so before causing too much confusion can we solve 1 problem at a time, please?
			 
			
			
 
Trying is the first step to success. 
			
		 |  
	 
 | 
 
	| 04-07-2015, 08:00 AM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				Oh, sorry didn't see that. Then I say the same as Flawless and DnALANGE.
			 
			
			
 
Derp. 
			
		 |  
	 
 | 
 
	| 04-07-2015, 08:12 AM  | 
	
		
	 | 
 
 
	
		
		Mudbill 
 
 
		
			Muderator 
			
			
			
 
			
	Posts: 3,881 
	Threads: 59 
	Joined: Apr 2013
	
 Reputation: 
179
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				I guess we'll have to hear what OP means by "script not working" because that might just mean that the whole thing isn't working as expected, in which case the collide callback should do it.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 04-07-2015, 09:30 AM  | 
	
		
	 | 
 
 
	
		
		FlawlessHappiness 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 3,980 
	Threads: 145 
	Joined: Mar 2012
	
 Reputation: 
171
		
	 | 
	
		
			
RE: AddUseItem Callback Not Working 
			 
			
				 (04-07-2015, 09:30 AM)Mudbill Wrote:  I guess we'll have to hear what OP means by "script not working" because that might just mean that the whole thing isn't working as expected, in which case the collide callback should do it. 
I was thinking the same... Error? Nothing?
			  
			
			
 
Trying is the first step to success. 
			
		 |  
	 
 | 
 
	| 04-07-2015, 10:08 AM  | 
	
		
	 | 
 
 
	 
 |