Jump to content
Sign in to follow this  
GIJaneDoe

Applying Vehicle Respawn Script to all vehicles

Recommended Posts

Hi All!

I have my mission to respawn vehicles and it's working fine with the one vehicle I have on the map. My question is do I have to add the veh = [this] execVM "vehicle.sqf" to each vehicle's init line or is there a way to apply it to all vehicles in one fell swoop?

Thanks a bunch!

Share this post


Link to post
Share on other sites

Well the easiest way would be to make it in a .sqf file since you're going to have to create an array for your vehicles.

Share this post


Link to post
Share on other sites

I have a vehicle.sqf file. Am I able to place the array script in it or do I need to make a new one with a different name? I really appreciate your help.

Share this post


Link to post
Share on other sites

Are you referring to the vehicle.sqf file? I'm using the Simple Vehicle Respawn Script I found in these forums so I imagine I'm allowed to cut and paste what I have, is that correct? I only have the one vehicle so far, but I'm just naming them Chopper1, Chopper2, etc.

Share this post


Link to post
Share on other sites

Yea or if you could just link the thread with that script so I could take a quick gander.

What should work is veh = [Chopper1, Chopper2, etc] execVM "vehicle.sqf";

Edited by deadlyhabit

Share this post


Link to post
Share on other sites

Ah ok so it looks like this script accepts an array as it's input already so veh = [Chopper1, Chopper2, etc] execVM "vehicle.sqf"; won't work.

I'm thinking this may work {veh = [this] execVM "vehicle.sqf" _X} forEach [Chopper 1, Chopper2, etc];

Share this post


Link to post
Share on other sites

In a new script file in your mission folder something like vehicles.sqf then create an init.sqf with the following:

execVM "vehicles.sqf";

if(true) exitWith {};

Share this post


Link to post
Share on other sites

I will give it a try tomorrow as I'm calling it a night. Thank you so much for taking the time to answer my questions.

Share this post


Link to post
Share on other sites

Well I tested it out for you and my initial code was a tad wrong, so went back and fixed it for your vehicles.sqf or whatever you name it, it would be this:

{veh = [_X] execVM "vehicle.sqf"} forEach [Chopper1, Chopper2, Chopper3, Chopper4]; 

What it does is executes the command in the {}s substituting the _X for each member in the array [] in this case 4 named choppers.

Share this post


Link to post
Share on other sites

I appreciate your help! I still to figure out exactly where to place this in the vehicle.sqf file.

Share this post


Link to post
Share on other sites

It should be in a new script file, I shouldn't have used vehicles.sqf as my name as it could easily be confusing.

Name it respawn.sqf and place that code in it.

Then create an init.sqf and put

execVM "vehicles.sqf";

if(true) exitWith {};

in it.

You should now have a mission.sqm, vehicle.sqf, respawn.sqf, and init.sqf in your mission folder.

Save and preview in editor now and everything should function fine.

edit:

JbY4B7a.png

Like so just I named my script file vehicles.sqf which I said was kind of a poor name choice given the originals name.

Edited by deadlyhabit

Share this post


Link to post
Share on other sites

You don't really need to make an vehicles.sqf though. In init.sqf you could simply type

{_veh = [_x] execVM "vehicle.sqf"}forEach vehicles; //vehicles is an actual command that returns all vehicles on the mission. very useful in this case

This could also be done in a trigger.

Edited by Tuliq

Share this post


Link to post
Share on other sites

Ah good point, force of habit for me since I generally do more scripting is to immediately go straight to a new file outside of init.sqf.

Your right about the vehicles command as well, slipped my mind last night.

Well now you have 2 ways to do it, one where all vehicles are selected by the vehicles command, or you can pick and choose via specific named ones like in the method I had before.

Should offer a nice flexibility and hopefully a rather painless introduction into scripting ;)

Share this post


Link to post
Share on other sites

Yup! The more ways to do things the merrier. :)

Share this post


Link to post
Share on other sites

I use that vehicle respawn script as well and it works great. I listed all my vehicles then called the script.

example of what you could use in just your "init.sqf" ..

cars = [car1,car2,car3,car4];

{veh = [_x] execVM "vehicle.sqf"} forEach cars;

Share this post


Link to post
Share on other sites
I use that vehicle respawn script as well and it works great. I listed all my vehicles then called the script.

example of what you could use in just your "init.sqf" ..

cars = [car1,car2,car3,car4];

{veh = [_x] execVM "vehicle.sqf"} forEach cars;

Unless you're actually using your cars array multiple times you don't have to define it beforehand.

You can just do it right within the function.

{veh = [_x] execVM "vehicle.sqf"} forEach [car1,car2,car3,car4];

cuts down the lines you need.

Share this post


Link to post
Share on other sites

I haven't had the opportunity to try this. I decided to re-format my PC and I'm still getting everything set back up. Thank you guys for all the responses.

Share this post


Link to post
Share on other sites

See this is what im talking about, applying a code to all vehicles, soldiers, or what have you in the game, instead of having to use all

sorts of codes, and come up with new scripts just to make it possible to apply a code to multiple units, ect,.

It should be a feature in the editor that all you would need to do is highlight the vehicles, (basically draw a box around them all)

and then from a dialogue list add the code and then it would be applied to all.

I have a thread for this:

http://forums.bistudio.com/showthread.php?149002-Make-multiple-units-playable-at-once-amp-other-editor-option-features&p=2326350#post2326350

please vote, and lets get this feature functionality added to the editor!

Share this post


Link to post
Share on other sites

It would be great to do this in editor and I voted in favor of it. This is the first time I've tried any editing so I don't carry experience from Arma or Arma II to Arma III.

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  

×