code34 248 Posted January 9, 2019 cause 3ms is dedicated to script execution and around 13 ms is dedicated for the other part of calculation (graphic part etc) to create a frame average of 60fps/s(it s an average calculation) while the schedule code execution major with unscheduled code go over the 3ms it impacts the performance of the game, cause the calculation of the frame will go over the 16ms. Just for memo, BIS added scheduler to fix definitively bad user code that have negative impact on game . After this, when you use unschedule code you may know what it does, and at your own risk. 1 Share this post Link to post Share on other sites
killzone_kid 1330 Posted January 9, 2019 3 hours ago, pierremgi said: who decided? A programmer who designed the scheduler 3 hours ago, pierremgi said: why this slot? 3 is very common number, it exists in folklore of many nations 3 hours ago, pierremgi said: is it still the best choice? It wasn't the best choice even then Share this post Link to post Share on other sites
Dedmen 2691 Posted January 10, 2019 15 hours ago, pierremgi said: It's a simple general consideration about engine. I mean nothing should be definitive. CPUs evolve. True. Modern CPU's can now execute more code in these 3ms as old CPU's. If anything, the limit would be shortened by modern CPUs It was chosen based on the expected fps the devs wanted. Averaging out all the other stuff done in a fame, they looked how much spare time they can dedicate while not letting the fps drop too far 15 hours ago, code34 said: Just for memo, BIS added scheduler to fix definitively bad user code that have negative impact on game . After this, when you use unschedule code you may know what it does, and at your own risk. +1. I'd say people should only use unscheduled if they know what they are doing. And if they do know what they are doing unscheduled has quite a few benefits. But can be very detrimental if you don't know what you are doing. Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted January 12, 2019 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. Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted January 13, 2019 (edited) 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 Edited January 13, 2019 by Pax_Jarome dun fucked up Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted January 13, 2019 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. Share this post Link to post Share on other sites
pierremgi 4850 Posted January 14, 2019 On each init of swivel target: 0 = this spawn {waitUntil {!isNil {_this getVariable "BIS_exitScript"} && {!(_this getVariable "BIS_exitScript")}}; if !(isServer) then {_this setVariable ["BIS_exitScript",true]}}; This way, the script will run only on server (where target is). Tested on hosted one. Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted January 14, 2019 12 hours ago, pierremgi said: On each init of swivel target: 0 = this spawn {waitUntil {!isNil {_this getVariable "BIS_exitScript"} && {!(_this getVariable "BIS_exitScript")}}; if !(isServer) then {_this setVariable ["BIS_exitScript",true]}}; This way, the script will run only on server (where target is). Tested on hosted one. will test tomorrow, thanks! Share this post Link to post Share on other sites
Dedmen 2691 Posted January 15, 2019 On 14.1.2019 at 2:32 AM, pierremgi said: !isNil {_this getVariable "BIS_exitScript"} && {!(_this getVariable "BIS_exitScript")} Can be combined into !(_this getVariable ["BIS_exitScript", true]) But why are you exiting when exitScript is false? Seems opposite of what it logically should be. Share this post Link to post Share on other sites
pierremgi 4850 Posted January 15, 2019 6 hours ago, Dedmen said: Can be combined into !(_this getVariable ["BIS_exitScript", true]) But why are you exiting when exitScript is false? Seems opposite of what it logically should be. No, that can't be combined. here... && {!(_this getVariable "BIS_exitScript")} is not checked before the variable is not nil (the { } acts as inner scope). If you do that, you automatically set the variable to true by default, then you don't wait for the initialization of the script. You have to wait for the variable not nil. That means, you're at it for the init of the target. The BIS_exitScript is false as long as it runs. So, here, you wait until it just starts. And you stop it everywhere except on server, with BIS_exitSript true. Share this post Link to post Share on other sites
killzone_kid 1330 Posted January 15, 2019 6 hours ago, pierremgi said: you automatically set the variable to true by default This is not how it works at all. You are not setting any variable, you are providing default value when the variable is nil. Dedmen is correct, you are incorrect. Share this post Link to post Share on other sites
pierremgi 4850 Posted January 16, 2019 1 hour ago, killzone_kid said: This is not how it works at all. You are not setting any variable, you are providing default value when the variable is nil. Dedmen is correct, you are incorrect. At least I provided a working code... I didn't realize that, because it's possible to work with the default value as you could do with a set variable (in the same scope?). It's weird to see at the same time, on debug console, during a mission preview: isNil {myExistingObject getVariable "anyNewVar"} returning true and myExistingObject getVariable ["anyNewVar",20] returning 20 So, the Value to return if variable doesn't exist, as BIKI says, was confusing for me. Perhaps worth some deeper explanation about how it works.... Not sure every people on forum can make a difference between: - providing a default value (for any script in due nameSpace or within scope?, if my English is OK) - and setting a variable (global here, missionNameSpace by default). Share this post Link to post Share on other sites
Dedmen 2691 Posted January 18, 2019 On 16.1.2019 at 1:17 AM, pierremgi said: Perhaps worth some deeper explanation about how it works.... Not sure every people on forum can make a difference between: - providing a default value (for any script in due nameSpace or within scope?, if my English is OK) - and setting a variable (global here, missionNameSpace by default). Deeper explanation of how it works? What kind of deeper explanation do you need than "default value in case variable is undefined" ? I guess your english is not okey as I don't understand what you mean there. You want to know how to set a variable? variableName = newValue or namespace setVariable ["variableName", newValue] Maybe this helps you, you can express what getVariable with default value does in script. _result = missionNamespace getVariable ["test", true]; is equal to _result = if (isNil "test") then {true} else {missionNamespace getVariable "test"} On 14.1.2019 at 2:32 AM, pierremgi said: !isNil {_this getVariable "BIS_exitScript"} && {!(_this getVariable "BIS_exitScript")} This was your code. Let's split it up a bit. if (!isNil {_this getVariable "BIS_exitScript"}) then { !(_this getVariable "BIS_exitScript") } else { false }; On 15.1.2019 at 10:21 AM, Dedmen said: !(_this getVariable ["BIS_exitScript", true]) Here is my code if (isNil {_this getVariable "BIS_exitScript"}) then { !true //default value here } else { !(_this getVariable "BIS_exitScript") }; Or let's switch it around so you can read it better if (!isNil {_this getVariable "BIS_exitScript"}) then { !(_this getVariable "BIS_exitScript") } else { !true }; Can you see it now? Exactly the same. Btw namespace is one word. Not name space. Share this post Link to post Share on other sites
pierremgi 4850 Posted January 19, 2019 Oh you know, that didn't worth so much lines! I resume the added value: Maybe this helps you, you can express what getVariable with default value does in script. _result = missionNamespace getVariable ["test", true]; is equal to _result = if (isNil "test") then {true} else {missionNamespace getVariable "test"} Perhaps... My remark was more about the scope around the 2nd parameter (optional) of getVariable. I know you can write: myGlobalResult = missionNameSpace getVariable ["test",true] to make it work as global variable. But sometimes, you're tempted to write only: (missionNameSpace getVariable ["test",true]) in a script. In this case, we can say that, if there is not yet defined "test" variable on missionNameSpace, everything works as if you passed a local variable with the 2nd optional arguments in the array. It was not so evident because the set/getVariable is usually global (can be even public with 3rd optional parameters), and suddenly, you fall into a local scope with no warning on documentation. That's probably normal and evident for skilled people, but I think that worth a line on BIKI. NOTA: 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. Share this post Link to post Share on other sites
killzone_kid 1330 Posted January 19, 2019 6 hours ago, pierremgi said: But sometimes, you're tempted to write only: (missionNameSpace getVariable ["test",true]) in a script. This statement doesn’t do anything, not sure why are you tempted to write it. Bottom line is, the existing documentation is sufficient and explanatory of how this command works already. 1 Share this post Link to post Share on other sites
pierremgi 4850 Posted January 19, 2019 Really? Alternative Syntax: varspace getVariable [name, defaultValue] Return Value: Anything - current value of the variable or defaultValue if the variable doesn't exist. Just add in BIKI: this default value is not global but local. Fast example. Not the best writing, but something possible if you make the mistake to think the first script has set the variable (like I did). There is no real wrong code. Just an abuse of what the default value is. (I'm still wonder why a real global setting couldn't be done instead of this default value...). [] spawn { while {true} do { if ( someUnit getVariable ["food",0] <10) then { someUnit execVM "someScript.sqf"; }; }; }; in someScript.sqf, some line like: _heath = getStamina someUnit * (someUnit getVariable "food"); // returns an error. Let's say normal but surprising. Share this post Link to post Share on other sites
killzone_kid 1330 Posted January 19, 2019 51 minutes ago, pierremgi said: Just add in BIKI: this default value is not global but local. No. This won’t improve it but confuse the hell out of people. Default value is neither local nor global it is what it is the DEFAULT value returned by the getVariable command if variable is not defined. 1 Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted January 24, 2019 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 Share this post Link to post Share on other sites
Dedmen 2691 Posted January 24, 2019 On 19.1.2019 at 9:35 AM, pierremgi said: Just add in BIKI: this default value is not global but local. But it isn't. That has nothing to do with global or local at all. On 19.1.2019 at 9:35 AM, pierremgi said: Just an abuse of what the default value is. Abuse? no... That's exactly how it's indended to be used. On 19.1.2019 at 9:35 AM, pierremgi said: Let's say normal but surprising. Not if you read the wiki https://community.bistudio.com/wiki/getVariable Quote Return Value: Anything or Nothing if the variable doesn't exist Variable doesn't exist -> it returns nothing(nil) What did you expect previously? that GETvariable will set a variable if it's undefined? that's not very logical. A getter shouldn't set something. 2 Share this post Link to post Share on other sites
pierremgi 4850 Posted January 24, 2019 OK. Some people decided to use the getter to throw a value for a nil variable (that's so much logic), just in case, but it's forbidden to dream this value could be used as the named variable since then. No problem. Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted January 29, 2019 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 Share this post Link to post Share on other sites
PaxJaromeMalues 22 Posted February 7, 2019 Reported https://feedback.bistudio.com/T136751 Share this post Link to post Share on other sites