| 
		
	
		| Smackdown   Junior Member
 
 Posts: 13
 Threads: 3
 Joined: Jan 2013
 Reputation: 
0
 | 
			| Lever and Entity 
 
				Hello
 I want that when I turn a lever, there appear and disappear some Entities I want, I also want to add a sound. So it should look like that?
 
 void OnStart()
 {
 ??????("mechanismus2", "lever2", "????", true, false, 0);
 }
 
 
 
 
 void func2(string &in asEntity)
 {
 AddLocalVarInt("Var1", 1);
 lever2();
 }
 
 void lever2()
 {
 if(GetLocalVarInt("Var1") == 1)
 
 {
 PlaySoundAtEntity("", "explosion_rock_large.snt", "player", 0.5f, false);
 GiveSanityBoostSmall();
 SetEntityActive("wine02_1", true);
 
 }
 }
 
 
 
 Or how do I script that? I don't get it. Please help
 |  |  
	| 05-07-2013, 03:45 PM |  |  
	
		| Tomato Cat   Senior Member
 
 Posts: 287
 Threads: 2
 Joined: Sep 2012
 Reputation: 
20
 | 
			| RE: Lever and Entity 
 
				So...You want to pull a lever and have an entity appear/disappear? 
You have it mostly right. You don't really need the variable, though.
 
For example, this should be a SetEntityConnectionStateChangeCallback
 void OnStart(){
 ??????("mechanismus2", "lever2", "????", true, false, 0);
 }
 
 //Include this in your OnStart
 SetEntityConnectionStateChangeCallback("name of your lever", "the function to call");
 
The callback function's syntax would look like this:
 void YourFunction(string &in asEntity, int alState){
 //This checks what "state" the lever is in
 if(alState == 1) //1 is on, 0 is in between and -1 means off
 {
 //Do what you want to happen here
 }
 
 }
 
				
(This post was last modified: 05-07-2013, 04:06 PM by Tomato Cat.)
 |  |  
	| 05-07-2013, 04:04 PM |  |  
	
		| Smackdown   Junior Member
 
 Posts: 13
 Threads: 3
 Joined: Jan 2013
 Reputation: 
0
 | 
			| RE: Lever and Entity 
 
				Thank you very much.  
All things work, except the sound. It does not play the explosion thing on player:
 void explosion(string &in asEntity, int alState){
 //This checks what "state" the lever is in
 if(alState == 1) //1 is on, 0 is in between and -1 means off
 {
 PlaySoundAtEntity("", "", "player", 0.5f, false);
 PlaySoundAtEntity("", "explosion_rock_large.snt", "player", 0, false);
 GiveSanityBoostSmall();
 SetEntityActive("wood_beam_2", false);
 SetEntityActive("wood_beam_3", false);
 SetEntityActive("wood_beam_4", false);
 SetEntityActive("rock_debris_brown02_*", false);
 SetEntityActive("stone_med01_brown_8", false);
 SetEntityActive("stone_med01_brown_9", false);
 SetEntityActive("stone_med01_brown_10", false);
 SetEntityActive("stone_med01_brown_11", false);
 
 }
 
 }
 
 |  |  
	| 05-07-2013, 04:32 PM |  |  
	
		| Tomato Cat   Senior Member
 
 Posts: 287
 Threads: 2
 Joined: Sep 2012
 Reputation: 
20
 | 
			| RE: Lever and Entity 
 
				I'm not sure if it matters, but try capitalizing "player."
			 |  |  
	| 05-07-2013, 04:41 PM |  |  
	
		| DnALANGE  Banned
 
 Posts: 1,549
 Threads: 73
 Joined: Jan 2012
 | 
			| RE: Lever and Entity 
 
				player must be Player.try that and remove the other line, it is useless there : PlaySoundAtEntity("", "", "player", 0.5f, false);
 |  |  
	| 05-07-2013, 05:00 PM |  |  
	
		| Smackdown   Junior Member
 
 Posts: 13
 Threads: 3
 Joined: Jan 2013
 Reputation: 
0
 | 
			| RE: Lever and Entity 
 
				Ill try 
 
How do I delet posts? ^^
 
Thank you, that was the fault. Now it works with Player   
				
(This post was last modified: 05-07-2013, 05:22 PM by Smackdown.)
 |  |  
	| 05-07-2013, 05:19 PM |  |  |