Page MenuHomeFeedback Tracker

allPlayers delayed on mission start, on dedicated server
Feedback, NormalPublic

Description

allPlayers can be delayed on a dedicated server, causing issues for mods and missions that rely on it and expected it to be reliable.

Details

Severity
Major
Resolution
Open
Reproducibility
Random
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce
  1. Start mission on a dedicated server.
  2. Observe allPlayers vs call BIS_fnc_listPlayers after briefing ends.
  3. Possibly repeat steps a few times.
Additional Information

Wiki only states that

In a player-hosted game, the complete array of allPlayers may get delayed on mission start. Use BIS_fnc_listPlayers if you need it earlier.

Which, would imply that it should be reliable on a dedicated server, however I recently ran into an issue on a dedicated server where allPlayers wasn't returning all of the players for a bit after mission start.

Mission used to confirm issue, both with and without mods:

Test mission usage:

  1. Confirm "postInit: [] != [p0]" is shown in briefing.
  2. Wait for "postInit: [p0] == [p0] after X seconds" after mission start.
  3. If seconds is < 1, restart mission and try again.

Screenshot of result on a modded dedicated server.

Screenshot of result on a locally hosted non-modded dedicated server.

Event Timeline

Coryf88 created this task.Aug 6 2022, 1:29 AM

Ok, updated biki. Have you tried allUsers / getUserInfo instead?

Thanks for updating the wiki to reflect these findings, however I reported it to the issue tracker in hope that it could be fixed.

I was not able to replicate this issue with getUserInfo, it consistently returns the player object in a spawn on postInit.

BIS_fnc_KK added a comment.EditedAug 6 2022, 6:12 PM

could you provide 2 scripts side by side one using allplayers and one using getuserinfo doing the same thing but allplayers failing?

I apologize for the late reply, I must have overlooked the notification.

Sure, though I'm not quite sure what you have in mind.

So, below is the postInit code that was used for the getUserInfo test, following it is an equivalent for allPlayers, if that's what you want?

allUsers/getUserInfo

if (!isServer) exitWith {};

private _allPlayers = allUsers apply { getUserInfo _x select 10 };
private _listPlayers = call BIS_fnc_listPlayers;
if (_allPlayers isNotEqualTo _listPlayers) then {
	format ["postInit: %1 != %2", _allPlayers, _listPlayers] remoteExec ["systemChat", -2];

	time spawn {
		private _allPlayers = allUsers apply { getUserInfo _x select 10 };
		private _listPlayers = call BIS_fnc_listPlayers;
		while { _allPlayers isNotEqualTo _listPlayers } do {
			sleep 0.01;
			_allPlayers = allUsers apply { getUserInfo _x select 10 };
			_listPlayers = call BIS_fnc_listPlayers;
		};
		format ["postInit: %1 == %2 after %3 seconds", _allPlayers, _listPlayers, time - _this] remoteExec ["systemChat", -2];
	};
} else {
	format ["postInit: %1 == %2", _allPlayers, _listPlayers] remoteExec ["systemChat", -2];
};

allPlayers

if (!isServer) exitWith {};

private _allPlayers = allPlayers - entities "HeadlessClient_F";
private _listPlayers = call BIS_fnc_listPlayers;
if (_allPlayers isNotEqualTo _listPlayers) then {
	format ["postInit: %1 != %2", _allPlayers, _listPlayers] remoteExec ["systemChat", -2];

	time spawn {
		private _allPlayers = allPlayers - entities "HeadlessClient_F";
		private _listPlayers = call BIS_fnc_listPlayers;
		while { _allPlayers isNotEqualTo _listPlayers } do {
			sleep 0.01;
			_allPlayers = allPlayers - entities "HeadlessClient_F";
			_listPlayers = call BIS_fnc_listPlayers;
		};
		format ["postInit: %1 == %2 after %3 seconds", _allPlayers, _listPlayers, time - _this] remoteExec ["systemChat", -2];
	};
} else {
	format ["postInit: %1 == %2", _allPlayers, _listPlayers] remoteExec ["systemChat", -2];
};
BIS_fnc_KK set Ref Ticket to AIII-56251.Feb 13 2024, 3:57 PM

Revision: 151401

should be much faster

BIS_fnc_KK removed BIS_fnc_KK as the assignee of this task.Feb 13 2024, 4:01 PM
BIS_fnc_KK changed the task status from New to Feedback.