patpowercat 7 Posted May 8, 2016 I am having some trouble with getting a script to work. It creates a group array which respawns your dead AI squad members in a helicopter which flies to your position to insert them. It's based of a radio trigger. I have input it in a mission which works great with single player, as well as testing multiplayer from the Eden editor. However, once uploaded to my local TADST dedicated server, the script spawns two helicopters on top of each other, which of course crash and fall to the ground. Here is the script: // SET LOCAL VARIABLES SCOPEprivate ["_helo","_unit","_hPad","_heloWp"];// CREATE THE HELO AND HPAD._helo = [getMarkerPos "Mk1", markerDir "Mk1", "B_Heli_Transport_01_F", WEST] call bis_fnc_spawnVehicle;_hPad = "Land_HelipadEmpty_F" createVehicle ( position player );// CHECK THE GROUP AND REPLACE DEAD UNITS. MOVE THEM INTO THE HELO'S CARGO{if ( ! ( alive ( _x select 0 ) ) ) then {_unit = ( ALPHA ) createUnit [ ( _x select 1 ), getMarkerPos "Mk1", [], 0, "NONE" ]; _unit moveInCargo ( _helo select 0 );};} forEach grpArray;// RESET THE ARRAYgrpArray = [];{ grpArray pushBack [ _x, ( typeOf _x ) ];} forEach units ALPHA;// GIVE THE HELO A WAYPOINT AT THE HPAD'S POSITION (PLAYER POS)_heloWp = ( _helo select 2 ) addWaypoint [_hPad, 0];_heloWp setWaypointType "MOVE";_heloWp setWaypointBehaviour "CARELESS";_heloWp setWaypointCombatMode "BLUE";_heloWp setWaypointSpeed "FULL";_heloWp setWaypointStatements ["true", "(vehicle this) LAND 'LAND';"];// WAIT UNTIL THE HELO IS TOUCHING THE GROUND OR CAN'T MOVE (SHOT DOWN / WRECK) ANDD EJECT THE UNITSwaitUntil {isTouchingGround (_helo select 0) || { !( canMove ( _helo select 0 ) ) } };{ unAssignVehicle _x; _x action ["eject", ( vehicle _x )]; sleep 1;} forEach units ALPHA; //WAITUNTIL THERE'S NO ALIVE GROUP MEMBERS IN THE HELO AND GIVE THE HELO A NEW WAYPOINT WHERE IT WILL BE DESTROYEDwaitUntil { { !( alive _x ) || { !( _x in ( _helo select 0 ) ) } } count ( units ALPHA ) == count ( units ALPHA ) }; _heloWp = ( _helo select 2 ) addWaypoint [[0,0,0], 0];_heloWp setWaypointType "MOVE";_heloWp setWaypointBehaviour "AWARE";_heloWp setWaypointCombatMode "RED";_heloWp setWaypointSpeed "FULL";_heloWp setWaypointStatements ["true", "{deleteVehicle _x;} forEach crew (vehicle this) + [vehicle this];"]; // DELETE THE EMPTY H-PADdeleteVehicle _hPad; The group array is established in init.sqf with this grpArray = [];{ grpArray pushBack [ _x, ( typeOf _x ) ];} forEach units ALPHA (Alpha being the group). Note: The credit for this script goes to Iceman77 Any ideas as to why this is occurring? Does the script need to modified to use if isServer perhaps? PS: There is an example mission here, again credit to Iceman77 Share this post Link to post Share on other sites
das attorney 858 Posted May 8, 2016 You're on the money there. If (not isServer) exitWith {}; ..at the top of the script will stop multiple computers from running it. You will need to address this following line though as there will be no player on a Dedi Server: _hPad = "Land_HelipadEmpty_F" createVehicle ( position player ); An easy way to do it would be to name your player in the editor (like player1 or similar) and then change the line to: _hPad = "Land_HelipadEmpty_F" createVehicle (position player1); Hope that helps. Share this post Link to post Share on other sites
celludriel 79 Posted May 9, 2016 An easy way to do it would be to name your player in the editor (like player1 or similar) and then change the line to: _hPad = "Land_HelipadEmpty_F" createVehicle (position player1); Couldn't he call the script with remoteExec and pass the location of the player towards it ? The script only runs on the server anyhow , so he might as well pass his local location to it on the server ? Share this post Link to post Share on other sites
patpowercat 7 Posted May 9, 2016 Couldn't he call the script with remoteExec and pass the location of the player towards it ? The script only runs on the server anyhow , so he might as well pass his local location to it on the server ? What would the syntax for this be? I tried replacing the execVM on the trigger with what I thought would be syntax from here, but nothing happened. Sorry still pretty new to the whole editing and scripting thing. Share this post Link to post Share on other sites
patpowercat 7 Posted May 9, 2016 You're on the money there. If (not isServer) exitWith {}; ..at the top of the script will stop multiple computers from running it. You will need to address this following line though as there will be no player on a Dedi Server: _hPad = "Land_HelipadEmpty_F" createVehicle ( position player ); An easy way to do it would be to name your player in the editor (like player1 or similar) and then change the line to: _hPad = "Land_HelipadEmpty_F" createVehicle (position player1); Hope that helps. Worked perfectly! Thank you so much, been trying to figure that out for a week. 2 quick other questions: 1) What would the syntax be to make the _hPad just a bit away from me (any direction) so the helicopter doesn't come down RIGHT on top of me? I tried (position player1), [0,10,0], but that didn't work. (position player1), 10, makes it come down, stop 10meters up, and fly away. 2) Any idea how to set the group's inventory so when they respawn they come back with weapons they had at start? I change the arsenal in the editor, but on spawn they have default class gear. Thanks again! Share this post Link to post Share on other sites
das attorney 858 Posted May 9, 2016 Hey, glad all went well. 1 - you can use alt syntax on getPos command, so something like: _randomPos = player1 getPos [20 + (random 20),random 360]; (That would pick a point between 20 and 40 meters away from player1 in a random direction). 2 - I would guess that you can add a respawn eventhandler to the units, which would launch a gear script from there. Check here: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Respawn As a note: If you add the EH in the init box, be aware to make it only fire locally on the players machine (a bit like your isServer thing above) otherwise all PC's will run it (with highly likely strange results). So something like this: this addEventHandler ["respawn",{if (local (_this select 0)) then {_this call myGearFunction}}]; Share this post Link to post Share on other sites
patpowercat 7 Posted May 9, 2016 Ok thanks I'll check it out. One last thing, how could I not include myself in the grpArray? If I die, I respawn already, but then when I run the script, there is another of me that spawns as well because I'm in the group. Share this post Link to post Share on other sites
das attorney 858 Posted May 9, 2016 Check for isPlayer - ex: _myarray = []; {if (not isplayer _x) then {_myarray pushback _x}} forEach someUnits Share this post Link to post Share on other sites
patpowercat 7 Posted May 9, 2016 Un-including the player from the array was successful, but I can't get the gear respawn to work. I have tried both this addEventHandler ["respawn", "_this execVM 'loadout.sqf'"]; and this addEventHandler ["respawn",{if (local (_this select 0)) then {_this call "loadout.sqf"}}]; Is it perhaps because in the original grpArray PushBack calls of a typeOf _x rather than specifying the specific unit/variable? I have named the units individually as well, but still no success. Share this post Link to post Share on other sites
celludriel 79 Posted May 10, 2016 What would the syntax for this be? I tried replacing the execVM on the trigger with what I thought would be syntax from here, but nothing happened. Sorry still pretty new to the whole editing and scripting thing. Suppose your script is called heliscript.sqf, [player, "heliscript.sqf"] remoteExec ["execVM", 0, false]; this would run heliscript.sqf on the server (ok and all clients in this case but you can use if(!isServer) exitWith {};) it's the equivalent of running player execVM "heliscript.sqf" on the server manually instead of callin it by remote. Even better would be to make it a function in a function library then you could write something like [player] remoteExec ["LIBNAME_fnc_heliscript", 0, false]; Share this post Link to post Share on other sites