Jump to content
Sign in to follow this  
canadian1337

Problem with a GetIn event handler.

Recommended Posts

Soo I wanted to create a NV system that is built into the helicopter (Vietnam War era) by creating an event handler that adds and assigns the NVG when someone is entering the pilot seat and removing when exiting the vehicle.
I've come up with the code below but sadly it doesn't work. The event handler is placed in the init field of the helicopter.

this addEventHandler ["GetIn", { _unit = _this select 0; _unit additem "NVGoggles";_unit assignitem "NVGoggles";}];

 

Share this post


Link to post
Share on other sites
2 minutes ago, canadian1337 said:

Soo I wanted to create a NV system that is built into the helicopter (Vietnam War era) by creating an event handler that adds and assigns the NVG when someone is entering the pilot seat and removing when exiting the vehicle.
I've come up with the code below but sadly it doesn't work. The event handler is placed in the init field of the helicopter.


this addEventHandler ["GetIn", { _unit = _this select 0; _unit additem "NVGoggles";_unit assignitem "NVGoggles";}];

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

params ["_vehicle", "_role", "_unit", "_turret"];

Always check if you're using the correct parameters first.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Yeah, I did check the parameters but they were a lil bit unclear to me (probably because I'd rather see examples than pure documentation).
So it would go like (?):

this addEventHandler ["GetIn", {_unit = _this select 0,"driver",heli_name}];

I'm kind of not used to the topic of event handlers so I'm not sure where to put in the:

 _unit additem "NVGoggles";_unit assignitem "NVGoggles";

 

Share this post


Link to post
Share on other sites
5 hours ago, canadian1337 said:

Yeah, I did check the parameters but they were a lil bit unclear to me (probably because I'd rather see examples than pure documentation).
So it would go like (?):


this addEventHandler ["GetIn", {_unit = _this select 0,"driver",heli_name}];

I'm kind of not used to the topic of event handlers so I'm not sure where to put in the:


 _unit additem "NVGoggles";_unit assignitem "NVGoggles";

 

watch this, it covers event handlers and the select command

 

 

if you look at the parameters that Grumpy Old Man posted, you would see thats in in this order like this

params ["_vehicle", "_role", "_unit", "_turret"];

 

and if you look in your script, you have

_unit = _this select 0

your setting _unit to be equal to _vehicle. with eventHandlers their in order starting from 0, so 0 is the vehicle, 1 is the role, 2 is the _unit(what you want) and 3 is the turret. so instead of setting unit to 0 you would want to set unit to 2 so its equal to the unit like this. anything inside of the {} is where you can put whatever scripts you want to run when the event handler runs.

this addEventHandler ["GetIn", 
{
	_unit = _this select 2;
	
	 _unit additem "NVGoggles";
	 _unit assignitem "NVGoggles";
}];

 

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  

×