Jump to content
Ibragim A

[Solved] Mission Event Handler "Loaded" works only while the mission is open

Recommended Posts

The issue, as stated in the title, is that the MEH "Loaded" only works if the player saves the game with the SAVE option and then loads it from the same mission dialog, but if he chooses SAVE & EXIT and opens the mission again, this MEH does not work.

 

I read that this event handler should be run in preinit and did everything as it says here.

 

MEH "Loaded" is running from mod config.cpp as preinit function:

 

config.cpp:

class CfgFunctions
	{
		class PC
			{
				class preInitFunctions
					{
						file = "Addon_PC";
						class doPreinit
							{
								preInit = 1;
							};
					};
			};
	};

fn_doPreinit.sqf:

addMissionEventHandler ["Loaded", 
	{
		params ["_saveType"];
		
		systemchat str _saveType;	// Anything...	
	}];

Maybe I did something wrong. Maybe there is another way how to handle the loading of the mission?

Share this post


Link to post
Share on other sites

The issue has been solved. There should be a small delay in the mission load handler:

addMissionEventHandler ["Loaded", 
	{
		params ["_saveType"];
		
		_this spawn 
			{
				waitUntil 
					{
						sleep 0.1;
						
						!isnull (finddisplay 46)
					};
					
				systemchat _this;
			};
	}];

 

  • Like 2

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

×