Jump to content
Sign in to follow this  
ironhawx

Units in vic set captive state true

Recommended Posts

So basically trying to make a mission where team sneaks into the area and meets up with a local asset.  The asset is simply there to deliver a local "civilian" truck for them to use to travel safely into city undercover.  Basically what I was thinking was in the init of the vic, putting something like: "foreach unit set captive true;" however realized that probably wouldn't work because then they are liable to be set captive rest of mission.  So basically looking for something that sets captive state true while units are in the vic but once they disembark the vic captive state switches back to false, with a like a two second buffer before the switch happens.  Any help would be great as my search wasn't very fruitful.

Share this post


Link to post
Share on other sites

Into the vehicles init field:

 

this addEventHandler ["GetOut",{

params ["_vehicle","_position","_unit"];
_unit setCaptive false;

}];

this addEventHandler ["GetIn",{

params ["_vehicle","_position","_unit"];
_unit setCaptive true;

}];

When units enter the vehicle they will be setCaptive true, when exiting they will be setCaptive false.

 

Cheers

Share this post


Link to post
Share on other sites
17 minutes ago, Grumpy Old Man said:

Into the vehicles init field:

 


this addEventHandler ["GetOut",{

params ["_vehicle","_position","_unit"];
_unit setCaptive false;

}];

this addEventHandler ["GetIn",{

params ["_vehicle","_position","_unit"];
_unit setCaptive true;

}];

When units enter the vehicle they will be setCaptive true, when exiting they will be setCaptive false.

 

Cheers

Much thanks someone was trying to have me use some big script package that checked what a unit is wearing and stuff, and I was like thats way more than I needed and new there was a simpler way.  Thank you for the help.  

Idk if I could trouble you as to go over the codes pieces so I can understand it a bit better?

If I'm reading it right "this" refers to the vic obviously, addEventHandler checks anytime an event happens aka a unit enters or exits the vehicle.  "GetOut" is keyword for a built in command (interaction option) that players fire., params short for parameters?  then its that stuff inside I'm almost certain 100% wrong on, but are built in keywords/functions of arma? and you set the parameters to look for an event regarding the vic, its position, or any units interacting with it?  and when it detects a unit getting out it sets it to false?

  • Like 1

Share this post


Link to post
Share on other sites

Well you can always add stuff to it, once there's an undercover unit in a vehicle you can start a loop and check for enemies and remove the captive state if an enemy is closer than 5m, check for uniforms, facewear etc.

Most important thing is to make stuff work in the first place.

 

Cheers

Share this post


Link to post
Share on other sites
On ‎02‎/‎09‎/‎2017 at 11:29 AM, ironhawx said:

then its that stuff inside I'm almost certain 100% wrong on, but are built in keywords/functions of arma? and you set the parameters to look for an event regarding the vic, its position, or any units interacting with it?

 

 

https://community.bistudio.com/wiki/params

The strings in the params array are just names he wanted give to his variables, as the names represent the values the event handler gives. He could name them

params ["_black","_fire","_monkey"];

if he wanted to and still contain the same value for each variable given by the event handler.

 

 

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

• vehicle: Object - Vehicle the event handler is assigned to

• position: String - Can be either "driver", "gunner" or "cargo"

• unit: Object - Unit that left the vehicle

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  

×