Jump to content
Sign in to follow this  
BullyBoii

Spawn Vehicle

Recommended Posts

hi.

im just wondering if the BIS_fnc_spawnVehicle function is still working in Arma 3 and if it is, how

have you made it work :)

heres my code below

_createHeliSupport = [(getmarkerPos "helicopter_support_spawn"), 316, "AH9_Base_F", WEST] call BIS_fnc_spawnVehicle;

i dont see what is causing it not to work, no script errors are appearing which means that i have not defined

the params properly or that this function is not working.

Extra details: saved as a dot sqf file

no functions module on the map, i have no idea how to place one, well cant find it in the modules tab

Any help is greatly appreciated

thanks

Share this post


Link to post
Share on other sites
Have not tested BIS functions on Arma 3 alpha yet, but did you put the function manager on the map?

http://community.bistudio.com/wiki/Functions_Library

thats what i said, i couldnt find a functions module in the mission editor to place on a map, usually that was the problem in arma 2 but i cant seem to find one, or get the script to work

Share this post


Link to post
Share on other sites

Functions module is loaded automatically now.

Also you're using the wrong classname. It's "B_AH9_F"

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites

even with the new class name the script still does not spawn a chopper, dont know what else to do unfortunately

Share this post


Link to post
Share on other sites

waituntil {!(isnil "bis_fnc_init")};
_spawnpoint = getmarkerPos "helicopter_support_spawn";
_createHeliSupport = [_spawnpoint, 316, "B_AH9_F", WEST] call BIS_fnc_spawnVehicle;

demo

Share this post


Link to post
Share on other sites
even with the new class name the script still does not spawn a chopper, dont know what else to do unfortunately

I put your code right into an init file, just changed the classname and it worked. Did you have a BLUFOR unit already on the map?

Share this post


Link to post
Share on other sites

Hey.

I have a sign with

this addAction["<t color='#ff1111'>Spawn Heli</t>", "ADG\helispawn.sqf"];

... to spawn the heli. He's spawning but there is an AI inside and the heli is flying. How can i get rid of the pilot and spawn an empty heli?

This is the code i have in the helispawn.sqf:

waituntil {!(isnil "bis_fnc_init")};
_spawnpoint = getmarkerPos "helicopter_support_spawn";
_createHeliSupport = [_spawnpoint, 316, "B_Heli_Light_01_armed_F", WEST] call BIS_fnc_spawnVehicle;

Cheers,

Valixx

Share this post


Link to post
Share on other sites

You don't need the isNil BIS_fnc_init thing anymore, the functions module is built into the engine now.

Also BIS_fnc_spawnVehicle is designed specifically to spawn a vehicle with proper crew. If you just want the empty vehicle simply use createvehicle array.

this addAction["<t color='#ff1111'>Spawn Heli</t>", {veh = createVehicle ["B_Heli_Light_01_armed_F", getmarkerPos "helicopter_support_spawn", [], 0, "NONE"]}];

Share this post


Link to post
Share on other sites

Thanks again for the 2nd time kylania. :)

It's working. I've got two further questions tough if you don't mind. If it can't be achieved, that's fine.

1st: When the players are spawning a heli and they don't get in, is it possible to make it despawn?

2nd: Can i put everything into an .sqf file inside the mission folder and only get the things on the sign like: Spawn Heli 1, Spawn Heli 2.

_____

Maybe, like this for the 2nd one:

this addAction["<t color='#ff1111'>Spawn Heli 1</t>", "ADG\helispawn.sqf"];

And in the helispawn.sqf:

[color=#000000][color=#007700]{[/color][color=#0000BB]veh [/color][color=#007700]= [/color][color=#0000BB]createVehicle [/color][color=#007700][[/color][color=#DD0000]"class1"[/color][color=#007700], [/color][color=#0000BB]getmarkerPos [/color][color=#DD0000]"helicopter_support_spawn"[/color][color=#007700], [], [/color][color=#0000BB]0[/color][color=#007700], [/color][color=#DD0000]"NONE"[/color][color=#007700]]}[/color][/color];
[color=#000000][color=#007700]{[/color][color=#0000BB]veh [/color][color=#007700]= [/color][color=#0000BB]createVehicle [/color][color=#007700][[/color][color=#DD0000]"class2"[/color][color=#007700], [/color][color=#0000BB]getmarkerPos [/color][color=#DD0000]"helicopter_support_spawn"[/color][color=#007700], [], [/color][color=#0000BB]0[/color][color=#007700], [/color][color=#DD0000]"NONE"[/color][color=#007700]]};
[/color][/color][color=#000000][color=#007700]{[/color][color=#0000BB]veh [/color][color=#007700]= [/color][color=#0000BB]createVehicle [/color][color=#007700][[/color][color=#DD0000]"class3"[/color][color=#007700], [/color][color=#0000BB]getmarkerPos [/color][color=#DD0000]"helicopter_support_spawn"[/color][color=#007700], [], [/color][color=#0000BB]0[/color][color=#007700], [/color][color=#DD0000]"NONE"[/color][color=#007700]]};[/color][/color]

.

I think that would spawn all 3 of them right? It's only my try to get better in scripting. Correct me please :)

Edited by Valixx

Share this post


Link to post
Share on other sites

1. Sure

2. With something a simple as just making an empty helicopter having separate SQF files for one line of code you can easily add into the addAction seems a waste, but since you have the request for 1...

Sign with init of:

this addAction["<t color='#ff1111'>Spawn Attack Heli</t>", "ADG\helispawn.sqf", ["attack"]];  
this addAction["<t color='#11FF11'>Spawn Transport Heli</t>", "ADG\helispawn.sqf", ["transport"]];

helispawn.sqf:

private["_veh", "_spawn", "_spawnTime", "_delay"];
_type = _this select 3 select 0;
_attack = ["helicopter_attack_spawn", "B_Heli_Light_01_armed_F"];
_transport = ["helicopter_transport_spawn", "B_Heli_Light_01_F"];
_delay = 60;
_spawn = "";
_veh = "";

switch (_type) do {
case "attack": {
	_spawn = _attack select 0;
	_veh = _attack select 1;
};
case "transport": {
	_spawn = _transport select 0;
	_veh = _transport select 1;
};
};

_heli = createVehicle [_veh, getmarkerPos _spawn, [], 0, "NONE"];
_heli setVariable ["Occupied", false, true];
hint format["Your %1 helicopter has been spawned.  You have %2 seconds to board it!", _type, _delay];
_delayCheck = _heli addEventHandler["GetIn", {(_this select 0) setVariable ["Occupied", true];}];
_spawnTime = time;

waitUntil {time > (_spawnTime + _delay)};
_heli removeEventHandler ["GetIn", _delayCheck];
if (!(_heli getVariable "Occupied")) then {
hint format["You did not board your %1 helicopter within %2 seconds, it has been removed!", _type, _delay];
deleteVehicle _heli;
};

Share this post


Link to post
Share on other sites

Thanks for your reply. You're just awesome..i wish i could script like that..

Well i have a sign in-game with a logo.jpg saying: Vehicle Spawn. On that sign, the player can choose from all the helicopters etc. which one he wants. And therefore my question to put it into the helispawn.sqf because something like this i can't put that into the init field..i think..

So if i want to add more, then i can make it like this?

[color=#000000][color=#0000BB]_humingbird [/color][color=#007700]= [[/color][color=#DD0000]"helicopter_attack_spawn"[/color][color=#007700], [/color][color=#DD0000]"Class 1"[/color][color=#007700]];
[/color][/color][color=#000000][color=#0000BB]_pawnee [/color][color=#007700]= [[/color][color=#DD0000]"helicopter_attack_spawn"[/color][color=#007700], [/color][color=#DD0000]"Class 2"[/color][color=#007700]];[/color][/color][color=#000000][color=#007700][/color][/color]

Then in switch:

[color=#000000][color=#007700]case [/color][color=#DD0000]"pawnee"[/color][color=#007700]: {
       [/color][color=#0000BB]_spawn [/color][color=#007700]= [/color][color=#0000BB]_pawnee select 0[/color][color=#007700];
       [/color][color=#0000BB]_veh [/color][color=#007700]= [/color][color=#0000BB]_pawnee select 1[/color][color=#007700];
   };[/color][/color]

and in-game in the init field of the sign:

this addAction["<t color='#11FF11'>Spawn XX Heli</t>", "ADG\helispawn.sqf", ["pawnee"]];

Cheers,

Valixx

Share this post


Link to post
Share on other sites

Exactly. You could even skip the whole case thing and just put it in the addAction:

this addAction["<t color=#11FF11'>Spawn XX Heli</t>", "ADG\helispawn.sqf", ["class1", "marker1]];

Then in the script:

_veh = _this select 3 select 0;

_spawn = _this select 3 select 1;

Share this post


Link to post
Share on other sites

Oh okay.

One question tough, what is the "select 3 select 0" doing? What is it targeting/selecting?

Big thanks kylania!

Share this post


Link to post
Share on other sites

select 3 selects the arguments passed from the addAction command, and then select 0 selects the first argument in that argument array. In addAction page, check the "Parameters of the called script upon activation" part for more details.

Share this post


Link to post
Share on other sites

Thanks galzohar.

---------- Post added at 21:41 ---------- Previous post was at 21:27 ----------

Sorry guys for bothering you.. but i have again one question. If the player spawns that heli, and he lands somewhere on the island.. is it despawning there too? I've placed all the helis etc in the editor and passed this in the init field:

veh = [this, 10, 120] execVM "vehicle.sqf"

. Is it possible to pass this line of code to every spawned heli? Sry again :butbut:

Share this post


Link to post
Share on other sites

If you're using my code from above:

_heli = createVehicle [_veh, getmarkerPos _spawn, [], 0, "NONE"];
[_heli, 10, 120] execVM "vehicle.sqf";
_heli setVariable ["Occupied", false, true];

Share this post


Link to post
Share on other sites

I'm feeling stupid right now because it was so simple :/

Thanks again kylania!

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  

×