I have a role selection, and I want a role to only be available when 50% of the total players click on a different button. I got it to unlock, but I can't get it to relock when players unclick the button. I will post my triggers. It isn't getting to my Commander3 or Commander4 debugs. Instead of relocking it, it seems that it unlocks it everytime.
Havnt really looked at your code but for this problem you need to know, when a player clicks a button have they already clicked it and what button is the current button that they just clicked. What you could do is when a player clicks a button have an array playerButtonClicked[player - 1] = 1 so if player 1 clicks button1 then index 0 of playerButtonClicked[] will be set to 1. If button 2 is clicked its set to 2 etc.
For this particular button lets say its button 3, every time a button is clicked after it sets the value i just went over go through the playerbuttonarray and increment a counter each time you come across a value that is not button3, if the counter is atlesaet 50% of the value of the total number of hte players in the game then enable the button otherwise disable. With this method your always keeping track of which player has pressed which button and on each button click your checking that 50% condition to enable or disable the button3 as needed.
Of course if by unclick you mean you can unclick a button so your not selecting any button, then when they click for example button2, check that players current button clicked value in the array and if it matches set the value to 0 for unclicked or seomthing otherwise set it to 2. And then you would only increment the counter i talked about in the above paragraph if the number wasn't a 3 or a 0.
I'll try to explain a little more. Right now, I have two mode buttons and when a player clicks on "War Mode", it adds one to a variable and changes the tooltip to show how many players have clicked it. Then it should check whether 50% of the people have clicked it or not (the first picture), Then, if someone clicks the "Normal Mode" causing there not to be 50% of people clicked, then it should force anyone who may have clicked the role that unlocked because of the mode to change, and then lock that role. However, that is where the problem seems to be. It seems that it knows that someone clicked "Normal" and it does take away the variable value as I found out through debugs. However, it will not lock the role again, and it won't switch the player to a different role. For that I told it to pick each integer for each of the roles and then if that role is available, select it, and if it's not, then go on to the next integer. I don't know why this isn't working, but this seems to be the problem.
Also for some reason, after the commander1 debug in the first picture, it will not disable it like I am telling it to. It gives be the debug, but it doesn't disable it.
Edit: I figured out that the math was wrong as I had the variables set to integers so when there is only 1 player in the game it thought that it always had 50% of the people clicked. So now it locks, but it still won't force you out of the role.
Edit 2: It seems that my condition was wrong. It works now! Thanks for the help.
I have a role selection, and I want a role to only be available when 50% of the total players click on a different button. I got it to unlock, but I can't get it to relock when players unclick the button. I will post my triggers. It isn't getting to my Commander3 or Commander4 debugs. Instead of relocking it, it seems that it unlocks it everytime.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
Havnt really looked at your code but for this problem you need to know, when a player clicks a button have they already clicked it and what button is the current button that they just clicked. What you could do is when a player clicks a button have an array playerButtonClicked[player - 1] = 1 so if player 1 clicks button1 then index 0 of playerButtonClicked[] will be set to 1. If button 2 is clicked its set to 2 etc.
For this particular button lets say its button 3, every time a button is clicked after it sets the value i just went over go through the playerbuttonarray and increment a counter each time you come across a value that is not button3, if the counter is atlesaet 50% of the value of the total number of hte players in the game then enable the button otherwise disable. With this method your always keeping track of which player has pressed which button and on each button click your checking that 50% condition to enable or disable the button3 as needed.
Of course if by unclick you mean you can unclick a button so your not selecting any button, then when they click for example button2, check that players current button clicked value in the array and if it matches set the value to 0 for unclicked or seomthing otherwise set it to 2. And then you would only increment the counter i talked about in the above paragraph if the number wasn't a 3 or a 0.
@lemmy734: Go
I'll try to explain a little more. Right now, I have two mode buttons and when a player clicks on "War Mode", it adds one to a variable and changes the tooltip to show how many players have clicked it. Then it should check whether 50% of the people have clicked it or not (the first picture), Then, if someone clicks the "Normal Mode" causing there not to be 50% of people clicked, then it should force anyone who may have clicked the role that unlocked because of the mode to change, and then lock that role. However, that is where the problem seems to be. It seems that it knows that someone clicked "Normal" and it does take away the variable value as I found out through debugs. However, it will not lock the role again, and it won't switch the player to a different role. For that I told it to pick each integer for each of the roles and then if that role is available, select it, and if it's not, then go on to the next integer. I don't know why this isn't working, but this seems to be the problem.
Also for some reason, after the commander1 debug in the first picture, it will not disable it like I am telling it to. It gives be the debug, but it doesn't disable it.
Edit: I figured out that the math was wrong as I had the variables set to integers so when there is only 1 player in the game it thought that it always had 50% of the people clicked. So now it locks, but it still won't force you out of the role.
Edit 2: It seems that my condition was wrong. It works now! Thanks for the help.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here