Welcome, Guest Friday 25th April 2014, 03:36:00
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: ArmA freezes on script addon, reason unknown  (Read 453 times)
0 Members and 1 Guest are viewing this topic.
myke13021
Contributing Member
**
Offline Offline

Myke


« on: 26 May 2008, 03:22:13 »

I really get headache from this. I try to make an addon to dynamically change viewdistance but i can't get it to work. It seems that scripts in addons behave completely different than any other scripts.

The error it throws:
Quote
'|#|' };
Error missing {
Thats all. After this, my PC completely locks up, alt+tab doesn't work nor ctrl+F4. Only Hardreset brings me back to work.

Ok, here what i have:

config.cpp:
Code:
class stm_dyn_vd
{
version[] = {};
dedicated[] = {};
class stm_dyn_vd
{
#include "\Dta\stm_dyn_vd_cfg.hpp"
};
};
class CfgPatches
{
class stm_dyn_vd
{
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {"Extended_EventHandlers"};
};
};

class Extended_Init_EventHandlers
{
class CAManBase
{
stm_init = "_this exec ""\stm_dyn_vd\stm_scripts\stm_check.sqf""";
};
};

stm_dyn_vd_cfg.hpp
Code:
STM_minViewDistance = 2000; //Define min allowed viewdistance, it will not fall below this value
STM_maxViewDistance = 4000; //Define max allowed viewdistance, it will not raise above this value
STM_estFlightLevel = 1000; //Define at which height the maxViewDistance should be reached
STM_TargetFPS = 25; //Define min FPS where DYN_VD should start to reduce viewdistance to get back to playable FPS
STM_groundOffset = 0; //Define min player height before raising viewdistance
STM_configHint = 0; //Show Hints to find best settings, 1 = ON/0 = OFF

stm_check.sqf
Code:
_unit = _this select 0;
if (isPlayer _unit)then
{
STM_FPS_COUNTER = compile loadFile "\stm_dyn_vd\stm_scripts\stm_bench.sqf";
nil = [] execVM "\stm_dyn_vd\stm_scripts\stm_dyn_vd.sqf";
};

stm_bench.sqf
Code:
private["_c","_d"];
_c = time;
_d = 0;
while {!(time > (_c +0.25))} do
{
_d = _d +1;
sleep 0.001;
};
_d = ((_d * acctime)*4);
_d;

stm_dyn_vd.sqf
Code:
_STM_GRND_OFFSET = getNumber (configFile >> "stm_dyn_vd" >> "stm_dyn_vd" >> "STM_groundOffset");
_STM_MIN_DIST = getNumber (configFile >> "stm_dyn_vd" >> "stm_dyn_vd" >> "STM_minViewDistance");
_STM_MAX_DIST = getNumber (configFile >> "stm_dyn_vd" >> "stm_dyn_vd" >> "STM_maxViewDistance");
_STM_MAX_HEIGHT = getNumber (configFile >> "stm_dyn_vd" >> "stm_dyn_vd" >> "STM_estFlightLevel");
_STM_TARGET_FPS = getNumber (configFile >> "stm_dyn_vd" >> "stm_dyn_vd" >> "STM_TargetFPS");
_STM_CFG_HINT = getNumber (configFile >> "stm_dyn_vd" >> "stm_dyn_vd" >> "STM_configHint");

_STM_STEP_WIDTH = ((_STM_MAX_DIST - _STM_MIN_DIST) / _STM_MAX_HEIGHT);
_STM_VIEW_DIST = (_STM_MIN_DIST + (((getPosASL player select 2) - _STM_GRND_OFFSET)*_STM_STEP_WIDTH));
setViewDistance _STM_VIEW_DIST;
_STM_MIN_FPS = (_STM_TARGET_FPS - (_STM_TARGET_FPS / 10));
_STM_MAX_FPS = (_STM_TARGET_FPS + (_STM_TARGET_FPS / 10));
_STM_ASSUMED_VD = _STM_VIEW_DIST;

for [{_i=0}, {_i<10}, {_i=_i+1}] do
{
_STM_ACTUAL_FPS = [] call STM_FPS_COUNTER;
if (_STM_ACTUAL_FPS > _STM_MAX_FPS) then
{
_STM_ACT_PLR_LVL = floor((getPosASL player select 2) - _STM_GRND_OFFSET);
_STM_ASSUMED_VD = (_STM_MIN_DIST + (_STM_ACT_PLR_LVL * _STM_STEP_WIDTH));
if (_STM_ASSUMED_VD > _STM_VIEW_DIST) then
{
_STM_VIEW_DIST = _STM_VIEW_DIST + (_STM_STEP_WIDTH * (sqrt _STM_ACTUAL_FPS));
if (_STM_VIEW_DIST > _STM_MAX_DIST) then
{
_STM_VIEW_DIST = _STM_MAX_DIST;
};
};
if (_STM_ASSUMED_VD < _STM_VIEW_DIST) then
{
_STM_VIEW_DIST = _STM_VIEW_DIST - (_STM_STEP_WIDTH * (sqrt _STM_ACTUAL_FPS));
if (_STM_VIEW_DIST < _STM_MIN_DIST) then
{
_STM_VIEW_DIST = _STM_MIN_DIST;
};
};
};
if (_STM_ACTUAL_FPS < _STM_MIN_FPS) then
{
_STM_VIEW_DIST = _STM_VIEW_DIST - (_STM_STEP_WIDTH * (sqrt _STM_ACTUAL_FPS));
if (_STM_VIEW_DIST < _STM_MIN_DIST) then
{
_STM_VIEW_DIST = _STM_MIN_DIST;
};
};
setViewdistance _STM_VIEW_DIST;
if (_STM_CFG_HINT == 1) then
{
hint format ["FPS: %1\nViewdistance: %2 Meter\nTarget VD: %3", _STM_ACTUAL_FPS, _STM_VIEW_DIST, _STM_ASSUMED_VD];
};
_i = 0;
};

This all i got in there. The folders are named properly as written in the config.
The scripts worked when directly used in the editor (so not in an addon), only thing i've changed was to define the values from the .hpp file directly in the stm_dyn_vd.sqf since the .hpp file was not loaded at this point of testing.

Anything else remained as it was (except script path to folder).

If anyone can see where the error is...please point me to it.


Myke out
Logged
Wolfrug
Addons Depot
Administrator
*****
Offline Offline


Official OFPEC Old Timer


« Reply #1 on: 26 May 2008, 06:05:53 »

Hey myke!

You could start by fixing this rather major blunder:

Code:
class Extended_Init_EventHandlers
{
class CAManBase
{
stm_init = "_this exec ""\stm_dyn_vd\stm_scripts\stm_check.sqf""";
};
};

Trying to "exec" a .sqf file invariably leads to fatal errors. Change it to execVM  Good

If that's not enough, try adding a little sleep to the start of the script : the latest version of XEH runs before units have even been recognized as created by the game, meaning it'll probably run on non-existing entities, which might also throw up errors Smiley 0.1 seconds is usually plenty.

Let us know how it goes!

Wolfrug out.
Logged

"When 900 years YOU reach, look as good you will not!"
i0n0s
Editors Depot Staff
*****
Offline Offline



« Reply #2 on: 26 May 2008, 06:36:07 »

And please don't use:
Code:
nil = [] execVM "\stm_dyn_vd\stm_scripts\stm_dyn_vd.sqf";
because this overwrites the predefined variable nil with a script handle.
Logged
myke13021
Contributing Member
**
Offline Offline

Myke


« Reply #3 on: 26 May 2008, 13:36:09 »

OMFG...so obviously...exec instead execVM...soething i should know for sure. BangHead BangHead BangHead

And i was counting curlet braces all over an over again everywhere and checking for other missing stuff like ; and such. Weeping Weeping
Really missed this exec. Damn, i thought my noob days would be over...doesn't seem so. Whistle

Thanks Wolfrug, works like a charm now.  Good


@i0n0s

Indeed, changed "nil" to "nul"...also a noob mistake at my side. Ok, i'm off, back to school again...with 38yrs. Cheesy


Thanks mates.



Myke out


:EDIT:
Forgot, Problem solved therefor topic...

**CLOSED**
« Last Edit: 26 May 2008, 17:36:16 by myke13021 » Logged
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: