Jump to content
AgentRev

Mission event handlers "PlayerConnected" and "PlayerDisconnected" do not work

Recommended Posts

As per the title, those event handlers do not seem to work at all. I tried adding them server-side, but the assigned code never gets called.

addMissionEventHandler ["PlayerDisconnected", { diag_log format ["test123 %1", _this] }];

Share this post


Link to post
Share on other sites

IIRC there is currently a bug where you must call the old event command prior to adding the mission event.

 

This is how I run it, no issues.

onPlayerConnected {}; // 1.58 bug, must be called before below mission event will work
onPlayerDisconnected {}; // 1.58 bug, must be called before below mission event will work
{
     addMissionEventHandler _x;
} forEach [
     ['Ended',{/* code */}],
     ['EntityKilled',{/* code */}],
     ['EntityRespawned',{/* code */}],
     ['HandleDisconnect',{/* code */}],
     ['PlayerConnected',{/* code */}],
     ['PlayerDisconnected',{/* code */}]
];
  • Like 2

Share this post


Link to post
Share on other sites

Instead of "onPlayerConnected {}" one should use "BIS_fnc_addStackedEventHandler" with "onPlayerConnected" to initialize (?) the event. That way you at least don't overwrite other events that make use of "BIS_fnc_addStackedEventHandler".

 

Example: https://github.com/CBATeam/CBA_A3/blob/62f7ee38861940146610bd26b09e17515863310e/addons/common/XEH_preInit.sqf#L40-L43

 

Last time I tried, this bug only applied to "onPlayerConnected" and not to the "Disconnected" variant. This should really be fixed.

  • Like 2

Share this post


Link to post
Share on other sites

Last time I tried, this bug only applied to "onPlayerConnected" and not to the "Disconnected" variant.

Just tested, both oPC and oPD need a dummy stacked EH for their homologous mission EH to trigger. Can be setup anywhere before or after addMissionEventHandler.

Share this post


Link to post
Share on other sites

Interesting. For PlayerDisconnected this was supposedly fixed during 1.57 dev. It even appeared in a changelog. Maybe the change didn't make it into stable branch?

 

https://forums.bistudio.com/topic/140837-development-branch-changelog/?p=3002942

 

 

  • Tweaked: The PlayerDisconnected mission Event Handler is now called even when the OnPlayerDisconnected command is not used

Share this post


Link to post
Share on other sites

This bug is known and the programmer is notified, it is a waiting game now ;)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×