Jump to content
Sign in to follow this  
_Ronin_

Help With Creating Vehicles w/ Names

Recommended Posts

I have searched threads on here and Bohemia Interactive on this topic. I have followed each of them to the letter and I still cannot get a vehicle spawned via script to have a name. As we know, the name is essential for follow-on actions with the vehicle. I would like some assistance please.

My created vehicle is as follows:

_LandRover_mg_tk_ins_ep1 = CreateVehicle ["LandRover_MG_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

How can I name this vehicle "GunTruck2a"?

Thanks in advance.

I tried the info on this link, and failed (Tried to post link but have not been registered long enough).

Arma 2 & OA - Editing > A2 & OA Missions & Scripting > Create Vehicles with Name

Share this post


Link to post
Share on other sites

well that'S what the = is for. it doesn't mean "equals" which would be like this ==.

do this...

GunTruck2a = CreateVehicle ["LandRover_MG_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

be aware that this name is unique. so this is one individual unit.

Share this post


Link to post
Share on other sites

I think you've missed the basic concept of variables. Assigning a variable to a vehicle is just the same as naming it in the property field of a spawned unit.

Just remember this:

variable = value;

Practically speaking, when you assign the vehicle created to a variable, you basically tell the script, "here, create this vehicle and store all the relevant stuff in this variable", and you can then access that vehicle by calling the variable. Also, take a look at the following:

_result = 5 + 5; // This assigns the result of 5 + 5 (10) to the variable _result, which is local.
hint format ["Result: %1",_result]; // This basically just outputs result, much like "print", "echo" or other stuff, but I guess you know that.

// The above is practically the same as:

hint format ["Result: %1",(5 + 5)];

// But the above does not use a variable. As you can see, a variable can practically be used to shorten stuff.

Okay I kinda made this longer than it had to be.. Just remember thar variables with a "_" infront of it are local :P

Share this post


Link to post
Share on other sites

I do it like this:

_spawn = [getmarkerpos "marker1", "ZSU_TK_EP1", "tank",180] execVM "mission1a.sqf";

it spawns a vehicle at marker1 named tank. Mission1a is a script that creates the crew..

Share this post


Link to post
Share on other sites
well that'S what the = is for. it doesn't mean "equals" which would be like this ==.

do this...

be aware that this name is unique. so this is one individual unit.

Thanks for the answer. I have tried that with no luck. The vehicle spawns but the units I am scripting to enter the vehicle do not enter it, but they continue on their waypoints.

I think you've missed the basic concept of variables. Assigning a variable to a vehicle is just the same as naming it in the property field of a spawned unit.

Just remember this:

variable = value;

Practically speaking, when you assign the vehicle created to a variable, you basically tell the script, "here, create this vehicle and store all the relevant stuff in this variable", and you can then access that vehicle by calling the variable. Also, take a look at the following:

_result = 5 + 5; // This assigns the result of 5 + 5 (10) to the variable _result, which is local.
hint format ["Result: %1",_result]; // This basically just outputs result, much like "print", "echo" or other stuff, but I guess you know that.

// The above is practically the same as:

hint format ["Result: %1",(5 + 5)];

// But the above does not use a variable. As you can see, a variable can practically be used to shorten stuff.

Okay I kinda made this longer than it had to be.. Just remember thar variables with a "_" infront of it are local :P

I appreciate this answer as well. This seems too in-depth for my abilities at the moment. Sry.

I do it like this:

_spawn = [getmarkerpos "marker1", "ZSU_TK_EP1", "tank",180] execVM "mission1a.sqf";

it spawns a vehicle at marker1 named tank. Mission1a is a script that creates the crew..

Thanks for the answer. I have tried this in both the trigger On Act field and in the script, and neither of them worked for me.

I'm going to post the script here. Could you please work it to what it needs so I can see what it is supposed to look like?

_TakiMilGrp2 = [(getMarkerPos "SpawnPoint2"), EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Patrol")] call BIS_fnc_spawnGroup;
_driver2a = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_gunner2a = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_driver2b = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_gunner2b = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];

_GunTruck2a = CreateVehicle ["LandRover_MG_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

_GunTruck2b = CreateVehicle ["BTR40_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

_driver2a moveindriver GunTruck2a;
_gunner2a moveingunner guntruck2a;
_driver2b moveindriver GunTruck2b;
_gunner2b moveingunner guntruck2b;

_members = units _TakiMilGrp2;
{_x moveInCargo guntruck2b} forEach _members;

Everything spawns correctly, but the units do not occupy the vehicle which indicates to me (a scripting nub) that the vehicles are not named.

Share this post


Link to post
Share on other sites
Thanks for the answer. I have tried that with no luck. The vehicle spawns but the units I am scripting to enter the vehicle do not enter it, but they continue on their waypoints.

I appreciate this answer as well. This seems too in-depth for my abilities at the moment. Sry.

Thanks for the answer. I have tried this in both the trigger On Act field and in the script, and neither of them worked for me.

I'm going to post the script here. Could you please work it to what it needs so I can see what it is supposed to look like?

_TakiMilGrp2 = [(getMarkerPos "SpawnPoint2"), EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Patrol")] call BIS_fnc_spawnGroup;
_driver2a = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_gunner2a = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_driver2b = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_gunner2b = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];

_GunTruck2a = CreateVehicle ["LandRover_MG_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

_GunTruck2b = CreateVehicle ["BTR40_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

_driver2a moveindriver GunTruck2a;
_gunner2a moveingunner guntruck2a;
_driver2b moveindriver GunTruck2b;
_gunner2b moveingunner guntruck2b;

_members = units _TakiMilGrp2;
{_x moveInCargo guntruck2b} forEach _members;

Everything spawns correctly, but the units do not occupy the vehicle which indicates to me (a scripting nub) that the vehicles are not named.

A few things. Your naming convention is not consistent - while object names are not case-sensitive, it's good form to stick to one style.

You named your vehicles using local variables, but then called them using undefined global variables.

Try this:

private ["_TakiMilGrp2","_driver2a","_gunner2a","_driver2b","_gunner2b","_members"];

_TakiMilGrp2 = [(getMarkerPos "SpawnPoint2"), EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Patrol")] call BIS_fnc_spawnGroup;
_driver2a = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_gunner2a = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_driver2b = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];
_gunner2b = _TakiMilGrp2 createunit ["TK_INS_Soldier_4_EP1", (getmarkerpos "Spawnpoint2"), [], 0, "form"];

guntruck2a = CreateVehicle ["LandRover_MG_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

guntruck2b = CreateVehicle ["BTR40_TK_INS_EP1", (getmarkerpos "SpawnPoint2"), [], 0, "form"];

_driver2a moveindriver guntruck2a;
_gunner2a moveingunner guntruck2a;
_driver2b moveindriver guntruck2b;
_gunner2b moveingunner guntruck2b;

_members = units _TakiMilGrp2;
{_x moveInCargo guntruck2b} forEach _members;

Not tested.

*edit* Lost track of the original intent and defined all trucks with local vars. Now global.

Edited by Harzach

Share this post


Link to post
Share on other sites

This is a link to a thread that I started and everything got sorted

http://forums.bistudio.com/showthread.php?120848-create-vehicle-with-name

Just noticed your first post and that you alresdy looked at this thread. I dont know why it wont work for you as I use it all the time and no problems?

All I can think of is maybe you not placed function module or have one of every faction you are spawning on map..

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

@Harzach, Thanks bro. It worked. I appreciate it and now I know what I did wrong.

@LockJaw, I also retried your method and found that adding a couple of quotations (VehicleVarName Method) worked for me too. 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  

×