UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Button script problem

broken avatar :(
Created 10 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
2,944 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I have trouble with this script. I am trying to make so you will have to press 4 buttons and then thread a function.
But ingame it threads the function if I only press 2 of the buttons. Why is this happening? In my script it says 4 buttons but ingame it threads after 2 hits.
Code Snippet
Plaintext
main()
{
level.switchs_hit = 0;
button1 = GetEnt("button1","targetname");
button2 = GetEnt("button2","targetname");
button3 = GetEnt("button3","targetname");
button4 = GetEnt("button4","targetname");

button1 thread make_switch();
button2 thread make_switch();
button3 thread make_switch();
button4 thread make_switch();
}
make_switch()
{
level waittill("gen1_done");
level waittill("gen2_done");
level waittill("gen3_done");
level waittill("gen4_done");

self setCursorHint( "HINT_NOICON" );
self sethintstring ("Press &&1 to Link Generator to Mainframe");
self waittill("trigger", player);

PlaySoundAtPosition( "heart_monitor", self.origin );
self delete();

level.switchs_hit = level.switchs_hit + 1;

if(level.switchs_hit == 4)
{
thread open_portal();
players = Get_players();
for( i = 0; i < players.size; i++ )
{
players[i] playsound("radio12");
}
}
}
Thanks in advance.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 March 2014
Last active: 2 years ago
Posts
227
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
My Contact & Social Links
More
Personal Quote
I the Mighty
×
ConvictioNDR's Groups
I'm new to scripting so maybe not the best answer but worth a shot until someone better at scripting can help if it doesn't work.
Try something more like this?
Code Snippet
Plaintext
main()
{
level.switchs_hit = 0;
level make_switch( "button1" );
level make_switch( "button2" );
level make_switch( "button3" );
level make_switch( "button4" );
}
make_switch( trigger_name )
{
level waittill("gen1_done");
level waittill("gen2_done");
level waittill("gen3_done");
level waittill("gen4_done");
button_trig = getent( trigger_name, "targetname" );
button_trig setCursorHint( "HINT_NOICON" );
button_trig sethintstring ("Press &&1 to Link Generator to Mainframe");
button_trig waittill("trigger", player);

PlaySoundAtPosition( "heart_monitor", button_trig.origin );
button_trig delete();

level.switchs_hit = level.switchs_hit + 1;

if(level.switchs_hit == 4)
{
thread open_portal();
players = Get_players();
for( i = 0; i < players.size; i++ )
{
players[i] playsound("radio12");
}
}
}
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I have trouble with this script. I am trying to make so you will have to press 4 buttons and then thread a function.
But ingame it threads the function if I only press 2 of the buttons. Why is this happening? In my script it says 4 buttons but ingame it threads after 2 hits.
Code Snippet
Plaintext
main()
{
level.switchs_hit = 0;
button1 = GetEnt("button1","targetname");
button2 = GetEnt("button2","targetname");
button3 = GetEnt("button3","targetname");
button4 = GetEnt("button4","targetname");

button1 thread make_switch();
button2 thread make_switch();
button3 thread make_switch();
button4 thread make_switch();
}
make_switch()
{
level waittill("gen1_done");
level waittill("gen2_done");
level waittill("gen3_done");
level waittill("gen4_done");

self setCursorHint( "HINT_NOICON" );
self sethintstring ("Press &&1 to Link Generator to Mainframe");
self waittill("trigger", player);

PlaySoundAtPosition( "heart_monitor", self.origin );
self delete();

level.switchs_hit = level.switchs_hit + 1;

if(level.switchs_hit == 4)
{
thread open_portal();
players = Get_players();
for( i = 0; i < players.size; i++ )
{
players[i] playsound("radio12");
}
}
}
Thanks in advance.
Looks fine to me...
Shot in the dark... You don't call main more than once do you?
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I'm new to scripting so maybe not the best answer but worth a shot until someone better at scripting can help if it doesn't work.
Try something more like this?
Code Snippet
Plaintext
main()
{
level.switchs_hit = 0;
level make_switch( "button1" );
level make_switch( "button2" );
level make_switch( "button3" );
level make_switch( "button4" );
}
make_switch( trigger_name )
{
level waittill("gen1_done");
level waittill("gen2_done");
level waittill("gen3_done");
level waittill("gen4_done");
button_trig = getent( trigger_name, "targetname" );
button_trig setCursorHint( "HINT_NOICON" );
button_trig sethintstring ("Press &&1 to Link Generator to Mainframe");
button_trig waittill("trigger", player);

PlaySoundAtPosition( "heart_monitor", button_trig.origin );
button_trig delete();

level.switchs_hit = level.switchs_hit + 1;

if(level.switchs_hit == 4)
{
thread open_portal();
players = Get_players();
for( i = 0; i < players.size; i++ )
{
players[i] playsound("radio12");
}
}
}
That wouldn't matter, I call the function as "self". And in that case self is always the entity I called it from in "main". But thanks anyway :D.
Looks fine to me...
Shot in the dark... You don't call main more than once do you?
I call main only once. :/
Last Edit: May 17, 2014, 08:46:34 pm by Ege115
Marked as best answer by Ege115 10 years ago
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 5 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
Signature
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
Quick made script. See how this works then maybe I can modify based on the results.
Code Snippet
Plaintext
main()
{
level.SwitchHit = 0;
for( i = 1; i < 5; i++ )
{
Button[i] = GetEnt( "button" + i, "targetname" );
Button[i] thread SwitchX();
}
level thread WatchHits();//Maybe just thread
}

SwitchX()
{
for( i = 1; i < 5; i++ )
level waittill( "gen" + i + "_done" );
self SetCursorHint( "HINT_NOICON" );
self SetHintString( "Press &&1 to link Generator to Mainframe" );
self waittill( "trigger", Player );
PlaySoundAtPosition( "heart_monitor", self.origin );
self delete();
level.SwitchHit += 1;
}

WatchHits()
{
while( 1 )
{
if( level.SwitchHit == 4 )
{
thread open_portal();
Player = GetPlayers();
for( i = 0; i < Player.size; i++ )
Player[i] playsound( "radio12" );
break;
}
wait .05;
}
}
Last Edit: May 17, 2014, 09:35:12 pm by PROxFTW
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 March 2014
Last active: 2 years ago
Posts
227
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
My Contact & Social Links
More
Personal Quote
I the Mighty
×
ConvictioNDR's Groups
Couldn't hurt to try though yeah?
I use a similar script in my map. I noticed it was adding a number already cuz I accidentally had two trigs with the same targetname. So I'd say check the target names make sure none are accidentally the same or with typo.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
main only once. :/

Sorry, just thought it might be 4 cause it ups the level variable twice, maybe. Did you check the level.switchs_hit with an iprintln after the waittill trigger? If counting by twos, then something is doubling. You could just make it 8 if you can't figure it out. If it counts by 1s and is working on 2, then sorry for wasting your time, cause I'm out of ideas.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Couldn't hurt to try though yeah?
I use a similar script in my map. I noticed it was adding a number already cuz I accidentally had two trigs with the same targetname. So I'd say check the target names make sure none are accidentally the same or with typo.
You solution would work as well, this script is just how I thought. :)
Sorry, just thought it might be 4 cause it ups the level variable twice, maybe. Did you check the level.switchs_hit with an iprintln after the waittill trigger? If counting by twos, then something is doubling. You could just make it 8 if you can't figure it out. If it counts by 1s and is working on 2, then sorry for wasting your time, cause I'm out of ideas.
You didn't waste my time at all. xD no need to say sorry.

Also, I solved it, it was something I did wrong in the script simply. Thanks for he help anyways, but sorry for wasting YOUR time. xD

Edit: but I give the best answer to prox, because your way is to use arrays which is smarter than the script I had. :D
Last Edit: May 17, 2014, 09:33:23 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 March 2014
Last active: 2 years ago
Posts
227
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
My Contact & Social Links
More
Personal Quote
I the Mighty
×
ConvictioNDR's Groups
Mind saying what the error was? Just in case someone else gets the same issue? They might have made the same mistake.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Oh, yea sure thing.

The script was called twice in mapname.gsc which dublicated the amount of times you pressed the buttons.
Last Edit: May 17, 2014, 09:47:26 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Why is this happening? In my script it says 4 buttons but ingame it threads after 2 hits.
You don't call main more than once do you?
I call main only once. :/
Did you check the level.switchs_hit with an iprintln after the waittill trigger? If counting by twos, then something is doubling.
Also, I solved it, it was something I did wrong in the script simply. Thanks for he help anyways, but sorry for wasting YOUR time. xD
Mind saying what the error was?
The script was called twice in mapname.gsc which dublicated the amount of times you pressed the buttons.
but I give the best answer to prox
LOL
 :derp:

 
Loading ...