Jump to content
Sign in to follow this  
lockjaw-65-

create vehicle with name

Recommended Posts

How do I create a vehicle with a name so that I can use other scripts with it after it has spawned. I can create the vehicle using a trigger ie: [getmarkerpos "air1", 0, "BMP3", east] call BIS_fnc_spawnVehicle;

I just dont know how to add the name? Thanks

Share this post


Link to post
Share on other sites

Give it a handle.

_myunit = [getmarkerpos "air1", 0, "BMP3", east] call BIS_fnc_spawnVehicle;

That will only be local to the script though.

Share this post


Link to post
Share on other sites

thanks guys you have both been very helpful and I managed to spawn it with name, now I have to work out how to spawn it with crew?

Share this post


Link to post
Share on other sites

Just been trying with bis function, I can get it to create vehicles etc but Im back to same problem with naming the spawned vehicle. I just cant get it to have a name id?

Share this post


Link to post
Share on other sites
Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)

so creating a vehicle:

_createdVehicle = [getPos mySpawnPos, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;
_theVehicleItSelf = _createdVehicle select 0;
_theGroupOfTheCrew = _createdVehicle select 2;

you can now simply ignore giving it a name if you manage all its actions within a script or use setVehicleVarName to name it for outside use.

Share this post


Link to post
Share on other sites

@ Demonized thanks for your help but im really not sure how you use or implement that or setVehicleVarName to it. It creates empty vehicles?

Share this post


Link to post
Share on other sites

you need to have at least one unit present on the map of the side you are trying to spawn from.

you can place one unit in editor, then set probability precense slider to 0 (lower right of unit window in editor), unit will not be in mission but the spawns will work.

this is the same as using the scripting command

[url="http://community.bistudio.com/wiki/createCenter"]createCenter[/url] side;

also in your script have this at the top to make sure function module is ready:

waitUntil { !isNil "BIS_fnc_init" };

Share this post


Link to post
Share on other sites

Thanks that all seems to work great now.

I will explain what I am doing : I have a random mission that spawns three Tunguska's. The objective is to destroy them all. I have a trigger and in the condition is: ! alive aa1 && ! alive aa2 && ! alive aa3. In the on activation is: Obj1 setTaskState "SUCCEEDED"; hint "Objective Complete, the AA Battery is destroyed";

This is why I need the vehicles to have the names aa1, aa2, aa3 and this is what im having trouble with..

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

From my functions

_spawn_zone = _this select 0;
_veh_type    = _this select 1;
       _name         = _this select 2;
_group = createGroup east;
_veh = createVehicle [_veh_type, _spawn_zone, [], 0, "NONE"];
_gunner = _veh emptyPositions "gunner";
_commander = _veh emptyPositions "commander";
_cargo = (_veh emptyPositions "cargo") - 1;
"TK_Soldier_Crew_EP1" createUnit [_spawn_zone, _group, "this moveinDriver _veh;this assignAsDriver _veh;"];
if (_gunner > 0) then {"TK_Soldier_Crew_EP1" createUnit [_spawn_zone, _group, "this moveinGunner _veh;this assignAsGunner _veh;"];};
if (_commander > 0) then {"TK_Soldier_Crew_EP1" createUnit [_spawn_zone, _group, "this moveinCommander _veh;this assignAsCommander _veh;"];};
for "_i" from 0 to _cargo do
{
	"TK_Soldier_EP1" createUnit [_spawn_zone, _group, "this moveinCargo _veh;this assignAsCargo _veh;"];
};
       _veh SetVehicleVarName _name;

Share this post


Link to post
Share on other sites
Just preplace them?

Do you mean the vehicle names, if so with what and where?

Share this post


Link to post
Share on other sites
he meant the vehicles, but if that doesnt work for you then just use the setVehicleVarname mentioned earlyer in this thread.

_vehice setVehicleVarName "aa1";

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

That had me puzzled for a while until I notice that it needs the extra bit.

I'm now stuck with the name of the crew, I tried naiming it in the same way as the vehicle but it didn't work, I also tried _theGroupOfTheCrew = group blue but that didn't work either.

My Code

//null = ["name",vehicle,position,direction,side] execvm "Veh_Spawn.sqf";

//null = ["aa1","BMP3",gl1,180,east] execvm "Veh_Spawn.sqf";

_name = _this select 0;

_type = _this select 1;

_pos = _this select 2;

_dir = _this select 3;

_side = _this select 4;

_createdVehicle = [getpos _pos,_dir,_type,_side] call bis_fnc_spawnvehicle;

_theVehicleItSelf = _createdVehicle select 0;

_theGroupOfTheCrew = _createdVehicle select 2;

_theVehicleItSelf setVehicleVarName _name;

call compile format["%1 = _theVehicleItSelf", _name];

Share this post


Link to post
Share on other sites

The reason I dont want to preplace them is because they might get destroyed before the random task has started and that would cause problems in the mission.

I have the vehicle spawning fine (with your help) but I still cannot name it properly. I dont understand where that set var.. code ties in the script? If anybody could show an example of the whole script that would be great..

I did manage to do it this way:

aa1="2S6M_Tunguska" createVehicle getMarkerPos "air1"

It worked but the vehicle is unmanned, it did create the name and when destroyed the objective was complete..

Share this post


Link to post
Share on other sites

In the script I posted in the spoiler is code that will name the unit, you call it three times passing a different name and you will get three units with the names you want.

I'm just trying the get the crew into a useful group but failing but that shouldn't affect what your after.

Share this post


Link to post
Share on other sites
The reason I dont want to preplace them is because they might get destroyed before the random task has started and that would cause problems in the mission.

I have the vehicle spawning fine (with your help) but I still cannot name it properly. I dont understand where that set var.. code ties in the script? If anybody could show an example of the whole script that would be great..

I did manage to do it this way:

aa1="2S6M_Tunguska" createVehicle getMarkerPos "air1"

It worked but the vehicle is unmanned, it did create the name and when destroyed the objective was complete..

Man i posted a script for you 4 posts ago....

This the line to launch it:

_spawn = [getmarkerpos "air1", "2S6M_Tunguska", "aa1"] execVM "yourscript.sqf";

Edited by Giallustio

Share this post


Link to post
Share on other sites
Man i posted a script for you 4 posts ago....

This the line to launch it:

_spawn = ["2S6M_Tunguska", getmarkerpos "air1", "aa1"] execVM "yourscript.sqf";

Just a couple of things , you need to switch the position and weapon.

_spawn = [getmarkerpos "air1","2S6M_Tunguska", "aa1"] execVM "yourscript.sqf";

Also it doesn't make the name of the unit available outside of the script which I think he's after. Placing aa1 setdamage 1 in a trigger had no effect. For that I needed to add

call compile format["%1 = _veh", _name];

For my part I'm trying to name the BIS spawn function which is slightly different

Edited by F2k Sel

Share this post


Link to post
Share on other sites

@F2k Sel

Yeah you're right :D i'm very tired :)

post fixed ;)

You can use also setvehicleInit with processInitCommand, as you like :)

Share this post


Link to post
Share on other sites

Thank you all so much for the help. everything works great :)

@Giallusto Very sorry I overlooked your post before at the time it did not make much sense to me, but it is your script that im using now Thanks..

@F2k Sel thanks for your help and I hope you work out what you need

thanks to all others especially @Demonized who always seems to help (helped a lot with random tasks on a different thread) thanks

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

Been working on this for a long time now on and off. Im at the stage where I have lots of objectives and at each one I have a lot of things that spawn as we have mentioned. Once the objective is complete and I dont need them what is the best way to delete them. I have tried garbage removel and a couple of other scritps but none of them remove the items? has anybody got any suggestions?

Share this post


Link to post
Share on other sites

Did you try:

deleteVehicle objectName; //for one

or

{deleteVehicle _x;} foreach [objectName,objectName,objectName,objectName];

Share this post


Link to post
Share on other sites

I tried something like that but I may have not done it right as that looks different. I will try it tonight 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  

×