User01
Member
Posts: 97
Threads: 30
Joined: Feb 2013
Reputation:
0
|
On, Off Button
I need a little help. When I push the button, the lamp gets on. But when I push it again it will just stay on, insteadt off. What do I need to add/change?
void OnStart() { SetLocalVarInt("Var1", 0); SetEntityPlayerInteractCallback("button1", "func1", false); }
void func1(string &in asEntity) { AddLocalVarInt("Var1", 1); SetLampLit("bonfire1", true, true); PlaySoundAtEntity("", "spot.snt", "bonfire1", 0.5f, false); }
(This post was last modified: 03-23-2013, 02:07 AM by plutomaniac.)
|
|
03-02-2013, 03:57 AM |
|
No Author
Posting Freak
Posts: 962
Threads: 10
Joined: Jun 2012
Reputation:
13
|
RE: On, Off Button
(03-02-2013, 03:57 AM)User01 Wrote: I need a little help. When I push the button, the lamp gets on. But when I push it again it will just stay on, insteadt off. What do I need to add/change?
void OnStart() { SetLocalVarInt("Var1", 0); SetEntityPlayerInteractCallback("button1", "func1", false); }
void func1(string &in asEntity) { AddLocalVarInt("Var1", 1); SetLampLit("bonfire1", true, true); PlaySoundAtEntity("", "spot.snt", "bonfire1", 0.5f, false); }
Use this :
void OnStart() { SetEntityPlayerInteractCallback("button1", "func1", false); }
void func1(string &in asEntity) { SetLampLit("bonfire1", true, true); PlaySoundAtEntity("", "spot.snt", "bonfire1", 0.5f, false); SetEntityPlayerInteractCallback("button1", "func2", false); }
void func2(string &in asEntity) { SetLampLit("bonfire1", false, true); PlaySoundAtEntity("", "///////YOUR SOUND////////", "bonfire1", 0.5f, false); SetEntityPlayerInteractCallback("button1", "func1", false); }
I changed the script to make it loop(When you press the button, it goes off. When you press it again, it goes on. And so on).
(This post was last modified: 03-02-2013, 04:44 AM by No Author.)
|
|
03-02-2013, 04:43 AM |
|
User01
Member
Posts: 97
Threads: 30
Joined: Feb 2013
Reputation:
0
|
RE: On, Off Button
Thank you
|
|
03-02-2013, 04:50 AM |
|
No Author
Posting Freak
Posts: 962
Threads: 10
Joined: Jun 2012
Reputation:
13
|
RE: On, Off Button
Your are very welcome
|
|
03-02-2013, 04:54 AM |
|
|