celludriel 79 Posted August 30, 2015 hey, I'm using this funciton on a onPlayerConnected listener setWarfundOnPlayerByPlayerUID = { diag_log format ["Calling setWarfundOnPlayerByPlayerUID, with %1", _this]; _playerUID = _this select 0; _amount = _this select 1; if(_playerUID != "") then { diag_log format ["allPlayers: %1", allPlayers]; { if(_playerUID == getPlayerUID _x) exitWith { diag_log format ["Setting warfund on %1", _x]; _x setVariable ["warfund", _amount, true]; }; } forEach allPlayers; }; }; When I try this on a local server instance this works perfectly, however on a dedicated server allPlayers seems to be empty. Here is an extract of the log 17:47:46 "Calling setWarfundOnPlayerByPlayerUID, with ["76561197962746017",100]" 17:47:46 "allPlayers: []" Is there something else I should use to fetch all the players on a dedicated server ? This code should ONLY run on the server btw if that is to any importance to the answer. I'm puzzled by this one ... Share this post Link to post Share on other sites
R3vo 2652 Posted August 30, 2015 Last time I used allPlayers it worked fine. You don't happen do be on dev branch, do you? Share this post Link to post Share on other sites
celludriel 79 Posted August 30, 2015 Nope I'm on the latest steam release, Maybe it's because I use it on the onPlayerConnected event and players are just not there yet at this point. Otherwise I have no idea Share this post Link to post Share on other sites
celludriel 79 Posted August 30, 2015 So I tried https://community.bistudio.com/wiki/BIS_fnc_addStackedEventHandler I've been using the regular onPlayerConnected instead of this one, maybe this would fix it, however the result was the same. Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted August 30, 2015 Nope I'm on the latest steam release, Maybe it's because I use it on the onPlayerConnected event and players are just not there yet at this point. Otherwise I have no idea OnPlayerConnected fires before there is a player object. initPlayerServer.sqf executes after there is a player object. 1 Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted August 30, 2015 So I tried https://community.bistudio.com/wiki/BIS_fnc_addStackedEventHandler I've been using the regular onPlayerConnected instead of this one, maybe this would fix it, however the result was the same. BIS_fnc_addStackedEventHandler just combines all the code from stacked events into one scope. ["EH1","onPlayerConnected",{/* code 1 */},[]] call BIS_fnc_addStackedEventHandler ["EH2","onPlayerConnected",{/* code 2 */},[]] call BIS_fnc_addStackedEventHandler is the same as: onPlayerConnected { /* code 1 */ /* code 2 */ }; 1 Share this post Link to post Share on other sites
celludriel 79 Posted August 31, 2015 OnPlayerConnected fires before there is a player object. initPlayerServer.sqf executes after there is a player object. Thanks this explains the behavior, It's not what I liked to hear though, since this means I have to add custom code in initPlayerServer.sqf. Now I hoped to have a way to add it in a file in the folder of my "mechanic", keeping it detached from the main mission files. Now I'll have to mix variables of my mechanic inside the root files :(. Oh well I'll live with it. Share this post Link to post Share on other sites
celludriel 79 Posted September 2, 2015 Bah didn't work :( I need to find a better way using allPlayers in initPlayerServer.sqf still returns an empty array. Maybe the player is only known to that function after initPlayerServer.sqf has run and not during :( Share this post Link to post Share on other sites
killzone_kid 1326 Posted September 2, 2015 Bah didn't work :( I need to find a better way using allPlayers in initPlayerServer.sqf still returns an empty array. Maybe the player is only known to that function after initPlayerServer.sqf has run and not during :( Not only allPlayers works perfectly in initPlayerServer.sqf and returns all players (just checked), _this param passed to initPlayerServer.sqf contains player object, so there is no need for allPlayers all together. 1 Share this post Link to post Share on other sites
celludriel 79 Posted September 3, 2015 Not only allPlayers works perfectly in initPlayerServer.sqf and returns all players (just checked), _this param passed to initPlayerServer.sqf contains player object, so there is no need for allPlayers all together. Then we have both different behaviors going on ??? Cause I can assure you I'm printing out allPlayers during initPlayerServer.sqf runs and it is empty. But I'll check again when I get home. However you are right ... I actually don't need allPlayers anymore if I rewrite a bit of code and pass the player object to my method instead of just the UID Share this post Link to post Share on other sites