Buttons that when you buy one another becomes visible

broken avatar :(
Created 14 days ago
by dabro
0 Members and 1 Guest are viewing this topic.
146 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 March 2013
Last active: 21 hours ago
Posts
26
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
dabro's Groups
dabro's Contact & Social Links
I can't think of exactly how I want to word this, but what I'm trying to do is one of 2 things.

First option: Have a set of buttons the player has to buy. Let's say in this case 3 of them. You buy the first one and it makes an button visible that wasn't visible before. Then you buy that one and it makes another button visible and when you buy that one it opens a door.

Second option: Basicially the same as the first, but this time in a random order.

Does anyone know how to do this, I've been trying to do this the last couple of days, but I don't exactly know the best way you excute this, anyone have any ideas?
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 20 September 2013
Last active: 4 hours ago
Posts
286
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
×
gympie6's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
gympie6's Contact & Social LinksDistenc5Teffrie
I can't think of exactly how I want to word this, but what I'm trying to do is one of 2 things.

First option: Have a set of buttons the player has to buy. Let's say in this case 3 of them. You buy the first one and it makes an button visible that wasn't visible before. Then you buy that one and it makes another button visible and when you buy that one it opens a door.

Second option: Basicially the same as the first, but this time in a random order.

Does anyone know how to do this, I've been trying to do this the last couple of days, but I don't exactly know the best way you excute this, anyone have any ideas?
Yes, first you have to setup buttons with "Trigger_use" on the map and in script you do this:
buttons = getstructarray( "buttons", "targetname" );
buttons = array_randomize( buttons );
Now these buttons are randomized!
Next you want to add a function to the button and it goes like this for example:
buttons[0] waittill( "trigger" , player );
player iprintlnbold("You pressed on this button");

// write here the stuff you want
//
//
//
//
After you pressed the button you want to hide it and unlock a new button.
players = get_players();
for(i = 0; i < players.size; i++)
{
// First trigger
     buttons[0].target SetInvisibleToPlayer ( players[i] );
     buttons[0] disable_trigger();

     // Second trigger
     buttons[1] enable_trigger();
     buttons[1].target SetVisibleToPlayer( players[i] );
}
.target is the object you have set as target in the kvps in radiant like for example the button model.
buttons[1] waittill( "trigger" , player );
player iprintlnbold("You pressed the second button");
and so on
Last Edit: May 09, 2019, 07:45:21 pm by gympie6
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 March 2013
Last active: 21 hours ago
Posts
26
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
dabro's Groups
dabro's Contact & Social Links
Yes, first you have to setup buttons with "Trigger_use" on the map and in script you do this:
Now these buttons are randomized!
Next you want to add a function to the button and it goes like this for example:
After you pressed the button you want to hide it and unlock a new button.
.target is the object you have set as target in the kvps in radiant like for example the button model.
and so on
 Thank you for the reply, sorry it took me so long to respond, I was dealing with irl stuff and haven't had time to work on my map. I'm not very knowledgeable when it comes to coding, I have taken a c++ class and a visual basic class, and knew enough to make a B both times, but I don't fully understand alot of the concepts.

Looking at the stuff you can provided, I can tell I need to have the Tigger_use targetname set to buttons, which Im assuming all the models can be any name I want, in my case; "button1", "button2", and "button3".

I can see a couple of sections were you notifiy the play that they pressed the button and then making a new button visible.

I pretty much have a good concept on what you did, but I just have a couple of questions.

The first one is about the section where you said to put the stuff I want, what exactly does that entail. Besides it just being random and making another button visible (which is in the code) and then having it cost an amount to use the trigger, couldn't I just apply that to the trigger use?

Secondly, where do I put this script, would it go in my "mapname.gsc" file or do I have to make a new one, if I am required to make a new one, how do I go about doing that, I tried to make one with notepad++, but couldn't find a way to save it as a .gsc file (I'm assuming, I need an extension?).
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 20 September 2013
Last active: 4 hours ago
Posts
286
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
I love skulls
×
gympie6's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
gympie6's Contact & Social LinksDistenc5Teffrie
Thank you for the reply, sorry it took me so long to respond, I was dealing with irl stuff and haven't had time to work on my map. I'm not very knowledgeable when it comes to coding, I have taken a c++ class and a visual basic class, and knew enough to make a B both times, but I don't fully understand alot of the concepts.

Looking at the stuff you can provided, I can tell I need to have the Tigger_use targetname set to buttons, which Im assuming all the models can be any name I want, in my case; "button1", "button2", and "button3".

I can see a couple of sections were you notifiy the play that they pressed the button and then making a new button visible.

I pretty much have a good concept on what you did, but I just have a couple of questions.

The first one is about the section where you said to put the stuff I want, what exactly does that entail. Besides it just being random and making another button visible (which is in the code) and then having it cost an amount to use the trigger, couldn't I just apply that to the trigger use?

Secondly, where do I put this script, would it go in my "mapname.gsc" file or do I have to make a new one, if I am required to make a new one, how do I go about doing that, I tried to make one with notepad++, but couldn't find a way to save it as a .gsc file (I'm assuming, I need an extension?).
This is an example of what you can do:

example()
{
players = get_players();

buttons = getstructarray( "buttons", "targetname" );
buttons = array_randomize( buttons );

while(1)
{
// buttons[0] setHintString("Give this trigger a name");
buttons[0] waittill( "trigger" , player );
player iprintlnbold("You pressed on this button");

// The cost of the trigger
if(player.score >= (150))
{
// Remove 150 points from the player
player maps\_zombiemode_score::minus_to_player_score(150);

for(i = 0; i < players.size; i++)
{
// First trigger
buttons[0].target SetInvisibleToPlayer ( players[i] );
buttons[0] disable_trigger();

// Second trigger
buttons[1] enable_trigger();
buttons[1].target SetVisibleToPlayer( players[i] );
}

break;
}
}

while(1)
{
// buttons[1] setHintString("Give this trigger a name");
buttons[1] waittill( "trigger" , player );
player iprintlnbold("You pressed the second button");

if(player.score >= (300))
{
// Remove 300 points from the player
player maps\_zombiemode_score::minus_to_player_score(300);

// Do what you like
break;
}
}

// and so on...
}
and you can place it here in YourMapName.gsc
    /*--------------------
ZOMBIE MODE
----------------------*/
[[level.DLC3.weapons]]();
[[level.DLC3.powerUps]]();
maps\_dig_site::PreCache_dig_site();
maps\_soul_chest::PreCache_soul_chest();
thread maps\dw_fx::init();

maps\_zombiemode::main();

--> Your Method Goes Here <--

thread dual_wield();
thread maps\_soul_chest::main();
thread maps\_dig_site::main();
// level thread spawndogs();
1. Yes maybe you can get the cost of the trigger in radiant but I think it's best to do it in script.
2. It's best to copy a gsc file, clear it and then use it for your own stuff.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 March 2013
Last active: 21 hours ago
Posts
26
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
dabro's Groups
dabro's Contact & Social Links
This is an example of what you can do:

and you can place it here in YourMapName.gsc
1. Yes maybe you can get the cost of the trigger in radiant but I think it's best to do it in script.
2. It's best to copy a gsc file, clear it and then use it for your own stuff.
 I appericate the reply, I will work with this and see if I can get it to work, thank you so much for the help!

 

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 Twitch
Loading ...