Jump to content
Sign in to follow this  
SenkiAlfonz

My mod doesn't survive game load -- NEED HELP!

Recommended Posts

Hi,

I have made a mod.

//it modifies nightvision

//features: noise+blur+circular mask

//planned, if I am able: fade in-out (+sound) on switch, hand anim

My problem:

It is not working on loaded savegames.

I am aware, it is a common problem, but I've noticed TMR and STHUD has got some kind of workaround.

I am totally new to modding, and the code TMR uses was a bit too much for me not to speak about sthud.

TMR: "Uses a watchdog do ensure it is reloaded -- must survive a game load."

I was hoping someone could help me out!

(I have searched the forum but not found anything useful with my knowledge.)

Thanks and here is my code (I combined hafm_nvg, tmr, and my effects)

Config.cpp:

class CfgPatches
{
class NVG
{
	units[] = {};
	weapons[] = {};
	Version = 0.1;
	requiredVersion = 0.1;
	requiredAddons[] = {"A3_Characters_F_BLUFOR","Extended_EventHandlers","cba_main"};
};
};
class cfgWeapons
{
class Default;	// External class reference
class Binocular;	// External class reference

class NVGoggles : Binocular {
	modelOptics = "NVG\data\nvg.p3d";
};
class NVGoggles_INDEP : Binocular {
	modelOptics = "NVG\data\nvg.p3d";
};
class NVGoggles_OPFOR : Binocular {
	modelOptics = "NVG\data\nvg.p3d";
};
};
class Extended_PostInit_EventHandlers {
class NVG {
	clientInit = "call compile preProcessFileLineNumbers '\NVG\init.sqf'";
};
};

init.sqf

#define PATH "\NVG\"
#define MAIN_DISPLAY (findDisplay 46)

if ( !isDedicated ) then
{
NVG_nvOn 				= false;

_fCheckVisionMode = {
	if ( !(isNull player) ) then 
	{
		if ( currentVisionMode player != 0) then 
		{
			if ( !NVG_nvOn ) then 
			{ 
				FG = ppEffectCreate ["FilmGrain", 2051];
				FG ppEffectEnable true;
				FG ppEffectAdjust[0.33, 1, 2, 0.1, 0.1, true];
				FG ppEffectCommit 0;

				DB = ppEffectCreate ["DynamicBlur", 451];
				DB ppEffectEnable true;
				DB ppEffectAdjust[0.33];
				DB ppEffectCommit 0;

				NVG_nvOn = true;
			};
		} else
		{
			if ( NVG_nvOn ) then 
			{ 
				ppEffectDestroy FG;
				ppEffectDestroy DB;
				setAperture -1;
				NVG_nvOn = false 
			};
		};
	};
};
[_fCheckVisionMode, 0, 0] call CBA_fnc_addPerFrameHandler; 
};

Share this post


Link to post
Share on other sites

OK! Removing the first if: "if (!isDedicated ) then" solved the problem. No need for watchdogs, canaries or any kind of animals here...

Dear Moderators: Post can be closed or even deleted.

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  

×