Page MenuHomeFeedback Tracker

The player object passed to "initPlayerServer.sqf" is sometimes null
Assigned, WishlistPublic

Description

I've noticed that, on random occasions, the player object in the array that is passed to "initPlayerServer.sqf" is null. I've looked into the game files, and I've traced down the issue.

The problem originates from "initFunctions.sqf" in "functions_f.pbo". At line 593, it does the following:

<pre>if !(isDedicated) then {
[player,_didJIP] execvm "initPlayerLocal.sqf";
[[[player,_didJIP],"initPlayerServer.sqf"],"bis_fnc_execvm",false,false] call bis_fnc_mp;
"initPlayerLocal.sqf" call bis_fnc_logFormat;
"initPlayerServer.sqf" call bis_fnc_logFormat;
};</pre>

However, the problem here is that the script does not wait until the player object is not null. It usually takes a couple seconds early game until it is set by the engine. So, the fix is simply to add a "waitUntil {!isNull player}":

<pre>if !(isDedicated) then {
<b>waitUntil {!isNull player};</b>
[player,_didJIP] execvm "initPlayerLocal.sqf";
[[[player,_didJIP],"initPlayerServer.sqf"],"bis_fnc_execvm",false,false] call bis_fnc_mp;
"initPlayerLocal.sqf" call bis_fnc_logFormat;
"initPlayerServer.sqf" call bis_fnc_logFormat;
};</pre>

Details

Legacy ID
4134633278
Severity
None
Resolution
Open
Reproducibility
Random
Category
Scripting

Event Timeline

AgentRev set Category to Scripting.Apr 12 2015, 4:08 PM
AgentRev set Reproducibility to Random.
AgentRev set Severity to None.
AgentRev set Resolution to Open.
AgentRev set Legacy ID to 4134633278.May 8 2016, 11:55 AM
AgentRev edited a custom field.
loudnl added a subscriber: loudnl.May 8 2016, 11:55 AM
loudnl added a comment.Jun 4 2015, 4:55 PM

Would be nice to get a fix for this!

Still present in v1.46 RC

+1. I guess in the meantime it is wise to do it manually like this at the very beginning of "initPlayerLocal.sqf" :

_didJIP = _this select 1;
_didJIP spawn {
_didJIP = _this;
waitUntil { !isNull player };
[[[player,_didJIP],"initPlayerServer_bisBugfix.sqf"],"bis_fnc_execvm",false,false] call bis_fnc_mp;
};