Jump to content

PaxJaromeMalues

Member
  • Content Count

    15
  • Joined

  • Last visited

  • Medals

Posts posted by PaxJaromeMalues


  1. And I am back with at least SOME good news:

     

    1. Buddy at my community looked at the code and the config viewer and was able to determine that "terc" as animationSource actually doesn't exist anymore. The term for swivel targets is now: popup_Source.

    2. Even tho "Terc" is not working anymore the EH which is on the swivel by default (hitPart) actually works for whatever reason when just placed with the object and entirely left alone. This doesn't get us anywhere tho.

    3. We are now able to properly animate the swivels with popup_source in combo with BIS_leaningEnabled.

    BUT

    4. The EventHandler hitPart is still not executing at all.

     

    last try in local multiplayer did generate this error in RPT:

    Quote

     1:37:57 Error in expression <[
    "_target",
    "",
    "",
    ""
    ];

    if (_target getVariable "rePop") then {
    _target setV>
     1:37:57   Error position: <getVariable "rePop") then {
    _target setV>
     1:37:57   Error getvariable: Type Array, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location

     

    Code currently looks like this:

     

    ///////////////////////////////////////////////////////////////////////////////////////////
    //Script to be called by inits or scripts for operating swivel and popup
    //targets around a specified object "_centerObj".
    //params: [ShouldTargetsAutoPop?,WhichSwitchShouldRun?,WhatDistanceFromObject?,WhatObject?]
    //By Pax
    ///////////////////////////////////////////////////////////////////////////////////////////
    params [
    	["_execution", "init"],
    	["_distance", 500],
    	["_centerObj", initCenter],
    	["_popEnabled", false]
    ];
    
    _targets = nearestObjects [position _centerObj, ["TargetBase", "Target_Swivel_01_base_F"], _distance];
    
    switch (toLower _execution) do {
    	case "init": {
    		{
    			//isKindOf Swivel else isKindOf popup
    			if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    				_x setVariable ["BIS_leaningEnabled", false, true];
    				_x setVariable ["BIS_poppingEnabled", false, true];
    				_x animateSource ["popup_Source", 1];
    			} else {
    				_x setVariable ["nopop", true, true];
    				_x animateSource ["terc", 1];
    			};
    		}forEach _targets;
    	};
    	
    	case "setup": {
    		//Make sure _targets are reset before running the setup phase (layerEightProtection)
    		["reset", _distance, _centerObj] call Fnc_popup;
    		//Inform Instructor who asked for setup that the command was received
    		"Command received - Targets are being setup" remoteExec ["systemChat", remoteExecutedOwner];
    		{
    			if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    				//Is this target told to auto-pop?
    				_x setVariable ["rePop", _popEnabled];
    				//Raise the target
    				_x animateSource ["popup_Source", 0];
    				//Making sure leaning is enabled for the animation
    				_x setVariable ["BIS_leaningEnabled", true, true];
    				//Add Hit EH and store the EH ID on the target
    				_x setVariable [
    					"HitEH",
    					_x addEventHandler [
    						"HitPart", {
    							params [
    								"_target",
    								"",
    								"",
    								""
    							];
    							//If auto-pop was set
    							if (_target getVariable "rePop") then {
    								_target setVariable [
    									"rePopThread", _target spawn {
    										"AUTOPOP" remoteExec ["systemChat", remoteExecutedOwner];
    										sleep (1 + random 4);
    										_this animateSource ["popup_Source", 0];
    									}
    								];
    							//No auto-pop set
    							} else {
    								//Bin Hit EH
    								"NOPOP" remoteExec ["systemChat", remoteExecutedOwner];
    								((_this select 0) select 0) RemoveEventHandler ["HitPart",0];
    								//Clean Shit up
    								_target setVariable ["HitEH", nil];
    								_target setVariable ["rePop", nil];
    							};
    						}
    					]
    				];
    			} else {
    				//Is this target told to auto-pop?
    				_x setVariable ["rePop", _popEnabled];
    				//Raise the target
    				_x animateSource ["terc", 0];
    				//Add Hit EH and store the EH ID on the target
    				_x setVariable [
    					"HitEH",
    					_x addEventHandler [
    						"Hit", {
    							params [
    								"_target",
    								"",
    								"",
    								""
    							];
    							//If auto-pop was set
    							if (_target getVariable "rePop") then {
    								_target setVariable [
    									"rePopThread", _target spawn {
    										sleep (1 + random 4);
    										_this animateSource ["terc", 0];
    									}
    								];
    							//No auto-pop set
    							} else {
    								//Bin Hit EH
    								_target removeEventHandler ["Hit", _thisEventHandler];
    								//Clean Shit up
    								_target setVariable ["HitEH", nil];
    								_target setVariable ["rePop", nil];
    							};
    						}
    					]
    				];
    			};
    		} forEach _targets;
    	};
    	
    	case "reset": {
    		//Inform Instructor of action
    		"Command received - Targets are being reset" remoteExec ["systemChat", remoteExecutedOwner];
    		{
    			//If the target for whatever reason still has an active EH:
    			if !(isNil {_x getVariable "HitEH"}) then {
    				//if auto-pop is set
    				if (_x getVariable "rePop") then {
    					//Is the target currently waiting to rePop?
    					if (!isNil {_x getVariable "rePopThread"} && {!isNull (_x getVariable "rePopThread")}) then {
    						//If it is waiting, terminate the Thread
    						terminate (_x getVariable "rePopThread");
    					};
    					_x setVariable ["rePopThread", nil];
    				};
    				if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    					_x removeEventHandler ["HitPart", _x getVariable "HitEH"];
    					_x setVariable ["HitEH", nil];
    					_x setVariable ["rePop", nil];
    					_x setVariable ["BIS_leaningEnabled", false, true];
    					_x animateSource ["popup_Source", 1];
    				} else {
    					_x removeEventHandler ["Hit", _x getVariable "HitEH"];
    					_x setVariable ["HitEH", nil];
    					_x setVariable ["rePop", nil];
    					_x animateSource ["terc", 1];
    				};
    			};
    			//Lower the targets
    		} forEach _targets;
    	};
    };

    We still hope someone can point us into the right direction as we are somewhat at the end of our capabilities here.

     

    KR

    Pax


  2. On 19.1.2019 at 2:02 AM, pierremgi said:

    NOTE: I hope  @Pax_Jarome  will success with my code (modified or not). This swivel target bug didn't have so much workaround till yet... You're welcome.

     

    Sofar I could make some progress and actually was able to terminate some possibilities for these issues.

    1) Popup targets (the normal ones) now behave as expected inculding the repop delay. (Thanks again @Larrow!)

    2) I tried to adapt the code from Larrow for the swivel targets based on the unknown authors mentions of "HitPart" for the EH and the weird bracketing of ((_this select 0) select 0) animateSource yadda yadda

    3)The code of @pierremgi actually works when put into each swivels init via the editor. On the server the swivels will not go into weird spasms anymore and actually move back and forth as expected.

    BUT :P

    4) Swivels will still not accept the first call of case init (meaning on mission start they just pop up and swivel along probably also ignoring BIS_poppingEnabled false)

    AND

    5) Will not react to any bullet impact at all (which is unusual)

    AND

    6) Will not execute the EventHandler placed on them (tested with Hit and HitPart as EH designator)

     

    This is the modified code sofar:

     

    ///////////////////////////////////////////////////////////////////////////////////////////
    //Script to be called by inits or scripts for operating swivel and popup
    //targets around a specified object "_centerObj".
    //params: [ShouldTargetsAutoPop?,WhichSwitchShouldRun?,WhatDistanceFromObject?,WhatObject?]
    //By Pax
    ///////////////////////////////////////////////////////////////////////////////////////////
    params [
    	["_execution", "init"],
    	["_distance", 500],
    	["_centerObj", initCenter],
    	["_popEnabled", false]
    ];
    
    _targets = nearestObjects [position _centerObj, ["TargetBase", "Target_Swivel_01_base_F"], _distance];
    // Target_Swivel_01_ground_F ??! Target_Swivel_01_base_F
    
    switch (toLower _execution) do {
    	case "init": {
    		{
    			//isKindOf Swivel else isKindOf popup
    			if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    				_x setVariable ["BIS_poppingEnabled", false, true];
    				_x animateSource ["terc", 1];
    			} else {
    				_x setVariable ["nopop", true, true];
    				_x animateSource ["terc", 1];
    			};
    		}forEach _targets;
    	};
    	
    	case "setup": {
    		//Make sure _targets are reset before running the setup phase (layerEightProtection)
    		["reset", _distance, _centerObj] call Fnc_popup;
    		//Inform Instructor who asked for setup that the command was received
    		"Command received - Targets are being setup" remoteExec ["systemChat", remoteExecutedOwner];
    		{
    			if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    				//Is this target told to auto-pop?
    				_x setVariable ["rePop", _popEnabled];
    				//Raise the target
    				_x animateSource ["terc", 0];
    				//Add Hit EH and store the EH ID on the target
    				_x setVariable [
    					"HitEH",
    					_x addEventHandler [
    						"HitPart", {
    							params [
    								"_target",
    								"",
    								"",
    								""
    							];
    							//If auto-pop was set
    							if (_target getVariable "rePop") then {
    								_target setVariable [
    									"rePopThread", _target spawn {
    										sleep (1 + random 4);
    										//_this animateSource ["terc", 0];
    										((_this select 0) select 0) animate ["Terc",1];
    									}
    								];
    							//No auto-pop set
    							} else {
    								//Bin Hit EH
    								//_target removeEventHandler ["HitPart", _thisEventHandler];
    								((_this select 0) select 0) RemoveEventHandler ["HitPart",0];
    								//Clean Shit up
    								_target setVariable ["HitEH", nil];
    								_target setVariable ["rePop", nil];
    							};
    						}
    					]
    				];
    			} else {
    				//Is this target told to auto-pop?
    				_x setVariable ["rePop", _popEnabled];
    				//Raise the target
    				_x animateSource ["terc", 0];
    				//Add Hit EH and store the EH ID on the target
    				_x setVariable [
    					"HitEH",
    					_x addEventHandler [
    						"Hit", {
    							params [
    								"_target",
    								"",
    								"",
    								""
    							];
    							//If auto-pop was set
    							if (_target getVariable "rePop") then {
    								_target setVariable [
    									"rePopThread", _target spawn {
    										sleep (1 + random 4);
    										_this animateSource ["terc", 0];
    									}
    								];
    							//No auto-pop set
    							} else {
    								//Bin Hit EH
    								_target removeEventHandler ["Hit", _thisEventHandler];
    								//Clean Shit up
    								_target setVariable ["HitEH", nil];
    								_target setVariable ["rePop", nil];
    							};
    						}
    					]
    				];
    			};
    		} forEach _targets;
    	};
    	
    	case "reset": {
    		//Inform Instructor of action
    		"Command received - Targets are being reset" remoteExec ["systemChat", remoteExecutedOwner];
    		{
    			//If the target for whatever reason still has an active EH:
    			if !(isNil {_x getVariable "HitEH"}) then {
    				//if auto-pop is set
    				if (_x getVariable "rePop") then {
    					//Is the target currently waiting to rePop?
    					if (!isNil {_x getVariable "rePopThread"} && {!isNull (_x getVariable "rePopThread")}) then {
    						//If it is waiting, terminate the Thread
    						terminate (_x getVariable "rePopThread");
    					};
    					_x setVariable ["rePopThread", nil];
    				};
    				if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    					_x removeEventHandler ["HitPart", _x getVariable "HitEH"];
    					_x setVariable ["HitEH", nil];
    					_x setVariable ["rePop", nil];
    					_x animateSource ["terc", 1];
    				} else {
    					_x removeEventHandler ["Hit", _x getVariable "HitEH"];
    					_x setVariable ["HitEH", nil];
    					_x setVariable ["rePop", nil];
    					_x animateSource ["terc", 1];
    				};
    			};
    			//Lower the targets
    		} forEach _targets;
    	};
    };

    Kind regards
    Pax


  3. Update:

     

    since Larrows changes the EH now fire for the regular popup targets and the delay is also working, which is wunderful. This is in Editor multiplayer test AND on a dedicated test server of our community across the globe. Awesome!

     

    Swivel targets on the other hand are a mystery to me and are probably borked as fuck when it comes to MP compatibility.

     

    In local editor test in multiplayer swivel targets via the current script state start in a swining state... left right, but when shot, will absolutely not react.

    In state case "setup" they will just continue swinging but due to their different way of being in need of called they now also have no Hit EH (afaik the EH needs to be called HitPart with swivel targets).

     

    On the dedicated test server swivels start the same as on local but their "swinging" is reduced to a mere spasm, it will continue to spawms on case "setup" as well.

     

    Therefore it can be said that the solution provided on steam to do this here:

    if (!isDedicated) then {
    	{
    		_x setVariable ["BIS_exitScript", false, true];
    	} forEach entities [
    		["Target_Swivel_01_ground_F", "Land_Target_Swivel_01_F"],[]
    	];
    };

    Doesn't do shit to fix the BIS swivels MP issues.

     

    Current conclusion until opposed:

     

    Dop not even touch swivels targets with a 10 feet pole. Borked AF.

    As per BIS tracker borked since years and no fix sofar.

     

     

    Thanks everyone for your great help!

     

    I will stay with normal popuptargets for now until someone can provide a fix by BIS or per code.


  4. EDIT: Issue found, I did fuck up the eventhandlers {} brackets.

     

    Hi @Larrow I read your suggestions line by line and adapted most of it into my script for now. I think there might still be adaptions necessary for the eventHandlers based on if the targets are isKindOf (swivelthingy) as EH for these need to be called and removed differently than normal popup targets if I can trust what others had to do in their scripts in the past.

     

    My Init.sqf currently looks like this:

    #define framework
    
    #include "core\script_macros.hpp"
    #include "core\init.sqf" //DO NOT REMOVE
    #include "customization\settings.sqf" //DO NOT REMOVE
    #include "core\dia\debug\dia_debug.sqf" //DO NOT REMOVE
    
    #include "customization\addAction.sqf" //give instructors control over all popuptargets
    
    //Following code is apparently necessary to make swivels somewhat working in multiplayer
    if (!isDedicated) then {
    	{
    		_x setVariable ["BIS_exitScript", false, true];
    	} forEach entities [
    		["Target_Swivel_01_ground_F", "Land_Target_Swivel_01_F"],[]
    	];
    };
    
    Fnc_popup = compile preprocessFileLineNumbers "customization\popups.sqf";
    
    if (isServer) then {
    
    	"hide" execVM "customization\arrows.sqf";
    
    //	[false,"init",500,initCenter] remoteExec ["Fnc_popup", 2];
    
    	_nul = [] spawn {
    		waitUntil {time > 0};
    		[] call Fnc_popup;
    	};
    
    	"" call FNC_StartingCount; //DO NOT REMOVE
    
    	[] spawn { //Spawns code running in parallel
    
    		while {!FW_MissionEnded} do { //Loops while the mission is not ended
    			
    			#include "customization\endConditions.sqf" //DO NOT REMOVE
    			
    			//The time limit in minutes variable called FW_TimeLimit is set in customization/settings.sqf, to disable the time limit set it to 0
    			if ((time / 60) >= FW_TimeLimit && FW_TimeLimit != 0) exitWith { //It is recommended that you do not remove the time limit end condition 
    				
    				FW_TimeLimitMessage call FNC_EndMission;
    				
    			};
    		};	
    	};
    };
    
    #include "modules\modules.sqf" //DO NOT REMOVE
    #include "core\postChecks.sqf" //DO NOT REMOVE

     

    My AddAction looks like this. It threw some errors due to _player and that variable being undefined so I reverted back to 'player' as that worked inbefore the changes.

    //Fnc_popup = compile preprocessFileLineNumbers "customization\popups.sqf";
    /*if (!isDedicated) then {
    	waitUntil { (player == player) };
    	if (player getVariable "isInstructor") then {
    		conrepboard addAction ["<t color='#FF2222'>Reveal Arrows",{"reveal" execVM "customization\arrows.sqf";}];
    		conrepboard addAction ["<t color='#FF2222'>Hide Arrows",{"hide" execVM "customization\arrows.sqf";}];
    		arBoard addAction ["<t color='#FF2222'>Raise Bunker Targets",{[true,"setup",15,bnkTgts] remoteExec ["Fnc_popup", 2];}];
    		arBoard addAction ["<t color='#FF2222'>Lower Bunker Targets",{[false,"reset",15,bnkTgts] remoteExec ["Fnc_popup", 2];}];
    		grnBoard addAction ["<t color='#FF2222'>Raise Trench Targets",{[false,"setup",15,grnTgts] remoteExec ["Fnc_popup", 2];}];
    		grnBoard addAction ["<t color='#FF2222'>Lower Trench Targets",{[false,"reset",15,grnTgts] remoteExec ["Fnc_popup", 2];}];
    		bldBoard addAction ["<t color='#FF2222'>Raise House Targets",{[false,"setup",15,hseTgts] remoteExec ["Fnc_popup", 2];}];
    		bldBoard addAction ["<t color='#FF2222'>Lower House Targets",{[false,"reset",15,hseTgts] remoteExec ["Fnc_popup", 2];}];
    		grnPraBoard addAction ["<t color='#FF2222'>Raise Practice Targets",{[false,"setup",3,grnPraTgts] remoteExec ["Fnc_popup", 2];}];
    		grnPraBoard addAction ["<t color='#FF2222'>Lower Practice Targets",{[false,"reset",3,grnPraTgts] remoteExec ["Fnc_popup", 2];}];
    	};
    };
    */
    if (!isDedicated) then {
    //	params ["_player"];
    	if (player getVariable ["isInstructor", false]) then {
    		conrepboard addAction ["<t color='#FF2222'>Reveal Arrows",{"reveal" execVM "customization\arrows.sqf";}];
    		conrepboard addAction ["<t color='#FF2222'>Hide Arrows",{"hide" execVM "customization\arrows.sqf";}];
    		arBoard addAction ["<t color='#FF2222'>Raise Bunker Targets",{["setup",15,bnkTgts,true] remoteExec ["Fnc_popup", 2];}];
    		arBoard addAction ["<t color='#FF2222'>Lower Bunker Targets",{["reset",15,bnkTgts,false] remoteExec ["Fnc_popup", 2];}];
    		grnBoard addAction ["<t color='#FF2222'>Raise Trench Targets",{["setup",15,grnTgts,false] remoteExec ["Fnc_popup", 2];}];
    		grnBoard addAction ["<t color='#FF2222'>Lower Trench Targets",{["reset",15,grnTgts,false] remoteExec ["Fnc_popup", 2];}];
    		bldBoard addAction ["<t color='#FF2222'>Raise House Targets",{["setup",15,hseTgts,false] remoteExec ["Fnc_popup", 2];}];
    		bldBoard addAction ["<t color='#FF2222'>Lower House Targets",{["reset",15,hseTgts,false] remoteExec ["Fnc_popup", 2];}];
    		grnPraBoard addAction ["<t color='#FF2222'>Raise Practice Targets",{["setup",3,grnPraTgts,false] remoteExec ["Fnc_popup", 2];}];
    		grnPraBoard addAction ["<t color='#FF2222'>Lower Practice Targets",{["reset",3,grnPraTgts,false] remoteExec ["Fnc_popup", 2];}];
    	};
    };

    The popups.sqf was changed to look nearly alike yours.
    As said I might have to do some more adaption and if's for the swivels, but I already ran into a script error that I can not find as for what I can see there, there is no missing bracket whatsoever:

     

    Quote

    23:37:58 [ACRE] (sys_core) INFO: Map Load Complete: \A3\Map_Malden\malden.wrp
    23:37:59 Error in expression <
    "Hit",
    params [
    "_target",
    "",
    "",
    ""
    ];

    if (_target getVariable "rePop") then>
    23:37:59   Error position: <;

    if (_target getVariable "rePop") then>
    23:37:59   Error Missing ]
    23:37:59 File D:\Users\NOPE\Documents\Arma 3 - Other Profiles\NOOOOOPE\mpmissions\UOTC_FTOps_Course_ZEUS_V1.Malden\customization\popups.sqf, line 50

     

    ///////////////////////////////////////////////////////////////////////////////////////////
    //Script to be called by inits or scripts for operating swivel and popup
    //targets around a specified object "_centerObj".
    //params: [ShouldTargetsAutoPop?,WhichSwitchShouldRun?,WhatDistanceFromObject?,WhatObject?]
    //By Pax
    ///////////////////////////////////////////////////////////////////////////////////////////
    params [
    	["_execution", "init"],
    	["_distance", 500],
    	["_centerObj", initCenter],
    	["_popEnabled", false]
    ];
    
    _targets = nearestObjects [position _centerObj, ["TargetBase", "Target_Swivel_01_base_F"], _distance];
    
    switch (toLower _execution) do {
    	case "init": {
    		{
    			//isKindOf Swivel else isKindOf popup
    			if (typeOf _x isKindOf "Target_Swivel_01_base_F") then {
    				_x setVariable ["BIS_poppingEnabled", false, true];
    			} else {
    				_x setVariable ["nopop", true, true];
    			};
    			// Lower all targets defined in array _targets
    			_x animateSource ["terc", 1];
    		}forEach _targets;
    	};
    	
    	case "setup": {
    		//Make sure _targets are reset before running the setup phase (layerEightProtection)
    		["reset", _distance, _centerObj] call Fnc_popup;
    		//Inform Instructor who asked for setup that the command was received
    		"Command received - Targets are being setup" remoteExec ["systemChat", remoteExecutedOwner];
    		{
    			//Is this target told to auto-pop?
    			_x setVariable ["rePop", _popEnabled];
    			//Raise the target
    			_x animateSource ["terc", 0];
    			//Add Hit EH and store the EH ID on the target
    			_x setVariable [
    				"HitEH",
    				_x addEventHandler [
    					"Hit",
    					params [
    						"_target",
    						"",
    						"",
    						""
    					];
    					//If auto-pop was set
    					if (_target getVariable "rePop") then {
    						_target setVariable [
    							"rePopThread", _target spawn {
    								sleep (1 + random 4);
    								_this animateSource ["terc", 0];
    							};
    						];
    					//No auto-pop set
    					} else {
    						//Bin Hit EH
    						_target removeEventHandler ["Hit", _thisEventHandler];
    						//Clean Shit up
    						_target setVariable ["HitEH", nil];
    						_target setVariable ["rePop", nil];
    					};
    				]
    			];
    		} forEach _targets;
    	};
    	
    	case "reset": {
    		//Inform Instructor of action
    		"Command received - Targets are being reset" remoteExec ["systemChat", remoteExecutedOwner];
    		{
    			//If the target for whatever reason still has an active EH:
    			if !(isNil {_x getVariable "HitEH"}) then {
    				//if auto-pop is set
    				if (_x getVariable "rePop") then {
    					//Is the target currently waiting to rePop?
    					if (!isNil {_x getVariable "rePopThread"} && {!isNull (_x getVariable "rePopThread")}) then {
    						//If it is waiting, terminate the Thread
    						terminate (_x getVariable "rePopThread");
    					};
    					_x setVariable ["rePopThread", nil];
    				};
    				_x removeEventHandler ["Hit", _x getVariable "HitEH"];
    				_x setVariable ["HitEH", nil];
    				_x setVariable ["rePop", nil];
    			};
    			//Lower the targets
    			_x animateSource ["terc", 1];
    		} forEach _targets;
    	};
    }; 
    
    /*
    private _targets = nearestObjects [position _centerObj, ["TargetBase"], _distance];
    private _SwivelTargets = nearestObjects [position _centerObj, ["Target_Swivel_01_base_F"], _distance];
    
    switch (_execution) do {
    	case "init": {
    		{
    			_x setVariable ["nopop", true];
    			_x animateSource ["terc",1]
    		} forEach _targets;
    		{
    			_x setVariable ["BIS_poppingEnabled", false];
    //			_x setVariable ["BIS_leaningEnabled", false]; <-- aparently disables any animation physics, thx BI -.-
    			_x animateSource ["terc",1];
    		} forEach _SwivelTargets;
      	};
    	
    	case "setup": {
    		"setup called" remoteExec ["systemChat"];
    //	Normal Popuptargets
    		if (_popEnabled) then {
    			"popup first condition" remoteExec ["systemChat"];
    			{
    				_x setVariable ["nopop", false];
    				_x animateSource ["terc",0];
    				_x addEventHandler [
    					"Hit", {
    						"popup first condition EH animate" remoteExec ["systemChat"];
    						(_this select 0) animateSource ["terc",1];
    						(_this select 0) setVariable ["popdelay", 1 + (random 5)];
    //						[{
    //							(_this select 0) animateSource ["terc",0];
    //							"popup first condition EH in CBA" remoteExec ["systemChat"];
    //						},
    //						[_this], 2 + (random 3)] call CBA_fnc_waitAndExecute;
    					}
    				] 
    			} forEach _targets;
    		} else {
    			"popup second condition" remoteExec ["systemChat"];
    			{
    				_x animateSource ["terc",0];
    				_x addEventHandler [
    					"Hit", {
    						(_this select 0) animateSource ["terc",1];
    						(_this select 0) removeEventHandler ["Hit",0];
    					}
    				]
    			} forEach _targets;
    		};
    //	Swivel targets
    		if (_popEnabled) then {
    			"swivel first condition" remoteExec ["systemChat"];
    			{
    				_x setVariable ["BIS_poppingEnabled", true];
    				_x setVariable ["BIS_leaningEnabled", true];
    				_x animateSource ["terc",0];
    				_x addEventHandler [
    					"HitPart", {
    						((_this select 0) select 0) animateSource ["terc",1];
    						((_this select 0) select 0) setVariable ["popdelay", 1 + (random 5)];
    //						[{
    //							((_this select 0) select 0) animateSource ["terc",0];
    //						},
    //						[_this], 2 + (random 3)] call CBA_fnc_waitAndExecute;
    					}
    				] 
    			} forEach _SwivelTargets;
    		} else {
    			"swivel second condition" remoteExec ["systemChat"];
    			{
    				_x setVariable ["BIS_leaningEnabled", true];
    				_x animateSource ["terc",0];
    				_x addEventHandler [
    					"HitPart", {
    						((_this select 0) select 0) setVariable ["BIS_leaningEnabled", false];
    						((_this select 0) select 0) animateSource ["terc",1];
    						((_this select 0) select 0) removeEventHandler ["HitPart",0];
    					}
    				]
    			} forEach _SwivelTargets;
    		};
    	};
    	
    	case "reset": {
    		"reset called" remoteExec ["systemChat"];
    		{
    			_x setVariable ["nopop", true];
    			_x removeEventHandler ["Hit",0];
    			_x animateSource ["terc",1];
    		} forEach _targets;
    		{
    			_x setVariable ["BIS_poppingEnabled", false];
    			_x setVariable ["BIS_poppingEnabled", false];
    			_x RemoveEventHandler ["HitPart",0];
    			_x animateSource ["terc",1];
    		} forEach _SwivelTargets;
    	};
    };
    */

     

    Greetings

    Pax


  5. Quick checkin, sofar I still haven't been able to make the eventhandler execute properly with the dedicated server and swivel targets.

    EH on the normal popup targets seem to work, but the delay code within the EH still isn't executed at all for whatever reason.

    I only have a few hours over the next days to spare so I might not spend them on the scripts.

    I will check back in next weekend, with a hopefully working solution or a workaround or a script that only uses popup targets vs with swivels as these start to set my brain on fire.


  6. 18 hours ago, pierremgi said:

    Truly, I wonder the added value of such CBA functions. To delay a unscheduled code, you ask your CPU to loop incrementally a short code, working for nuts, just to avoid a spawn (scheduled) code... Isn't it just "intellectually satisfactory"? Where is the real gain? At least, I hope you don't load CBA just for that!

    ... thanks, I guess?

     

    15 hours ago, Tankbuster said:

     In this case, he doesn't need CBA. 

    https://community.bistudio.com/wiki/BIS_fnc_runLater

    Thank you, I did not know this fuction until now, I have to check if it works in unscheduled environment like eh tho, will do that over the next 2 days.

     

    15 hours ago, killzone_kid said:


    Didn't look through the whole code, just noticed this ^^^. What makes you think you can add MP event handler with addMPEventHandler but remove it as if it was a normal event handler? Did you know there is removeMPEventHandler command for that? https://community.bistudio.com/wiki/removeMPEventHandler

    Because I am absolutely unknowledgable in sqf (scripting in general) compared to you guys.

     

    3 hours ago, Larrow said:

    No such MP event.

    There should be no need to use MP events, just use normal EH "Hit" on the server (where the targets are local).

     

     

      Hide contents
    
    
    //initServer.sqf
    
    if !( isDedicated ) then {
    	{
    		//Not even sure what this is or where it came from as I find no reference to it in a grep of A3
    		_x setVariable[ "BIS_exitScript", false, true ];
    	} forEach entities [ [ "Target_Swivel_01_ground_F", "Land_Target_Swivel_01_F" ], [] ];
    };
    
    _nul = [] spawn {
    	waitUntil{ time > 0 };
    
    	//No remoteExec already executing from the server
    	[] call Fnc_popup;
    };

     

    
    
    //initPlayerLocal.sqf
    
    params[ "_player" ];
    
    if ( _player getVariable[ "isInstructor", false ] ) then {
    	arBoard addAction[ "<t color='#FF0000'>Raise Bunker Targets", {
    		[ "setup", 15, bnkTgts, true ] remoteExec[ "Fnc_popup", 2 ];
    	}];
    	arBoard addAction[ "<t color='#FF0000'>Lower Bunker Targets", {
    		[ "reset", 15, bnkTgts ] remoteExec[ "Fnc_popup", 2 ];
    	}];
    };

     

    
    
    ///////////////////////////////////////////////////////////////////////////////////////////
    //Script to be called by inits or scripts for operating swivel and popup
    //targets around a specified object "_center".
    //params: [WhichSwitchShouldRun?,WhatDistanceFromObject?,WhatObject?,ShouldTargetsAutoPop?]
    //By PaxJaromeMalues
    ///////////////////////////////////////////////////////////////////////////////////////////
    params [
    	[ "_execution", "init" ],
    	[ "_dist", 500 ],
    	[ "_center", initCenter ],
      	[ "_popenabled", false ]
    ];
    
    _targets = nearestObjects[ position _center, [ "TargetBase", "Target_Swivel_01_base_F" ], _dist ];
    
    //Be safe, make sure command was sent in lower case
    switch ( toLower _execution ) do {
    	
    	case "init" : {
    		
    		{
    			//Add noPop vars
    			//Do in editor to save network bandwidth?
    			if ( typeOf _x isKindOf "Target_Swivel_01_base_F" ) then {
    				_x setVariable[ "BIS_poppingEnabled", false, true ];
    			}else{
    				_x setVariable[ "nopop", true, true ];
    			};
    			
    			//Lower target
    			_x animateSource[ "terc", 1 ];
    		}forEach _targets;
    		
      	};
    	
    	case "setup" : {
    
    		//Make sure targets are reset
    		[ "reset", _dist, _center ] call Fnc_popup;
          
    		//Inform Instructor who asked for setup that command was received
    		"Setting up targets" remoteExec[ "systemChat", remoteExecutedOwner ];
    
    		{
    			//Store a reference to the instructor on the target
    			_x setVariable[ "instructor", remoteExecutedOwner ];
    			//Store whether this target is to rePop
    			_x setVariable[ "rePop", _popenabled ];
    			
    			//Raise target
    			_x animateSource[ "terc", 0 ];
    			
    			//Add Hit event and store EH ID on target
    			_x setVariable[ "HitEH", _x addEventHandler [ "Hit", {
    				params[ "_target", "", "", "_instigator" ];
    				
    				//If the Hit was caused by a player
    				if ( isPlayer _instigator ) then {
    					//Inform the Instructor who hit the target
    					format[ "%1 hit target", name _instigator ] remoteExec ["systemChat", _target getVariable "instructor" ];
    				};
    				
    				//If the target is set to rePop
    				if ( _target getVariable "rePop" ) then {
    					//Spawn thread and store a reference
    					_target setVariable[ "rePopThread", _target spawn {
    						//Random sleep time
    						sleep ( 2 + random 3 );
    						//Raise target
    						_this animateSource[ "terc", 0 ];
    					}];
    				}else{
    					//No rePop
    					//Remove Hit EH
    					_target removeEventHandler[ "Hit", _thisEventHandler ];
    					//Clean up
    					_target setVariable[ "HitEH", nil ];
    					_target setVariable[ "instructor", nil ];
    					_target setVariable[ "rePop", nil ];
    				};
    			}]];
    		}forEach _targets;
    	};
    	
    	case "reset" : {
    		
    		//Inform Instructor who requested reset that command was received
    		"reseting targets" remoteExec[ "systemChat", remoteExecutedOwner ];
    		
    		{
    			//If the target still has a Hit EH
    			if !( isNil { _x getVariable "HitEH" } ) then {
    				//If the target is set to rePop
    				if ( _x getVariable "rePop" ) then {
    					//Is the target awaiting rePop
    					if ( !isNil { _x getVariable "rePopThread" } && { !isNull ( _x getVariable "rePopThread" ) } ) then {
    						//If it is terminate the thread
    						terminate ( _x getVariable "rePopThread" );
    					};
    					//Clean up
    					_x setVariable[ "rePopThread", nil ];
    				};
    				//Remove Hit EH
    				_x removeEventHandler[ "Hit", _x getVariable "HitEH" ];
    				//Clean up
    				_x setVariable[ "HitEH", nil ];
    				_x setVariable[ "rePop", nil ];
    			};
    			//Clean up
    			_x setVariable[ "instructor", nil ];
    			
    			//Lower target
    			_x animateSource[ "terc", 1 ];
    		} forEach _targets;
    		
    	};
    };

    All thoroughly untested.

     

    Oh wow Larrow, I will definitely will incorporate a lot of this in my new try, especially the stuff with reducing the two arrays of taregts into one and then asking for its kind, that is super neat.
    Thanks alot guys!
     

    I'll be back if it works and post the solution or doesn't work and ask for furhter assistance ^^'


  7. 5 hours ago, davidoss said:

    Its CBA_fnc_waitAndExecute parameters array

    Here  problem is locality along with objects variables and eh

    I looked at cba docs and if I understand it right, args need to be in brackets if I get that right so I now have: [_this] instead of _this, do I need to also enclose 2 + (random 3) as (2 + (random 3))?

     

    But I absolutely not sure what the locality and variable issues could be that you mentioned.

    All variables are local to each execution and are not used outside of popup.sqf.

     

    It would be much appriciated if you could elaborate on your findings.


  8. 5 hours ago, nomadd said:

    may or may not be the problem but it looks like you are missing a closing bracket

    
    {	
    	_x addMPEventHandler 
    	[ "MPHit", 
    		{
    			"popup first condition EH before CBA" remoteExec ["systemChat"];
    			(_this select 0) animateSource ["terc",1];
    		[  //whats this ?
    			{
    				(_this select 0) animateSource ["terc",0];
    				"popup first condition EH in CBA" remoteExec ["systemChat"];
    			},
    				_this, 2 + (random 3)] call CBA_fnc_waitAndExecute;
    		}
    	] 
    } forEach _targets;

     

    thats the opening bracket for CBA_fnc_waitAndExecute


  9. Hello folks,

     

    I am currently working on a mission designed for training puposes.

    The mission is build upon the OlsenFramework, a mission making framework.

    Links are to either githubs.

     

    I am running into the following problem:

     

    a) If I test the mission in the Eden Editors host environment and singleplayer, all code executes flawslessly when addEventHandler is used (obviously no MP).

    b) When tested on a dedicated server, the EventHandlers (addEventHandler and addMPEventhandler) will not fire at all. This was tested via systemChat messages.

     

    The code:

    (All code can be viewed on the github linked, its the latest changes made and the last version tested on the server)

    A few months back I was given a script by my units training officer to work with popup targets but it was split in a multitude of files and also only worked partially on dedicated, which I did not like so I rewrote it into a single script.

    The origin of that code is not known to me, so forgive me for the missing credits.

     

    In the init.sqf of the mission, I call code which adds a line of code to each targets which apparently is supposed to 'fix' swivel targets not working in multiplayer dedicated environments. This can be found here.
    As far as I unterstand this is supposed to disable animation control on all clients (including non dedicated servers and HC), but sofar the targets still behave crappy.

    if (!isDedicated) then {
    	_localTargets = (entities "Target_Swivel_01_ground_F") + (entities "Land_Target_Swivel_01_F");
    	{
    		_x setVariable ["BIS_exitScript", false];
    	} forEach _localTargets;
    };

    later I call my script which is mainly in control of the targets: popup.sqf once via the init.sqf to get all targets into a down position at mission start. This works flawless.
    Fnc_popup is the same as popup.sqf just processed via: Fnc_popup = compile preprocessFileLineNumbers "customization\popups.sqf";

    if (isServer) then {
    	[false,"init",500,initCenter] remoteExec ["Fnc_popup", 2];
    };

    Players being Instructors are makred via a variable "isInstructor" only players with this restriction will have access to the popup addAction ... actions. Which are placed on landBoards in the mission.
    en example from the addAction.sqf looks like this:

    Fnc_popup = compile preprocessFileLineNumbers "customization\popups.sqf";
    if (!isDedicated) then {
    	waitUntil { (player == player) };
    	if (player getVariable "isInstructor") then {
    		arBoard addAction ["<t color='#FF0000'>Raise Bunker Targets",{[true,"setup",15,bnkTgts] remoteExec ["Fnc_popup", 2];}];
    		arBoard addAction ["<t color='#FF0000'>Lower Bunker Targets",{[false,"reset",15,bnkTgts] remoteExec ["Fnc_popup", 2];}];
    	};
    };

    This calls a precompiled form of popup.sqf and now the problöem occurs that everything in that popup.sqf works, except for the damn eventHandlers place on the trainingTargets.

    case init and case reset work, and throw no script errors.

    This is the popup.sqf file content:

    ///////////////////////////////////////////////////////////////////////////////////////////
    //Script to be called by inits or scripts for operating swivel and popup
    //targets around a specified object "_center".
    //params: [ShouldTargetsAutoPop?,WhichSwitchShouldRun?,WhatDistanceFromObject?,WhatObject?]
    //By PaxJaromeMalues
    ///////////////////////////////////////////////////////////////////////////////////////////
    params [["_popenabled",false],["_execution","init"],["_dist",25],["_center",initCenter]];
    
    _targets = nearestObjects [position _center, ["TargetBase"], _dist];
    _SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F"], _dist];
    
    switch (_execution) do {
    	case "init": {
    		{
    			_x setVariable ["nopop", true];
    			_x animateSource ["terc",1]
    		} forEach _targets;
    		{
    			_x setVariable ["BIS_poppingEnabled", false];
    			_x animateSource ["terc",1];
    		} forEach _SwivelTargets;
      	};
    	
    	case "setup": {
    		"setup called" remoteExec ["systemChat"];
    		if (_popenabled) then {
    			"popup first condition" remoteExec ["systemChat"];
    			{
    				_x animateSource ["terc",0];
    				_x addMPEventHandler [
    					"MPHit", {
    						"popup first condition EH before CBA" remoteExec ["systemChat"];
    						(_this select 0) animateSource ["terc",1];
    						[{
    							(_this select 0) animateSource ["terc",0];
    							"popup first condition EH in CBA" remoteExec ["systemChat"];
    						},
    						_this, 2 + (random 3)] call CBA_fnc_waitAndExecute;
    					}
    				] 
    			} forEach _targets;
    		} else {
    			"popup second condition" remoteExec ["systemChat"];
    			{
    				_x animateSource ["terc",0];
    				_x addMPEventHandler [
    					"MPHit", {
    						(_this select 0) animateSource ["terc",1];
    						(_this select 0) removeEventHandler ["MPHit",0];
    					}
    				]
    			} forEach _targets;
    		};
    		if (_popenabled) then {
    			"swivel first condition" remoteExec ["systemChat"];
    			{
    				_x animateSource ["terc",0];
    				_x addMPEventHandler [
    					"MPHitPart", {
    						((_this select 0) select 0) animateSource ["terc",1];
    						[{
    							((_this select 0) select 0) animateSource ["terc",0];
    						},
    						_this, 2 + (random 3)] call CBA_fnc_waitAndExecute;
    					}
    				] 
    			} forEach _SwivelTargets;
    		} else {
    			"swivel second condition" remoteExec ["systemChat"];
    			{
    				_x animateSource ["terc",0];
    				_x addMPEventHandler [
    					"MPHitPart", {
    						((_this select 0) select 0) animateSource ["terc",1];
    						((_this select 0) select 0) removeEventHandler ["MPHit",0];
    					}
    				]
    			} forEach _SwivelTargets;
    		};
    	};
    	
    	case "reset": {
    		"reset called" remoteExec ["systemChat"];
    		{
    			_x removeEventHandler ["MPHit",0];
    			_x animateSource ["terc",1];
    		} forEach _targets;
    		{
    			_x animateSource ["terc",1];
    			_x RemoveEventHandler ["MPHitPart",0];
    		} forEach _SwivelTargets;
    	};
    };

     

     

    I have been sitting at this problem for over a month now, and have no idea what I am doing wrong here.
    Pls help.

    • Like 1

  10. Hello,

    I am playing ArmA as military simulator since 2011.

    My ingame hours I did never count but putting them all together: something around 1000 hours would fit I guess considering the fact that I played nearly every day or every second at least 2 hours.

    In the past years I focused on the following roles: Medic [Likely the role I did spend the most time in back until '11](FT-CLS up to COY-Level Logistics), I started 1 year ago to practice the work of a JTAC (Sadly I never had the chance to take a course on that topic at the community [us time zone] I played at, so I had to learn everything by myself. Worth the trouble. I might gained sum rust as I did not JTAC in the past 2 months), I did in fact lead sometimes from PL position or 2IC and took quiet a lot courses on these topics but I stoped leading as soon as the overall ability to execute simple orders as well as to maintain simple individual infantry combat skills vanished from the playerbase; leading ended up to be frustrating to the core and I knew to spend my time better as to go angry about some idiots and their damn excuses.

    What do I expect:

    As I played at multiple multigaming communitys and I had no luck with them I now search for a place with a set and mature playerbase. People should know what they are doing. Greeting some sandbacks with 'sir' whenever they enter a TS-channel or take a piss near the spawning area is a no-go. I am willing to start from 0 if necessarry. Actually I would like to start from 0. The server should not be public; that means: not every troll is able to enter the playerbase to then lower the overall gameplay quality. I had enough of such places.

    If there is any European time zone place offering such: please pm me.

    - Seemax

×