BEAKSBY 11 Posted September 5, 2014 Hi ALL, How do obtain an array of players currently in-game...not in the lobby and not an empty player spot either? Share this post Link to post Share on other sites
Beerkan 71 Posted September 5, 2014 Hi ALL,How do obtain an array of players currently in-game...not in the lobby and not an empty player spot either? This playableUnits Share this post Link to post Share on other sites
BEAKSBY 11 Posted September 5, 2014 This playableUnits Yes, but I think I may have to filter the array with player, otherwise it will include units also occupied by AI? Share this post Link to post Share on other sites
dreadedentity 278 Posted September 5, 2014 (edited) _west = []; _east = []; _guer = []; _civ = []; { if (isPlayer (playableUnits select (_x - 1))) then { if (side playableUnits select (_x - 1) == west) then { _west set [(count _west), playableUnits select (_x - 1)]; }; if (side playeableUnits select (_x - 1) == east) then { _east set [(count _east), playableUnits select (_x - 1)]; }; // if (side playableUnits select (_x - 1) == guer) then // { // _guer set [(count _guer), playableUnits select (_x - 1)]; // }; if (side playableUnits select (_x - 1) == indep) then { _guer set [(count _guer), playableUnits select (_x - 1)]; }; if (side playableUnits select (_x - 1) == civ) then { _civ set [(count _civ), playableUnits select (_x - 1)]; }; }; } forEach playableUnits; //_allPlayers = _west + _east + _guer + _civ; //Uncomment to return an array with all human players Edited September 5, 2014 by DreadedEntity Share this post Link to post Share on other sites
Beerkan 71 Posted September 5, 2014 For ArmA3 I think it's INDEP rather than GUER. Share this post Link to post Share on other sites
dreadedentity 278 Posted September 5, 2014 For ArmA3 I think it's INDEP rather than GUER. Thanks, edited original comment. Share this post Link to post Share on other sites
Larrow 2821 Posted September 5, 2014 Sorry DE but these lines make no sense if (side playableUnits select (_x - 1) == west) then You are already passing the unit in _x via foreaching playableUnits so there is no need to access playableUnits again, also _x - 1 is thePassedUnit - 1. //east, west, indep, civ _sides = [0,0,0,0]; { if (isPlayer _x) then { _index = (side _x) call BIS_fnc_sideID; _sides set [ _index, ((_sides select _index) +1 )]; }; }forEach playableUnits; or if you dont want to use BIS enumeration then //east, west, indep, civ _sides = [0,0,0,0]; { if (isPlayer _x) then { _index = [east, west, independent, civilian] find (side _x); _sides set [ _index, ((_sides select _index) +1 )]; }; }forEach playableUnits; _allPlayers = 0; { _allPlayers = _allPlayers + _x; }forEach _sides; Share this post Link to post Share on other sites
dreadedentity 278 Posted September 5, 2014 Sorry DE but these lines make no sense if (side playableUnits select (_x - 1) == west) then You are already passing the unit in _x via foreaching playableUnits so there is no need to access playableUnits again, also _x - 1 is thePassedUnit - 1. Ah, you're right. I got a little confused with the syntax, I guess. I'm used to working with throwaway arrays when I use forEach. Something like: { } forEach [1,2,3,4,5]; Thanks for that catch ---------- Post added at 17:25 ---------- Previous post was at 16:44 ---------- Just wondering if this code would work: _west = []; _east = []; _guer = []; _civ = []; { if (isPlayer _x) then { missionNamespace setVariable [format["_%1", side _x], call compile format ["_%1 = _%1 + %2;", side _x, _x]]; }; } forEach playableUnits; I know we shouldn't really use call compile because of it's slow speed, but I was wondering if I can use it nested in setVariable like that. Share this post Link to post Share on other sites