Jump to content
Sign in to follow this  
-ami- mofo

spawning a vehicle using this very simple script (that I found)

Recommended Posts

Hello guys, I'm up to making my third mission and now want to spawn soldier/s and vehicle/s via triggers rather than just pre-placing them on the map.

I don't know scripting one bit so I searched on you tube and found this which is very simple (needs to be) and which spawns an enemy soldier on a marker (named spawn1) via a trigger...

You just put this in the triggers on act and set detected by blufor.

GroupOne_X = Creategroup EAST; "O_Soldier_F" createUnit [getMarkerPos "spawn1",GroupOne_X,"this allowFleeing 0",random 1, "Private"]; 

Now I worked out how to spawn multiple soldiers on the marker but I have no idea how to modify the line to spawn a vehicle.

I tried

GroupOne_X = Creategroup EAST; "[b]O_MRAP_02_hmg_F[/b]" createUnit [getMarkerPos "spawn1",GroupOne_X,"this allowFleeing 0",random 1, "Private"];

but that didn't work, nothing spawned at all. I also tried changing the createUnit to createVehicle but that just gave me an error. Remember I'm totally guessing as I have no clue. Derrrrr

Could somebody please show me the amended code for getting the vehicle to spawn?

Thanks very much.

Share this post


Link to post
Share on other sites

// spawn 2 dudes
GroupOne_X = [getMarkerPos "spawn1", EAST, ["O_Soldier_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup;
{_x allowFleeing 0} forEach units GroupOne_X;

// spawn an MRAP too
mrapSpawn = [getMarkerPos "spawn1", 0, "O_MRAP_02_hmg_F", EAST] call bis_fnc_spawnvehicle;
MRAP = mrapSpawn select 0;
MRAPcrew = mrapSpawn select 1;
MRAPgroup = mrapSpawn select 2;
{_x allowFleeing 0} forEach units MRAPgroup;

Though if you want an Ifirt and a few guys you could just do this:

GroupOne_X = [getMarkerPos "spawn1", EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Motorized_MTP" >> "OIA_MotInf_Team")] call BIS_fnc_spawnGroup;
{_x allowFleeing 0} forEach units GroupOne_X;

Share this post


Link to post
Share on other sites

Excellent thanks so much kylania that works perfectly :)

May I trouble you with one more question?

I though "why not try doing this from a .sqf file in my mission\scripts folder"...

So I added a spawn1.sqf file to my mission\scripts folder and put in the same code that worked in the on act of the trigger. Then I just changed the wording in the trigger on act to null0 = this execVM "scripts\spawn1.sqf";

But nothing happened. So did I do something wrong? Or is this type of code only suited to calling directly from a trigger?

Thanks again.

Share this post


Link to post
Share on other sites

Make sure your mission is *.sqf and not *.sqf.txt. See

for the difference and how to fix it.

Also if you're calling this from a trigger you'll definitely want to use a script. Also include this at the top so that only one set of dudes gets spawned:

if (!isServer) exitWith{};

Additionally since you're not passing anything to the script, you can ignore the 'this' and just call the script as:

_null = [] execVM "scripts\spawn1.sqf";

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  

×