Jump to content
Sign in to follow this  
Ivanoff.N

Event handlers or script start for specific classes

Recommended Posts

I am trying to make an addon that will make a small hud appear as soon as you enter particular vehicle.

I have made the hud itself via script using rsctext.

I only need the code for the init.sqf so that:

1) playable unit enters mortar as gunner (only mortar no other vehicle) - script starts

2) playable unit exits mortar  - script stops

 

I need this to work with all mortars placed on the map for all playable units, without any naming etc. (of course each player must see the hud individually).

 

Please advise if it is possible to do and the code to do it if possible.

Thank you,

Share this post


Link to post
Share on other sites

The wiki has it all, surprisingly :smile_o::

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

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

mortars = ["mortar_class_1","mortar_class_2","mortar_class_3"...];
player addEventHandler ["GetInMan", {if (_this select 2 in mortars) then {[_this select 0] execVM "script.sqf"}}];

Share this post


Link to post
Share on other sites
On ‎1‎/‎19‎/‎2017 at 2:00 PM, theend3r said:

The wiki has it all, surprisingly :smile_o::

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

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


mortars = ["mortar_class_1","mortar_class_2","mortar_class_3"...];
player addEventHandler ["GetInMan", {if (_this select 2 in mortars) then {[_this select 0] execVM "script.sqf"}}];

Yes, the problem is that to understand what the wiki sais you need to have quite a bit of knowledge.

For example this: mortars = ["mortar_class_1","mortar_class_2","mortar_class_3"...]; <- are these the names of the classes of units I want to trigger the script ?

Would this be the correct syntax if I want to use vanilla mortars ?

mortars = ["B_G_Mortar_01_F ","B_Mortar_01_F"];

   

Also I know that all new variables are marked with _ (example: _variable = something) why is it not so in this case ?

 

Share this post


Link to post
Share on other sites
1 hour ago, Ivanoff.N said:

Yes, the problem is that to understand what the wiki sais you need to have quite a bit of knowledge.

For example this: mortars = ["mortar_class_1","mortar_class_2","mortar_class_3"...]; <- are these the names of the classes of units I want to trigger the script ?

Would this be the correct syntax if I want to use vanilla mortars ?

mortars = ["B_G_Mortar_01_F ","B_Mortar_01_F"];

   

Also I know that all new variables are marked with _ (example: _variable = something) why is it not so in this case ?

 

  1. Yes, that's correct.
  2. _something means it's local and that wouldn't work here

Also, I made a mistake there, it needs typeOf to work

player addEventHandler ["GetInMan", {if (typeOf (_this select 2) in mortars) then {[_this select 0] execVM "script.sqf"}}];

 

Share this post


Link to post
Share on other sites
On ‎1‎/‎20‎/‎2017 at 6:09 PM, theend3r said:
  1. Yes, that's correct.
  2. _something means it's local and that wouldn't work here

Also, I made a mistake there, it needs typeOf to work


player addEventHandler ["GetInMan", {if (typeOf (_this select 2) in mortars) then {[_this select 0] execVM "script.sqf"}}];

 

This has to go in the init .sqf and start at the beginning of the mission right  ?

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  

×