fathersarge 46 Posted January 30, 2017 So I'm using this script to randomize popup targets on multiple lanes on my shooting range (this is the .sqf) This is what does in the control station (laptop) init, where # is the lane (separate sqfs for each lane), delayTime is 2 (seconds), randomize is true, and display is false ////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: FoxRazgriz/SSgt Schirf // Version: 1.0 ////////////////////////////////////////////////////////////////// // ***** USABILITY ***** // Example Use: controlLaptop addAction["Sequence 1 Targets","popup_sequence.sqf",[[target_1,target_2,target_3],1,false,true]]; // Use Format: controlStationName addAction["Action Title","popup_sequence.sqf",[[tar1, tar2, tar3],delayTime,randomize,display]]; // WHERE: // - controlStationName (object variable name) is the variable name of your control station (laptop, flag pole, etc.) // - tar1, tar2, tar3 (array of objects) are the variable names of the targets in the sequence of targets to be popped // - delayTime (integer) how long (in seconds) the script will wait between popping the first set of targets and the second set // - randomize (boolean) is whether or not the targets will pop up in a random order or in the order in which they are given // - display (boolean) is whether or not you want a hint displayed telling you how many targets have been flipped // BE ADVISED: This script can only be used one at a time. I.E. Only one sequence style pop up script can be running at a time, due to the presence of global variables. // ***** ADDITIONAL INFORMATION ***** // None // ***** ADD THIS CODE TO THE INIT OF EVERY POP-UP TARGET YOU WANT TO BE DOWN ***** // this animate["terc",1] // ***** RESET YOUR TARGETS ***** // Use the following code block in order to reset all your targets to the "down" position //{ // _x setDamage 1; // _x animate["terc",1]; //} foreach [tar_1, tar_2, tar_3]; // ***** SCRIPT FORMAT ***** // 1. Get the following info from parameters: // 1a. List of targets // 1b. Delay Time (in seconds) // 1c. Randomize Y/N // 1c. Diplay Y/N // 2. If randomize is false (the targets should be popped in order) // 2a. For every target in the array, one at a time (since it's in order, there will be no duplicates) // 2b. Pop, then wait until that target is down, using an event handler and global variable as a trigger // 2c. If display is true, display which target it is (and the delay?) // 2d. If display is true, display when the sequence is complete // 3. If randomize is true (the targets should be popped in a random order) // 3a. For each entry in the selection list, chose one target at random, then add it to a second array // 3b. For each target in the new array, one at a time (since it's NOW in order, there will be no duplicates) // 3c. Pop, then wait until the target is down, using an event handler and global variable as a trigger // 3d. If display is true, display which target it is (and the delay?) // 3e. If display is true, display when the sequence is complete // ***** UPCOMING CHANGES ***** // - Add randomness option to delay time // - Add ability for free-fire mode, where all targets are standing // - Make more black box & optimize // - Add feature for monitoring how many targets are in play/where they are // Check to make sure this script is executed on the server ONLY if (!isServer) exitWith {}; // Ensure the targets do not pop up again once shot nopop = true; // Step 1a _selection = _this select 3 select 0; // Gets the first element in the list (list is at index 3), should be array of targets // Step 1b _delayTime = _this select 3 select 1; // Gets the second element in the list (list is at index 3), should be an integer // Step 1c _randomize = _this select 3 select 2; // Gets the third element in the list (list is at index 3), should be a boolean // Step 1d _display = _this select 3 select 3; // Gets the third element in the list (list is at index 3), should be a boolean // Step 2 if (!_randomize) then { // Step 2a for "_i" from 0 to (count _selection) - 1 do { GLOBALVAR1_HIT = false; sleep _delayTime; // Step 2b _selection select _i addEventHandler ["Hit", {GLOBALVAR1_HIT = true}]; _selection select _i setDamage 0; _selection select _i animate ["terc",0]; // Step 2c if (_display) then { hint format ["Target: %1\nDelay: %2", _selection select _i, _delayTime]; }; waitUntil{GLOBALVAR1_HIT}; _selection select _i removeEventHandler ["Hit", 0]; }; // Step 2d if (_display) then { hint "Sequence complete"; }; } // Step 3 else { _random = count _selection; _targets = []; // Step 3a while {_random > 0} do { _target = _selection call BIS_fnc_selectRandom; while {_target in _targets} do { // Ensure no duplicates _target = _selection call BIS_fnc_selectRandom; }; _targets append [_target]; _random = _random - 1; }; // Step 3b for "_i" from 0 to (count _targets) - 1 do { GLOBALVAR1_HIT = false; sleep _delayTime; // Step 3c _targets select _i addEventHandler ["Hit", {GLOBALVAR1_HIT = true}]; _targets select _i setDamage 0; _targets select _i animate ["terc",0]; // Step 3d if (_display) then { hint format ["Target: %1\nDelay: %2", _targets select _i, _delayTime]; }; waitUntil{GLOBALVAR1_HIT}; _targets select _i removeEventHandler ["Hit", 0]; }; // Step 3e if (_display) then { hint "Sequence complete"; }; }; this addAction["Randomize Targets","popup#_sequence.sqf",[[tar1, tar2, tar3],delayTime,randomize,display]]; My problem is it doesn't work on multiplayer. It works fine when I run it solo, the lanes function independently as one would expect but it is non-functioning on a server. The randomization doesn't even start, all the targets remain in the down position. Any help in this one would be great! Share this post Link to post Share on other sites
fathersarge 46 Posted February 1, 2017 So in my attempt to fix this, I have 5 separate .sqfs (1-5) with the corresponding GLOBALVAR_HIT changed to GLOBALVAR1-5_HIT But that unfortunately doesn't work on multiplayer either. Anyone have any ideas? Even if it's just to scrap this entire thing and go with another script? Share this post Link to post Share on other sites
rebel12340 46 Posted February 3, 2017 Your original post doesn't seem to contain the entire script from what I can tell, unless I'm missing something. Share this post Link to post Share on other sites
fathersarge 46 Posted February 4, 2017 Quite right. Didn't want to overwhelm the post but, what the heck? Edited the original post so it has the full script On 2/2/2017 at 5:28 PM, rebel12340 said: Your original post doesn't seem to contain the entire script from what I can tell, unless I'm missing something. Share this post Link to post Share on other sites
Lucullus 71 Posted February 4, 2017 The targets are not local in MP so the EH will not work. Edit: Oh, saw this: if (!isServer) exitWith {}; This script works only on ServerClient, didn't work on Client or Dedicated. Switch to MPEventHandler and run the script Clientside. Share this post Link to post Share on other sites
BlacKnightBK 47 Posted February 4, 2017 Would you mind telling me where is the file called? Share this post Link to post Share on other sites
rebel12340 46 Posted February 4, 2017 Just throwing a guess out here, but I THINK that the issue may be that you're using addaction to execute the script, which only executes scripts locally. So, if you have a player who isn't the host in multiplayer try and use the action the script won't run because the player isn't the server. What you could do is execute the script from a trigger that is activated via radio Alpha and see if that works. nul = [[tar1, tar2, tar3],delayTime,randomize,display] execvm "popup_sequence.sqf"; Though, if you do that you'll have to edit some of the first few lines of the script where it sets the variables otherwise it won't work // Step 1a _selection = _this select 0; // Gets the first element in the list (list is at index 3), should be array of targets // Step 1b _delayTime = _this select 1; // Gets the second element in the list (list is at index 3), should be an integer // Step 1c _randomize = _this select 2; // Gets the third element in the list (list is at index 3), should be a boolean // Step 1d _display = _this select 3; // Gets the third element in the list (list is at index 3), should be a boolean Alternatively you may just be able to get rid of the "if (!isServer)" line at the top of the script and call it with the addaction as normal. Not sure if there's a specific reason that it HAS to be called on the server or not. Share this post Link to post Share on other sites