Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help [SOLVED] Levers
Straxedix Offline
Senior Member

Posts: 426
Threads: 52
Joined: Mar 2014
Reputation: 5
#1
Wink  [SOLVED] Levers

Hi i saw in some Fcm-s,Cs-s...When you pull the lever lights turn off or on so if can someone explain me that how to make it.I never did something like that before :P

(This post was last modified: 10-19-2014, 09:05 AM by Straxedix.)
10-18-2014, 07:06 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Levers

Levers work, with the thing called "alState".

This is the callback for a lever, placed in void OnStart() (For beginners)

PHP Code: (Select All)
SetEntityConnectionStateChangeCallback(stringasNamestringasCallback); 

The function will look like this:

PHP Code: (Select All)
void Func(string &in asEntityint alState
{
if(
alState == 1)
{
//If ON
}

if(
alState == -1)
{
//If OFF
}


Simply put in SetLampLit when ON and OFF, and put in false and true, for whatever your liking ^^

Trying is the first step to success.
(This post was last modified: 10-18-2014, 07:25 AM by FlawlessHappiness.)
10-18-2014, 07:20 AM
Find
Straxedix Offline
Senior Member

Posts: 426
Threads: 52
Joined: Mar 2014
Reputation: 5
#3
RE: Levers

string& asName ? name of lever ?

Cause i wanna shut down Light (spot light) and entity...

(This post was last modified: 10-18-2014, 07:28 AM by Straxedix.)
10-18-2014, 07:25 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Levers

It's a simple callback.
Just like with a collide callback.

Try using logic here.

In a collide callback you have object A colliding with object B, creating a FUNCTION.

So what happens in the lever callbacK?
It's simply a lever that calls a FUNCTION.

Meaning, string &in asName == The name of the lever, yep.

Trying is the first step to success.
10-18-2014, 07:28 AM
Find
Straxedix Offline
Senior Member

Posts: 426
Threads: 52
Joined: Mar 2014
Reputation: 5
#5
RE: Levers

Uhm no not working

Spoiler below!
PHP Code: (Select All)
void OnStart()
{
SetEntityConnectionStateChangeCallback("Lever00""Lever");
}

void Lever(string &in asEntityint alState
{
if(
alState == 1)
{
//If ON
}

if(
alState == -1)
{
//If OFF
}



EDIT:Could you explain a little i am doing that kinda script for the first time :I

(This post was last modified: 10-18-2014, 07:36 AM by Straxedix.)
10-18-2014, 07:35 AM
Find
Straxedix Offline
Senior Member

Posts: 426
Threads: 52
Joined: Mar 2014
Reputation: 5
#6
RE: Levers

Bump ?

10-18-2014, 08:38 AM
Find
Straxedix Offline
Senior Member

Posts: 426
Threads: 52
Joined: Mar 2014
Reputation: 5
#7
RE: Levers

Bump :3

10-18-2014, 10:20 AM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#8
RE: Levers

PHP Code: (Select All)
void Func(string &in asEntityint alState
{
if(
alState == 1)
{
//If ON
}

if(
alState == -1)
{
//If OFF


Those two little bastards allow you to do what happens whether you pull them up or down, I beleive 1 is if you pull lever up, so basically put the stuff you want to happen in the state 1, if neither that helps try putting the stuff to -1 instead of 1.
10-18-2014, 11:41 AM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#9
RE: Levers

Here

jesus man...

10-18-2014, 02:06 PM
Find
Straxedix Offline
Senior Member

Posts: 426
Threads: 52
Joined: Mar 2014
Reputation: 5
#10
RE: Levers

(10-18-2014, 02:06 PM)7heDubz Wrote: Here

jesus man...

This means nothing.
I already searched there.

10-19-2014, 07:16 AM
Find




Users browsing this thread: 1 Guest(s)