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
Lever and Entity
Smackdown Offline
Junior Member

Posts: 13
Threads: 3
Joined: Jan 2013
Reputation: 0
#1
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
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

PHP Code: (Select All)
void OnStart()
{
??????(
"mechanismus2""lever2""????"truefalse0);
}

//Include this in your OnStart 
SetEntityConnectionStateChangeCallback("name of your lever""the function to call"); 

The callback function's syntax would look like this:

PHP Code: (Select All)
void YourFunction(string &in asEntityint 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
Find
Smackdown Offline
Junior Member

Posts: 13
Threads: 3
Joined: Jan 2013
Reputation: 0
#3
RE: Lever and Entity

Thank you very much.
All things work, except the sound. It does not play the explosion thing on player:

PHP Code: (Select All)
void explosion(string &in asEntityint 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.5ffalse);
 
PlaySoundAtEntity("""explosion_rock_large.snt""player"0false);
    
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#4
RE: Lever and Entity

I'm not sure if it matters, but try capitalizing "player."
05-07-2013, 04:41 PM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#5
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
Find
Smackdown Offline
Junior Member

Posts: 13
Threads: 3
Joined: Jan 2013
Reputation: 0
#6
RE: Lever and Entity

Ill try

How do I delet posts? ^^


Thank you, that was the fault. Now it works with Player Wink
(This post was last modified: 05-07-2013, 05:22 PM by Smackdown.)
05-07-2013, 05:19 PM
Find




Users browsing this thread: 1 Guest(s)