Chris_37 0 Posted February 27, 2018 Hello wondering if anyone can help me? i am trying to come up a way of counting all the players with a variable and if their is 5 players already with the variable the player will be prevented from joining? Share this post Link to post Share on other sites
KC Grimes 79 Posted February 27, 2018 You could setVariable forEach allPlayers, and cycle through getVariable forEach allPlayers each time your variable changes somewhere and do a count for when the variable is equal to whatever. A more efficient approach, depending on what you are accomplishing, could be to keep a script running on the server that manages a global array that adds/removes players from it as a means of "assigning variables". You may have to make it a publicVariable. Again, it just depends on what you are needing the data for. Share this post Link to post Share on other sites
Chris_37 0 Posted February 27, 2018 1 hour ago, KC Grimes said: You could setVariable forEach allPlayers, and cycle through getVariable forEach allPlayers each time your variable changes somewhere and do a count for when the variable is equal to whatever. A more efficient approach, depending on what you are accomplishing, could be to keep a script running on the server that manages a global array that adds/removes players from it as a means of "assigning variables". You may have to make it a publicVariable. Again, it just depends on what you are needing the data for. How would i go about doing a gobal array that manages players depending of which variable they had? like in terms of adding/removing? Share this post Link to post Share on other sites
KC Grimes 79 Posted February 27, 2018 Again it just depends on the circumstances surrounding the variable. Is the variable set locally based on a local action, or is it set on the server based on the server's detection of a condition? Does anybody but the server need to set or get the variables? To avoid public variables it would be ideal to have all of the tracking done on the server, but I get a feeling the clients will need to have access to the variable. Just do setVariable, have the public broadcast param set to true, loop through allPlayers counting the number, and do/don't do what you are wanting given that condition. Share this post Link to post Share on other sites
HazJ 1289 Posted February 27, 2018 _playerCount = {alive _x} count allPlayers - entities "HeadlessClient_F"; You can also use this command: https://community.bistudio.com/wiki/playersNumber It all depends on what you are trying to exactly. 1 Share this post Link to post Share on other sites