pvtdancer 5 Posted March 21, 2014 Hey guys, I'm still new at scripting but for the most part I've been able to get along pretty well but for the life of me I can't get "addaction" to work in a script. I've been working off of the wiki and off of other scripts that call addaction in themselves and have had no luck, the action never appears in or out of the vehicle. In the future I want this script to apply to only certain heli's but for now I just want the add action to show up at all on all of them lol. Here is my script I'm running which works great in when the addaction line is added to the init of the vehicle, so the script is working. private ["_heli", "_grp"]; // lets set some local variables _heli = _this select 0; _grp = _this select 1; _chuteType = "Steerable_Parachute_f"; //parachute type _player = _this; _HQ = [West,"HQ"]; { player action ["Eject", vehicle player]; sleep 0.5; } forEach (units player); _chute = createVehicle [_chuteType, [100, 100, 200], [], 0, 'FLY']; _chute setPos [getPosASL _heli select 0, getPosASL _heli select 1, (getPosASL _heli select 2) - 35]; _grp moveInDriver _chute; waitUntil {(position _grp select 2) < .7}; Thanks in advance. Share this post Link to post Share on other sites
Ghost 40 Posted March 21, 2014 How are you adding it in the script? Share this post Link to post Share on other sites
pvtdancer 5 Posted March 21, 2014 (edited) The line I was trying to use was player addAction["<t color='#ffff00'>"Eject"</t>", [], -1, false, false,]; Now I've also tried variations of this and other types but mostly something similar to this. I even tried adding an init.sqf then doing addaction and call the script from there but had no luck. I'm not really sure if its easier\better to create the action from within the same script or call it from an init or other .sqf file. Edited March 21, 2014 by PvtDancer Share this post Link to post Share on other sites
Ghost 40 Posted March 21, 2014 The line I was trying to use was player addAction["<t color='#ffff00'>"Eject"</t>", [], -1, false, false,]; Now I've also tried variations of this and other types but mostly something similar to this. ok, so what script is that Addaction using because you are not telling it. Also where is that line being called? Share this post Link to post Share on other sites
pvtdancer 5 Posted March 21, 2014 So this line is being added as the last line of my script as that's what I've seen done on other working scripts, so when I've been adding it the script has then looked like. private ["_heli", "_grp"]; // lets set some local variables _heli = _this select 0; _grp = _this select 1; _chuteType = "Steerable_Parachute_f"; //parachute type _player = _this; _HQ = [West,"HQ"]; { player action ["Eject", vehicle player]; sleep 0.5; } forEach (units player); _chute = createVehicle [_chuteType, [100, 100, 200], [], 0, 'FLY']; _chute setPos [getPosASL _heli select 0, getPosASL _heli select 1, (getPosASL _heli select 2) - 35]; _grp moveInDriver _chute; waitUntil {(position _grp select 2) < .7}; player addAction["<t color='#ffff00'>"Eject"</t>", [], -1, false, false,]; Share this post Link to post Share on other sites
kahna 13 Posted March 21, 2014 That's not how you use addactions though. First you have to tell the action, in this case 'Eject' what to do with itself (what script or action to run) this addAction["<t color='#ff1111'>Eject</t>", "Eject.sqf"]; Second, your script just runs through a sequence of commands to do a parachute eject from an aircraft, but where is the script actually being called from initially? Ideally you would have the addaction and the accompanying script called from the vehicle's INIT line in which case you wouldn't need the addaction in the script itself, especially at the end after everything is complete (parachuting through the air) and there is nothing to eject from. Share this post Link to post Share on other sites
pvtdancer 5 Posted March 21, 2014 So even if the addaction is in the script that is going to be ran. You have to set the action to call the script externally? I guess I figured that since I was putting this in the script it would all be self contained. Plus the examples I worked off of looked like player addAction["<t color='#ffff00'>"+STR_TOSS_ROPES+"</t>", zlt_fnc_createropes, [], -1, false, false, '','[] call zlt_fnc_ropes_cond']; Of course in this case he was calling functions in the script. Share this post Link to post Share on other sites
fight9 14 Posted March 21, 2014 That works because STR_TOSS_ROPE is defined as a string (""). Look at the top of the script and you should see #Define STR_TOSS_ROPE "Text" Share this post Link to post Share on other sites
pvtdancer 5 Posted March 21, 2014 So then. In my current scripts state. I would have to alter it so that it would look like private ["_heli", "_grp"]; #define eject "Eject" // lets set some local variables _heli = _this select 0; _grp = _this select 1; _chuteType = "Steerable_Parachute_f"; //parachute type _player = _this; _HQ = [West,"HQ"]; player_eject = { player action ["Eject", vehicle player]; sleep 0.5; forEach (units player); _chute = createVehicle [_chuteType, [100, 100, 200], [], 0, 'FLY']; _chute setPos [getPosASL _heli select 0, getPosASL _heli select 1, (getPosASL _heli select 2) - 35]; _grp moveInDriver _chute; waitUntil {(position _grp select 2) < .7};}; player addaction["<t color='#ffff00'>"+eject+"</t>", player_eject, [], -1, false, false,]; I'm sure there are some formatting issues but is that kind of how that would have to work? Share this post Link to post Share on other sites
fight9 14 Posted March 21, 2014 It should look like this: private ["_heli", "_grp","_chute"]; #define eject "Eject" player_eject = { // lets set some local variables _heli = _this select 0; // vehicle/unit addaction is attached to _grp = _this select 1; // Caller - player unit _chuteType = "Steerable_Parachute_f"; //parachute type { _x action ["Eject", vehicle player]; sleep 0.5; } forEach (units player); _chute = createVehicle [_chuteType, [100, 100, 200], [], 0, 'FLY']; _chute setPos [getPosASL _heli select 0, getPosASL _heli select 1, (getPosASL _heli select 2) - 35]; _grp moveInDriver _chute; waitUntil {(position _grp select 2) < .7}; }; heliName addaction["<t color='#ffff00'>"+eject+"</t>", player_eject, [], -1, false, false,]; for the heli to be "_this select 0", you have to attach the addaction to the heli. The player/unit who uses the action, becomes "_this select 1". I cleaned up your script and corrected a few things. Namely, your forEach loop and a few other minor things. Share this post Link to post Share on other sites
pvtdancer 5 Posted March 21, 2014 Wow, thanks a lot. So if I understand you right at this point if I call this script in the mission's init.sqf the action should be attached to any heli that's spawned in? Sorry if its a stupid question I'm doing my best at learning all this. thanks again for all your help I really appreciate it. I'm working on this massive mission and trying to get all the features I want is a large task lol. Share this post Link to post Share on other sites
fight9 14 Posted March 21, 2014 No, only the heli with the name "heliname". If you need it to be applied to every heli, I'll write something up for you later after work. If you want to start researching, use the nearest object command to find the heli closest to the player. Share this post Link to post Share on other sites
pvtdancer 5 Posted March 21, 2014 ok cool. Yeah the intention was either all heli's or define it by the heli names. so that for instance only the mohawk and the ghost hawk classed heli's would get the script. Reason being when in a large long mission I'm planning on atleast 3 - 4 heli's and a heli might get destroyed and loose the name and the INIT line. There are some respawn scripts that allow you to keep the init line but because I'm trying to keep a color on the scripted eject line it doesn't work as intended or at all. I've seen some scripts that have lines like _heli = [i_Heli_Transport_02_F,B_Heli_Transport_01_F] To classify what exactly was used in the script. Would something like that work in this case? Again thanks for you help I really appreciate it. Share this post Link to post Share on other sites