Jump to content
Tostm8

Using a vehicle's class name to get it's real name

Recommended Posts

Hello,

I need some help here. I want to find another way to do this basically:

_vehicle = _this select 0;
vehicleType = "";

if (typeOf _vehicle == "B_Truck_01_mover_F") then {vehicleType = "HEMTT"};
if (typeOf _vehicle == "B_Truck_01_ammo_F") then {vehicleType = "HEMTT Ammo"};
if (typeOf _vehicle == "B_Truck_01_fuel_F") then {vehicleType = "HEMTT Fuel"};
if (typeOf _vehicle == "B_Truck_01_medical_F") then {vehicleType = "HEMTT Medical"};
if (typeOf _vehicle == "B_Truck_01_Repair_F") then {vehicleType = "HEMTT Repair"};
if (typeOf _vehicle == "B_Truck_01_transport_F") then {vehicleType = "HEMTT Transport"};
if (typeOf _vehicle == "B_Truck_01_covered_F") then {vehicleType = "HEMTT Transport (Covered)"};

I don't want to have to type out every different variation because I'm lazy haha. Is there another way around this?

 

Thanks,

Toasty.

 

*EDIT*

 

!SOLVED!

Here's the solution / an example of its use:

_nearVehicles = nearestObjects [player, ["Car"], 200];

{

	_description = getDescription _x;
	_className = _description select 0;
	_displayName = getText (configFile >> "CfgVehicles" >> _className >> "displayName");
	_marker = createMarker [str(_x), getPos _x];
	_marker setMarkerColor "ColorRed";
	_marker setMarkerShape "ICON";
	_marker setMarkerType "mil_end";
	_marker setMarkerText _displayName;

} forEach _nearVehicles;

This will add a marker onto every "car" with its name within a 200-meter radius.

Edited by Tostm8

Share this post


Link to post
Share on other sites

@Tostm8,

_displayName = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName");
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

This way, I think...

 

getText (configFile >> "CfgVehicles" >> (typeof _vehicle) >> "displayName")

 

  • Like 1

Share this post


Link to post
Share on other sites

lol Schatten beat me.

by a second :)

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites

Thank you both! I reckon that should work.

 

Ta.

 

*EDIT*

 

Works like a charm. Thank you very much guys!

Edited by Tostm8
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

×