Jump to content
Sign in to follow this  
Lucky44

How to name vehicle spawned in BIS_fnc_SpawnVehicle ???

Recommended Posts

I'm trying to name a vehicle that I'm creating with BIS_fnc_SpawnVehicle, and it's not working. Can anyone improve on this (non-working) approach?

_TestHelo1 = [getMarkerPos "mrk_WP1", 20, "LIN_UH1", _airSquad1] call BIS_fnc_spawnvehicle;

Share this post


Link to post
Share on other sites

_TestHelo1 = [getMarkerPos "mrk_WP1", 20, "LIN_UH1", _airSquad1] call BIS_fnc_spawnvehicle;
_TestHelo1 setVehicleVarName "YourVehicleName";

;)

Share this post


Link to post
Share on other sites

BIS_fnc_spawnVehicle returns an array :)

Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)

So;

_TestHelo1 = [getMarkerPos "mrk_WP1", 20, "LIN_UH1", _airSquad1] call BIS_fnc_spawnvehicle;
(_TestHelo1 select 0) setVehicleVarName "YourVehicleName";

Share this post


Link to post
Share on other sites

Thanks, Buliwyf. I tried it like this:

_testHelo1 = [getMarkerPos "mrk_WPtest0", 20, "LIN_UH1", _airSquad1] call bis_fnc_spawnvehicle;
_testHelo1 setVehicleVarName "Helo98";

And got an error about "type array, expected object". -I don't see what is coming up as an array there.

Share this post


Link to post
Share on other sites

Thanks, Cuel. But I'm still getting a (different) problem. Here's my code now:

_testHelo1 = [getMarkerPos "mrk_WPtest0", 10, "LIN_UH1", _airSquad1] call bis_fnc_spawnvehicle;
(_testHelo1 select 0) setVehicleVarName "Helo98";
.
.
.
//move each group member into Helo
for "_x" from 0 to 4 do {
sleep 0.2;
(units _heloTroop1 select _x) moveInCargo Helo98;
};

The problem comes when I try to refer to helo98. I get a "undefined variable" error. Why would that be???

Share this post


Link to post
Share on other sites

how about

_ch select 0 setVehicleInit "transporthelo = this; this setVehicleVarName ""transporthelo""";

processInitCommands;

and here is a link to a helo transport script script with that in it for u to check out. should take care of your issue. http://www.kylania.com/ex/?p=47

Share this post


Link to post
Share on other sites

I found a little more info, but it's even more confusing now!

If I output the value of Helo98 (like Hint Format ["Helo98 is now %1",Helo98] ), it shows up as having a value of "to Helo98". -Yes, with the "to" in there! I've never seen anything like that! Now I'm really confused!

Share this post


Link to post
Share on other sites

Try it like this....no need for setvehiclevarname! ... also don't use "_x" in a for statement it's reserved for the foreach statement. Use "_i", "_j", "_k" etc. instead (standard programming practice).

//create the helo
_testHelo1 = [getMarkerPos "mrk_WPtest0", 10, "LIN_UH1", west] call bis_fnc_spawnvehicle;
Helo98 = _testHelo1 select 0;

//move each group member into Helo
for "_i" from 0 to (count units _heloTroop1)-1 do {
_unit = (units _heloTroop1) select _i;
_unit assignasCargo Helo98;
_unit moveInCargo Helo98;
sleep 0.2;
};

... another way of moving in the troops using foreach...

{_x assignascargo Helo98; _x moveincargo Helo98} foreach units _heloTroop1;

Edited by twirly
Clarity & Correction

Share this post


Link to post
Share on other sites

Sigh. -Thanks, twirly. That's awesome. I am such a hack programmer. But I keep learning by doing ;)

Share this post


Link to post
Share on other sites

No worries man... I had a little error with the _heloTroop1 variable... calling it _helogroup in one line! It's been fixed.

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  

×