davidoss 552 Posted January 8, 2018 Hi. I am trying to create a code where server pickup first player which is starting the mission and let him choose the position where the base will be spawned. It should be a group leader and only one player selected. There are 3x20 playable units ,20 for each side + 2 headlescclients. I have this: init.sqf private _players = []; {_players pushBackUnique _x } forEach (((allPlayers + switchableUnits)) select {!didJIPOwner _x}); private _starter = (_players select {_x == (leader (group _x))}) select 0; null = [] remoteExecCall ["MWF_fnc_getBasePos", _starter, false]; waitUntil {sleep 1; !isNil "F_BASE_POS" && {!(F_BASE_POS isEqualTo [])}}; {_x setPos F_BASE_POS} forEach (_players select {(side _x) isEqualTo (side _starter)}); MWF_fnc_getBasePos Spoiler /* //MWF_fnc_getBasePos Author: DaVidoSS Description: Display map for player and collect position after single click Returns: VOID */ F_BASE_POS = []; [] spawn { private _fnc_getmapposition = { private _dxd = [] spawn { sleep 0.2; "Select position" hintC [ "Single click on map to select your desired base position" ]; hintC_arr_EH = findDisplay 72 displayAddEventHandler ["unload", { 0 = _this spawn { _this select 0 displayRemoveEventHandler ["unload", hintC_arr_EH]; hintSilent ""; hintC_arr_EH = nil; }; }]; }; waitUntil{scriptDone _dxd && {isNil "hintC_arr_EH"}}; openMap [true, false]; onMapSingleClick "F_BASE_POS = +_pos; true"; waitUntil {sleep 1;!visibleMap || {!(F_BASE_POS isEqualTo [])}}; onMapSingleClick ""; if (visibleMap) then { openMap [false, false]; }; }; waitUntil {sleep 0.2; (speed player) > 0}; while {(F_BASE_POS isEqualTo [])} do { private _poshandle = [] spawn _fnc_getmapposition; waitUntil {sleep .2; scriptDone _poshandle}; }; publicVariableServer "F_BASE_POS"; }; Unfortunately this works only if hosted or SP. On dedicated its go to somewhere and no one player gets function execute without any error After some tests i realise that this code runs too early on dedicated where are no players in game. I edit this to: waitUntil {sleep 1; (count ([] call BIS_fnc_listPlayers)) > 0}; private _allplayers = [] call BIS_fnc_listPlayers; waitUntil {sleep 1;({getPlayerUID _x != ""} count _allplayers) > 0}; private _players = _allplayers select {(side _x) isEqualTo GVAR_FSIDE}; private _starter = (_players select {_x == (leader (group _x))}) select 0; null = [] remoteExecCall ["MWF_fnc_getBasePos", _starter, false]; waitUntil {sleep 1; !isNil "F_BASE_POS" && {!(F_BASE_POS isEqualTo [])}}; {_x setPos F_BASE_POS} forEach (_players select {(side _x) isEqualTo (side _starter)}); [[format ["selected %1 from side %2",STR _starter, STR (side _starter)], "PLAIN", 1]] remoteExec ["titleText"]; It works but this is very nasty, kind of workaround. Please help, how to correct write such thing. Share this post Link to post Share on other sites