Search the Community
Showing results for tags 'training targets'.
Found 1 result
-
bisobjectbug add(MP)EventHandler not working on Dedicated Server
PaxJaromeMalues posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
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.- 46 replies
-
- 1