Jump to content
Sign in to follow this  
thestuntman

Passing parameters in a unit init to an Event Handler

Recommended Posts

say for example i have a script which is passed parameters in the usual way "nul = [[arty1,arty2,arty3],3,20,3,1] execVM "arty_smoke_test.sqf";"

and these are grabbed in the script using

_myBattery = _this select 0;

_delay = _this select 1;

_spread = _this select 2;

_loop = _this select 3;

......

Is it possible to then reference these values with _idx = player addEventHandler ["Fired", {.... further in the same script?

From what I have tried the event handler knows nothing about these values. Am I going about this the wrong way or is there a way to have these values passed to the event handler without making them globals?

What i am trying to do is get the position of a smoke grenade, then call in a mortar strike on that position.

I am able to do it just fine using ((position player) nearObjects["SmokeShell",150]), but the only problem is that it will pick up anyone's smoke grenade within whatever radius I have set.

The reason i wanted to use event handlers is that it will confine the strike to just the player's grenades, and make it easy to remove the event handler whenever i don't want the ability to be available.

Share this post


Link to post
Share on other sites

I assume you have event handler in arty_smoke_test.sqf script?

_myBattery = _this select 0;
_delay = _this select 1;
_spread = _this select 2;
_loop = _this select 3;
// ......
artyargs = _this;
_idx = player addEventHandler ["Fired", {
_myBattery = artyargs select 0;
_delay = artyargs select 1;
_spread = artyargs select 2;
_loop = artyargs select 3;
//........
}];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×