Search the Community
Showing results for tags 'addstackedeventhandler'.
Found 1 result
-
How can I improve efficiency of "onEachFrame" with BIS_fnc_addStackedEventHandler ?
cklymowsky posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
With additional units on the field the FPS starts to drop. I would like to have the script only calculate the _distance every second instead of on every frame to see how much it improves FBS. Any ideas? I have tried the following with no luck private ["_randomSectorDestination","_revealTime","_enemyArray","_addNew"]; _enemyArray = []; _distance = 0; _displayName = ""; _picture = ""; _icon = ""; _revealTime = 30; _run = missionNamespace setVariable ["Intel",0]; _timer = missionNamespace setVariable ["Timer",time]; fn_Draw3DNEW = { _enemyArray = []; _distance = 0; _displayName = ""; _picture = ""; _icon = ""; _run = missionNamespace getVariable ["Intel",0]; _timer = missionNamespace getVariable ["Timer",0]; {if (((side _x) == AIside) && (isFormationLeader _x)) then {_enemyArray pushBack _x}} forEach allUnits+vehicles+allUnitsUAV; { _text = ""; if ( floor(time-_timer) == _run ) then { _run = missionNamespace setVariable ["Intel",_run + 5]; private ["_private", "_displayName", "_picture", "_icon", "_text", "_distance", "_leaderDestination","_enemyArray"]; if (vehicle _x != _x) then {_x = vehicle _x}; _distance = round (_x distance player); _displayName = getText (configfile >> "CfgVehicles" >> typeOf _x >> "displayName"); }; _text = str(parseText format["%1 men %2m",count units group _x, (str _distance)]); _icon = ""; if ( (_x isKindOf "LandVehicle") or (_x isKindOf "Air") or (_x isKindOf "Ship") ) then { _picture = getText (configfile >> "CfgVehicles" >> typeOf _x >> "picture"); } else { _icon = getText (configFile >> "CfgVehicles" >> typeOf _x >> "Icon"); _picture = getText (configFile >> "CfgVehicleIcons" >> _icon); }; drawIcon3D [ _picture, [1,0,0,1], [(visiblePosition _x) select 0,(visiblePosition _x) select 1,((visiblePosition _x) select 2) + 10], 0.8, 0.5, 0, _text, 0, 0.03, "PuristaMedium" ]; player reveal [_x, 4]; {[_x, 1] showWaypoint "ALWAYS" } forEach allGroups; } forEach _enemyArray; hint format ["_run: %1 \n floor(time-_timer): %2 \n floor(time-_timer) == _run: %3", _run, floor(time-_timer), floor(time-_timer) == _run]; }; _addNew = ["BIS_idNEW", "onEachFrame", "fn_Draw3DNEW"] call BIS_fnc_addStackedEventHandler; sleep (_revealTime); ["BIS_idNEW", "onEachFrame", "fn_Draw3DNEW"] call BIS_fnc_removeStackedEventHandler; _run = missionNamespace setVariable ["Intel",nil]; _timer = missionNamespace setVariable ["Intel",nil]; thanks in advance...