Crielaard 434 Posted April 6, 2014 (edited) I have completed an airburst script which affects it's surrounding as per real life 'REDs'. I can add the airburst funtion to an aircraft so all specified bomb types will airburst by putting this in the init line: 'This addeventhandler .......' anf that works fine. However I want the pilot to turn this function On and off. Placing this in an AddAction somehow doesnt work. Been searching google and the forum for days now! :-( Edited April 6, 2014 by 87th_Neptune Share this post Link to post Share on other sites
lordheart 1 Posted April 6, 2014 Do you add the addAction to the plane? If so, within an addAction, _this will be the unit that activated the addAction and _target will be the object the AddAction is attached to. Share this post Link to post Share on other sites
Crielaard 434 Posted April 6, 2014 Thanks didnt know that. So far I have this in the init line: this addAction ["Set airburst fuse", {_target addEventHandler ["fired",{_target execVM "airburst\airburst.sqf"}]}]; Which is not working Share this post Link to post Share on other sites
lordheart 1 Posted April 6, 2014 Try the following: this addAction ["Set airburst fuse", {(_this select 0) addEventHandler ["fired",{(_this select 0) execVM "airburst\airburst.sqf"}]}]; Share this post Link to post Share on other sites
Crielaard 434 Posted April 6, 2014 YES that did it! Thanks!!! Now...can you explain the 'select 0' part. Ofcourse I know what the command does but what can you find in the 0 indec of the _this array?? Share this post Link to post Share on other sites
igneous01 19 Posted April 6, 2014 YES that did it!Thanks!!! Now...can you explain the 'select 0' part. Ofcourse I know what the command does but what can you find in the 0 indec of the _this array?? its the arguments the event sends to the handler. it looks like this: [player, player, 0]; // player activated the action, player owns the action, 0 is the id of the action in the player (the first addaction) so by doing (_this select someNumber) you are fetching those arguments from the array Share this post Link to post Share on other sites
lordheart 1 Posted April 6, 2014 https://community.bistudio.com/wiki/addAction Check under Parameters -> Script -> Parameters https://community.bistudio.com/wiki/ArmA_3:_Event_Handlers#Fired Share this post Link to post Share on other sites
Crielaard 434 Posted April 6, 2014 Thanks to both. :) Share this post Link to post Share on other sites
Crielaard 434 Posted April 9, 2014 (edited) Right... So the above worked but now I have put the above in an add action. It works basically. I just stumble into an anomally I can not understand. There are two scripts running here: 1. A "fired" event handler with ID "JDAM"to for a JDAM simulation if a jdam type bomb is released. This is just placed in the init line. And works perfectly on it's own. 2. The script from this thread initialised with an execVM in the initline aswell. The script creates two actions "set airburst fuse" which invokes the event handler "fired" with ID "AIRBURST". The other action simply does: removeeventhandler ["fired", AIRBURST]. The anomally is that I have to Activate the airburst now for the JDAM eventhandler to work. Edited April 9, 2014 by 87th_Neptune Share this post Link to post Share on other sites