Jump to content
Sign in to follow this  
thegunnysgt

Executing a script using class names and triggers

Recommended Posts

I know that this is probably going to be confusing, but here it goes. I have too many vehicles on the map for me to keep up with the init lines for each one to exec as script. So I would like something that detects the vehicles inside a trigger and looks for their class name or whatever and execs that vehicle using the script.

Now I know this is probably totally wrong, but here is what I got started. And it is probably in the wrong direction of what I want too, but hey I tried.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//Triggers - two sets for the two sides (east and west)

_area = ["airportin","farp1","farp2","farp3"];

_enemy_towns = ["pitlist","epolist","baglist","maslist","corlist","ortlist","obrlist","parlist","somlist","caylist","dollist"]

//Different vehicle types to use the script

_support = ["Truck5tReammo","UralReammo"];

_light_armor = ["BMP2","BRDM2_ATGM","Stryker_ICV_M2","Stryker_ICV_MK19","Stryker_TOW"];

_heavy_armor = ["M1Abrams","T72"];

//Line of code to exec the script for each vehicle inside each trigger

dummy = [_support, 90, false] execVM "scripts\ammo_burn.sqf";

Thanks.

Share this post


Link to post
Share on other sites

If I understood your goal properly this might work::

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{

   _trigger=_x   

   {

       _vehicle=_x;

       {

           _vehlist = _x;

           if ((typeOf _vehicle) in _vehlist) then {

               nul = [_vehicle,_vehlist,90,false] execVM "scripts\ammo_burn.sqf";

           };

       }forEach [_support,_light_armor,_heavy_armor];

   }forEach list _trigger;

}forEach _area+_enemy_towns;

The outer loop goes though all the triggers (in _area & _enemy_towns), the next loop takes each unit that is in each trigger area (list _trigger), and then we go through the three vehicle groups. If the vehicle tested is in one of the groups, it then calls the script.

Your original script didn't actually hand over the vehicle itself (only the class array). I don't know what happens in that script, but whatever it is, I would assume that it would need the *object* that it should do something with, so I've added that now as the first argument (_vehicle).

Good luck! You may need it... wink_o.gif

Share this post


Link to post
Share on other sites

Thanks, I'll give it a try. Yeah that piece of script was something that I threw together and of course it didn't work. crazy_o.gif

Update

Okay, I tried it and it didn't work. Said that a bracket was missing, but they all are there so I don't now how to fix.

A better explanation of what I want is for a trigger that spans the whole map to detect specific vehicles and then have those specific vehicles run a particular code. I have so many vehicles and they can be scattered throughout the map and it would be too much of a pain to insert the line of code into all of them.

I know I can do via switch statement as most of vehicles are already done that way, but that is dependent on if the vehicle has someone in it. This particular script needs to go off whether someone is in the vehicle or not.

Thanks.

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  

×