I have a 6 player map, with two teams (3 player per team)
On each team there can be 1 attacker and 2 defenders. So I am trying to make a dialog that shows up for each team, and the players choose who they want to be.
If no one chooses attacker, then the game chooses randomly (I know how to do this)
if multiple people choose attacker, then the game picks one from those who chose attacker (I am not sure how to do this)
I would appreciate any help on that last one. Thanks
Loop through all the players and check for each of them if they chose attacker. If yes, add them to another (local) player group. Than choose a random player from this group (Player A from local player group) where A is a random integer between 1 and number of players in local player group. This also covers the first case.
I was able to add the player to a player group once they picked an attacker, but how do I "choose a random player from this group (Player A from local player group) where A is a random integer between 1 and number of players in local player group."
So the players in the player group are listed like so: 4, 5, 8, 9. The order is based on the order that they were added to the player group, so it could also be like 5, 4, 9, 8, too (note, these are just arbitrary player numbers).
Anyway, these four random player numbers in the player group, they have positions in the player group. The first player in the player group that contains 4, 5, 8, and 9 would be 4. The second player; 5, third player; 8, and fourth; 9.
Using the functions:
Number of Players in Player Group
Random Integer
Player from Player Group
You can get a random player from a player group. You pick a random integer between 1 and the amount of players in the player group, and you use that integer in the function Player from Player Group.
You now have a function that you can call whenever you need a random player from a player group. You said you already managed to get the player group of players who chose attacker, now you just have to use this function to get a random player from it.
Looks alright. The "or" in your first trigger doesn't serve any purpose. And you need to think about things like what happens if nobody has voted by 15 sec (There won't be an attacker). Might be a problem, might not be, depending on what you want to do.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I have a 6 player map, with two teams (3 player per team) On each team there can be 1 attacker and 2 defenders. So I am trying to make a dialog that shows up for each team, and the players choose who they want to be.
I would appreciate any help on that last one. Thanks
Loop through all the players and check for each of them if they chose attacker. If yes, add them to another (local) player group. Than choose a random player from this group (Player A from local player group) where A is a random integer between 1 and number of players in local player group. This also covers the first case.
@Elmaex: Go
I was able to add the player to a player group once they picked an attacker, but how do I "choose a random player from this group (Player A from local player group) where A is a random integer between 1 and number of players in local player group."
Thanks
@TerranMaster23: Go
So the players in the player group are listed like so: 4, 5, 8, 9. The order is based on the order that they were added to the player group, so it could also be like 5, 4, 9, 8, too (note, these are just arbitrary player numbers).
Anyway, these four random player numbers in the player group, they have positions in the player group. The first player in the player group that contains 4, 5, 8, and 9 would be 4. The second player; 5, third player; 8, and fourth; 9.
Using the functions:
You can get a random player from a player group. You pick a random integer between 1 and the amount of players in the player group, and you use that integer in the function Player from Player Group.
@Charysmatic: Go
I might be really tired right now... however, I cant seem to find these functions -_- sorry
@TerranMaster23: Go
Try to recreate this function
@Elmaex: Go
Thanks, I was able to create that function, then what do I exactly do? I appreciate the help :)
You now have a function that you can call whenever you need a random player from a player group. You said you already managed to get the player group of players who chose attacker, now you just have to use this function to get a random player from it.
@Elmaex: Go
Thanks, it works now. Just to make sure everything is alright, I have my triggers below:
Add player to player group once they choose "attacker":
http://gyazo.com/b8f6c419aca5466a3bcba460338e8734
This is the function:
http://gyazo.com/b97b60405e7c5671c73f612c48214d96
(which is the same as the one above)
I did similar triggers for the rest of the players
And this happens after the "choosing role timer" ends:
http://gyazo.com/e7d4ede8f3cc4fa90a6a2e49d16077d2
I really appreciate all the help. :D
Looks alright. The "or" in your first trigger doesn't serve any purpose. And you need to think about things like what happens if nobody has voted by 15 sec (There won't be an attacker). Might be a problem, might not be, depending on what you want to do.