Jump to content
Sign in to follow this  
R3vo

Issue with 3DEN EH "OnMissionNew"

Recommended Posts

The following function is supposed to compare the game version with the version of my mod and in case game version is not equal to mod version and the user is on dev branch, show a message. The function is called on preStart.

 

1. Even though the function has the attribute preStart, it's still called when I open Eden or return back to the main menu. I thought it would only be called once on game start.

 

2. The onMissionNew EH does not seem to trigger when a new mission is opened in Eden Eden is opened. The debug message inside the EH does not appear.

/*
    Author: Revo

    Description:
    Gets current 3den Enhanced version and compares it with game version.
    In case game version is not equal to required version and dev branch is enabled a warning will be shown.

    Parameter(s):
    -
    Returns:
    true
*/
systemChat "Function called";//Debug
add3DENEventHandler ["OnMissionNew",
{
   systemChat "EH executed";//Debug
   private ["_requiredVersion", "_currentVersion", "_branch"];

   _requiredVersion = getNumber (configfile >> "CfgPatches" >> "3denEnhanced">> "requiredVersion");
   _currentVersion = (productVersion select 2) / 100;
   _branch = (productVersion select 4);

   if (_currentVersion != _requiredVersion && _branch == "Development") then//Checking if it's dev branch is probably enough
   {
      ["LogClassName"] call BIS_fnc_3DENNotification;//Placeholder
   };
}];
true;

I'd be glad for any help regarding the aforementioned questions.

Share this post


Link to post
Share on other sites

I don't think onMissionNew is supposed to trigger on loading a mission, that why there's is onMissionLoad.

 

Also, why do this with some pre-start function as you could add the whole EH stuff into your mod config instead? :shrug:

Edited by h -

Share this post


Link to post
Share on other sites

Also, why do this with some pre-start function as you could add the whole EH stuff into your mod config instead? :shrug:

 

Teach me, please! :D

 

I don't think onMissionNew is supposed to trigger on loading a mission, that why there's is onMissionLoad.

 

 

onMissionNew eh is supposed to executed when the editor is opened. Guess my phrasing was incorrect in my inital post.

Share this post


Link to post
Share on other sites

 

onMissionNew eh is supposed to executed when the editor is opened. Guess my phrasing was incorrect in my inital post.

It did (and does) for me, didn't fully test it though because was currently running no mods so only tested the systemChat, but EHs can fail silently if there's some small error somewhere, have had to tear out some gray hair because of that..

 

 

Teach me, please!

lol, well, it's not that hard, I mean there's example about it in the Biki I think..

 

Anyway, Cfg3DEN -> class EventHandlers -> class You -> onMissionNew = "<code>";

Something like (you don't necessarily need to do the code in there like in this sample, just call your function from there or something):

class Cfg3DEN
{
	class EventHandlers
	{
		class MYTAG
		{
			onMissionLoad = "\
                            if (productversions don't match) then {\
                                 notify error;\
                            } else {\
                                 all is well;\
                            };\
                        ";
			onMissionNew = "\
                            if (productversions don't match) then {\
                                notify error;\
                            } else {\
                                all is well;\
                            };\
                        ";
		};
	};
};
Edited by h -

Share this post


Link to post
Share on other sites

That way I can define my own EHs, I knew about that, but they are not automatically executed, are they ?

Share this post


Link to post
Share on other sites

Yes they are, that's what eventhandlers do I guess.

If your mod is loaded and 3den started config defined onMissionNew should 'fire'..

 

 

Misspoke earlier about your problem as I was referring to my own experience with config defined EHs, that sample of your worked fine when 3den was running obviously but not when started as I didn't test the pre-start part of it.. Sorry, been doing way way too much modding today so brain is farting.. :P

  • Like 1

Share this post


Link to post
Share on other sites

Yes they are, that's what eventhandlers do I guess.

 

 

I can't actually believe how stupid I was. I thought one could define own EHs which could then be added with add3DENEventhandler, at the same time I was wondering how one could define such an event which would trigger the new EH.

 

You explaination of course makes way more sense.

 

 

 

Edit: Works flawlessly now, thanks for you help, much apprechiated

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
Sign in to follow this  

×