Jump to content
fathersarge

Bad Vehicle Type - NATO IR Grenade

Recommended Posts

So I'm getting a Bad Vehicle Type error when trying to add the NATO IR Grenades to the inventory of a vehicle. I'm using a script to add items to the inventory (on mission start and on respawn).

 

The script works perfectly except for the IR grenade. As far as I can tell the object name is "B_IR_Grenade" and I've yet to see anything that contradicts that. The script calls for an array to define the loadout (see below)

 

In this example, the script puts 1 blue chemlight in the inventory and throws the bad vehicle error.

Spoiler

_loadOut = ["Chemlight_blue","B_IR_Grenade"]

 

If anyone can shed some light on a solution for this that would be great!

Share this post


Link to post
Share on other sites

How do you add the items from _loadOut to the unit?

And are you using any mods?

Share this post


Link to post
Share on other sites

As I said, the script works great, the only thing that doesn't get added is the IR Grenades for whatever reason.

 

Only mods of merit you will need are... CBA, ACE3, ADR-97 (w/compat), RHS (w/compats), and ctab I believe.

 

Spoiler

/* ---------------------------------------------------------------------------------------------------- 
File: vehRespawn.sqf 
Author: Iceman77
Modified: soulkobk 4:07 PM 13/05/2017 - added load out for specific vehicles.

Description: 
Respawn destroyed and abandoned vehicles (with custom vehicle load outs based on vehicle type, by soulkobk)

Parameter(s): 
_this select 0: vehicle  
_this select 1: abandoned delay in minute(s) - Required 
_this select 2: destroyed delay in minute(s) - Required 

How to use - Vehicle Init Line:  
_nul = [this, 120, 60] execVM "vehRespawn.sqf"; << 2 minute abandoned delay, 1 minute destroyed delay. 
---------------------------------------------------------------------------------------------------- */ 

private "_veh";

_veh = _this select 0; 
_abandonDelay = _this select 1; 
_deadDelay = _this select 2; 
_dir = getDir _veh;  
_pos = getPos _veh;  
_vehType = typeOf _veh;  

if (isServer) then

    _executeLoadout = {
        params ["_veh","_vehType"];
        _loadOut = []; // init _loadOut.
        switch (_vehType) do
        {
            case "RHS_UH60M_d": { _loadOut = ["Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","Chemlight_blue","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_HiRed","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","ACE_Chemlight_IR","B_IR_Grenade","B_IR_Grenade","B_IR_Grenade","B_IR_Grenade","B_IR_Grenade","DemoCharge_Remote_Mag","DemoCharge_Remote_Mag","DemoCharge_Remote_Mag","DemoCharge_Remote_Mag","DemoCharge_Remote_Mag","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellBlue","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellGreen","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellOrange","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","SmokeShellRed","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","Rangefinder","Rangefinder","Rangefinder","Rangefinder","Rangefinder","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","kss_beer_dark","kss_beer_dark","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EarPlugs","ACE_EntrenchingTool","ACE_EntrenchingTool","kss_beer_light","kss_beer_light","ACE_Clacker","ACE_Clacker","ACE_MapTools","ACE_MapTools","ACE_MapTools","ACE_MapTools","ACE_MapTools","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_morphine","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ACE_personalAidKit","ItemcTab","ItemcTab","ItemcTab","ItemcTab","ItemcTab","rhs_m4a1_grip_acog_usmc","rhs_m4a1_grip_acog_usmc","SMG_03C_black","SMG_03C_black","B_AssaultPack_blk","B_AssaultPack_blk","B_AssaultPack_blk","B_AssaultPack_blk","B_AssaultPack_blk"]; };
        };
        clearBackpackCargoGlobal _veh;
        clearMagazineCargoGlobal _veh;
        clearWeaponCargoGlobal _veh;
        clearItemCargoGlobal _veh;
        {
            if (_x != "") then
            {
                if ("B" in [_x splitString "_" select 0]) then
                {
                    _veh addBackpackCargoGlobal [_x, 1];
                }
                else
                {
                    _veh addItemCargoGlobal [_x, 1];
                };
            };
        } forEach _loadOut;
    };  

    [_veh,_vehType] call _executeLoadout; // init the load out for the first spawn

    while {true} do { 
        sleep 1; 
        if ((alive _veh) && {canMove _veh} && {{alive _x} count crew _veh == 0}) then
        { 
            _abandoned = true; 
            for "_i" from 0 to _abandonDelay do
            {   
                if (({alive _x} count (crew _veh) > 0) || (!alive _veh) || (!canMove _veh)) exitWith {_abandoned = false;}; 
                sleep 1;   
            }; 

            if ((_abandoned) && {_veh distance _pos > 10}) then
            { 
                deleteVehicle _veh; 
                sleep 1; 
                _veh = createVehicle [_vehtype, _pos, [], 0, "CAN_COLLIDE"]; 
                _veh setDir _dir; 
                _veh setPos [_pos select 0, _pos select 1,0];
                [_veh,_vehType] call _executeLoadout;
            }; 
        }; 
        if ((!alive _veh) || (!canMove _veh)) then
        { 
            _dead = true; 
            for "_i" from 0 to _deadDelay do
            {   
                if (({alive _x} count (crew _veh) > 0) || (canMove _veh)) exitWith {_dead = false;}; 
                sleep 1;   
            }; 
            if (_dead) then
            { 
                deleteVehicle _veh; 
                sleep 1; 
                _veh = createVehicle [_vehtype, _pos, [], 0, "CAN_COLLIDE"]; 
                _veh setDir _dir; 
                _veh setPos [_pos select 0, _pos select 1,0];
                [_veh,_vehType] call _executeLoadout;
            }; 
        }; 
    }; 
};

2

 

 

 

Share this post


Link to post
Share on other sites
47 minutes ago, fathersarge said:

"B" in [_x splitString "_" select 0]

B does not denote a backpack.

Use something like...

//snip

clearBackpackCargoGlobal _veh;
clearMagazineCargoGlobal _veh;
clearWeaponCargoGlobal _veh;
clearItemCargoGlobal _veh;
{
    if (_x != "") then   {
        [ _x ] call BIS_fnc_itemType params[ "_type", "_subType" ];
        switch ( toUpper _type ) do {
        	case "MINE";
        	case "MAGAZINE" : {
        		_veh addMagazineCargoGlobal[ _x, 1 ];
        	};
        	case "ITEM" : {
        		_veh addItemCargoGlobal[ _x, 1 ];
        	};
        	case "WEAPON" : {
        		_veh addWeaponCargoGlobal[ _x, 1 ];
        	};
        	case "EQUIPMENT" : {
        		if ( _subType == "backpack" ) then {
        			_veh addBackpackCargoGlobal[ _x, 1 ];
        		}else{
        			_veh addItemCargoGlobal[ _x, 1 ];
        		};
        	};
        };
    };
} forEach _loadOut;

//snip

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@Larrow yup that was it. Thanks for the save!

 

Any chance you know a way to identify specific vehicles (variable names?) with this script?

Also is there a different way to setup the loadouts so instead of 30 object names it can just be something like [ACE_Bandage, 30]?

Share this post


Link to post
Share on other sites
1 hour ago, fathersarge said:

Also is there a different way to setup the loadouts so instead of 30 object names it can just be something like [ACE_Bandage, 30]?

Change the loadout arrays so they include counts e.g

_loadOut = [ [ "Chemlight_blue", 10 ], [ "ACE_Chemlight_HiRed", 10 ], /* etc etc*/ ];

Then change the forEach loop. Using code from my previous post as an example..

{
	_x params[ "_item" ];
    [ _item ] call BIS_fnc_itemType params[ "_type", "_subType" ];
    switch ( toUpper _type ) do {
    	case "MINE";
    	case "MAGAZINE" : {
    		_veh addMagazineCargoGlobal _x;
    	};
    	case "ITEM" : {
    		_veh addItemCargoGlobal _x;
    	};
    	case "WEAPON" : {
    		_veh addWeaponCargoGlobal _x;
    	};
    	case "EQUIPMENT" : {
    		if ( _subType == "backpack" ) then {
    			_veh addBackpackCargoGlobal _x;
    		}else{
    			_veh addItemCargoGlobal _x;
    		};
    	};
    };
} forEach _loadOut;

 

1 hour ago, fathersarge said:

Any chance you know a way to identify specific vehicles (variable names?) with this script?

Instead of the switch statement like...

switch ( _vehType ) do {
	case "RHS_UH60M_d": { 
//snip

do..

switch ( true ) do {
	case ( _vehType == "RHS_UH60M_d" ) : {
		//Compatable with previous formatting
	};
	case ( vehicleVarName _veh == "MY_VEHICLE_NAME" ) : {
		//Choose vehicle via name given in eden
	};

Then you will need to change your two IF statements for when the vehicle is abandoned/destroyed to preserve the vehicles var name.

if ((_abandoned) && {_veh distance _pos > 10}) then
{
	_varName = vehicleVarName _veh; //ADD
	deleteVehicle _veh; 
	sleep 1; 
	_veh = createVehicle [_vehtype, _pos, [], 0, "CAN_COLLIDE"]; 
	_veh setDir _dir; 
	_veh setPos [_pos select 0, _pos select 1,0];
	_veh setVehicleVarName _varName; //ADD
	[ _veh, _varName ] call BIS_fnc_objectVar; //ADD
	[_veh,_vehType] call _executeLoadout;
};

if (_dead) then
{
	_varName = vehicleVarName _veh; //ADD
	deleteVehicle _veh; 
	sleep 1; 
	_veh = createVehicle [_vehtype, _pos, [], 0, "CAN_COLLIDE"]; 
	_veh setDir _dir; 
	_veh setPos [_pos select 0, _pos select 1,0];
	_veh setVehicleVarName _varName; //ADD
	[ _veh, _varName ] call BIS_fnc_objectVar; //ADD
	[_veh,_vehType] call _executeLoadout;
};

Think that should do the job, or at least give you an idea of what is needed in case ive made a mistake :/

  • Like 2

Share this post


Link to post
Share on other sites

In this case I believe. B = Blufor. and the reciprocal - O - Opfor. 

Share this post


Link to post
Share on other sites

@Larrow Masterful work! Everything is humming along beautifully. Thanks for the help!

Share this post


Link to post
Share on other sites
10 hours ago, Midnighters said:

In this case I believe. B = Blufor. and the reciprocal - O - Opfor. 

For soldiers and actual vehicles yes but it cannot be relied upon. A lot of the backpacks are indeed denoted as B even though shared across sides, like _ghex and _ocamo are B backpacks yet are mainly used by OPFOR and _oli mainly used by INDEP etc. There was a lot of disparity in early A3 but since then quite a few seem to have been inherited into new classes denoted by their side O I and G for example, yet are still direct inheritance of their B counterparts.

 

Here is a quick search through all soldier classes and the backpacks they have..

Spoiler

[
	//OPFOR
	[
		"G_FieldPack_Medic",
		"G_TacticalPack_Eng",
		"G_Carryall_Exp",
		"G_FieldPack_LAT",
		"G_Carryall_Ammo",
		"B_FieldPack_cbr_LAT",
		"B_FieldPack_ocamo_Medic",
		"B_FieldPack_cbr_Repair",
		"B_Carryall_ocamo_Exp",
		"B_FieldPack_cbr_Ammo",
		"B_FieldPack_cbr_AT",
		"B_FieldPack_ocamo_AA",
		"B_Carryall_ocamo_Eng",
		"B_Parachute",
		"B_Parachute",
		"O_UAV_01_backpack_F",
		"O_Assault_Diver",
		"B_FieldPack_blk_DiverExp",
		"B_FieldPack_cbr_RPG_AT",
		"B_FieldPack_ocamo_ReconMedic",
		"B_FieldPack_ocamo_ReconExp",
		"B_Carryall_ocamo_AAR",
		"B_Carryall_cbr_AAT",
		"B_Carryall_ocamo_AAA",
		"O_HMG_01_weapon_F",
		"O_GMG_01_weapon_F",
		"O_Mortar_01_weapon_F",
		"O_HMG_01_support_F",
		"O_Mortar_01_support_F",
		"B_Carryall_oucamo_AAR",
		"B_FieldPack_oucamo_LAT",
		"B_FieldPack_oucamo_AT",
		"B_Carryall_oucamo_AAT",
		"B_FieldPack_oucamo_AA",
		"B_Carryall_oucamo_AAA",
		"B_FieldPack_oucamo_Medic",
		"B_FieldPack_oucamo_Repair",
		"B_Carryall_oucamo_Exp",
		"B_Carryall_oucamo_Eng",
		"B_FieldPack_oucamo_Ammo",
		"B_Carryall_ghex_OTAmmo_F",
		"B_Carryall_ghex_OTAAR_AAR_F",
		"O_HMG_01_support_F",
		"O_Mortar_01_support_F",
		"B_Carryall_ghex_OTAAA_F",
		"B_Carryall_ghex_OTAAT_F",
		"B_FieldPack_ghex_OTMedic_F",
		"B_Carryall_ghex_OTEng_F",
		"B_Carryall_ghex_OTExp_F",
		"O_GMG_01_weapon_F",
		"O_HMG_01_weapon_F",
		"O_Mortar_01_weapon_F",
		"B_FieldPack_ghex_OTAA_F",
		"B_FieldPack_ghex_OTAT_F",
		"B_Parachute",
		"B_Parachute",
		"B_FieldPack_ghex_OTRepair_F",
		"B_FieldPack_ghex_OTLAT_F",
		"O_UAV_01_backpack_F",
		"O_Assault_Diver",
		"B_FieldPack_blk_DiverExp",
		"B_Carryall_ghex_OTReconExp_F",
		"B_FieldPack_ghex_OTReconMedic_F",
		"B_FieldPack_ghex_OTRPG_AT_F",
		"B_ViperHarness_hex_M_F",
		"B_ViperHarness_hex_M_F",
		"B_ViperHarness_hex_TL_F",
		"B_ViperHarness_hex_Exp_F",
		"B_ViperHarness_hex_Medic_F",
		"B_ViperHarness_hex_M_F",
		"B_ViperHarness_hex_LAT_F",
		"B_ViperHarness_hex_JTAC_F",
		"B_ViperHarness_ghex_M_F",
		"B_ViperHarness_ghex_TL_F",
		"B_ViperHarness_ghex_Exp_F",
		"B_ViperHarness_ghex_Medic_F",
		"B_ViperHarness_ghex_M_F",
		"B_ViperHarness_ghex_LAT_F",
		"B_ViperHarness_ghex_JTAC_F"
	],
	//BLUFOR
	[
		"B_AssaultPack_rgr_LAT",
		"B_AssaultPack_rgr_Medic",
		"B_AssaultPack_rgr_Repair",
		"B_Kitbag_rgr_Exp",
		"B_AssaultPack_mcamo_Ammo",
		"B_AssaultPack_mcamo_AT",
		"B_AssaultPack_mcamo_AA",
		"B_Kitbag_mcamo_Eng",
		"B_Parachute",
		"B_Parachute",
		"B_UAV_01_backpack_F",
		"B_Assault_Diver",
		"B_AssaultPack_blk_DiverExp",
		"B_AssaultPack_rgr_ReconLAT",
		"B_AssaultPack_rgr_ReconExp",
		"B_AssaultPack_rgr_ReconMedic",
		"B_AssaultPack_rgr_LAT",
		"B_Kitbag_rgr_Exp",
		"B_AssaultPack_rgr_Medic",
		"B_AssaultPack_mcamo_Ammo",
		"B_Kitbag_rgr_AAR",
		"B_Carryall_mcamo_AAT",
		"B_Carryall_mcamo_AAA",
		"B_HMG_01_weapon_F",
		"B_GMG_01_weapon_F",
		"B_Mortar_01_weapon_F",
		"B_HMG_01_support_F",
		"B_Mortar_01_support_F",
		"G_FieldPack_Medic",
		"G_TacticalPack_Eng",
		"G_Carryall_Exp",
		"G_FieldPack_LAT",
		"G_Carryall_Ammo",
		"B_Carryall_oli_BTAmmo_F",
		"B_Kitbag_rgr_AAR",
		"B_HMG_01_support_grn_F",
		"B_Mortar_01_support_grn_F",
		"B_Carryall_oli_BTAAA_F",
		"B_Carryall_oli_BTAAT_F",
		"B_AssaultPack_tna_BTMedic_F",
		"B_Kitbag_rgr_BTEng_F",
		"B_Kitbag_rgr_BTExp_F",
		"B_GMG_01_Weapon_grn_F",
		"B_HMG_01_Weapon_grn_F",
		"B_Mortar_01_Weapon_grn_F",
		"B_Kitbag_rgr_BTAA_F",
		"B_Kitbag_rgr_BTAT_F",
		"B_Parachute",
		"B_Parachute",
		"B_AssaultPack_tna_BTRepair_F",
		"B_AssaultPack_rgr_BTLAT_F",
		"B_UAV_01_backpack_F",
		"B_Assault_Diver",
		"B_AssaultPack_blk_DiverExp",
		"B_Kitbag_rgr_BTReconExp_F",
		"B_AssaultPack_rgr_BTReconMedic",
		"B_AssaultPack_rgr_ReconLAT",
		"B_Kitbag_rgr_CTRGExp_F",
		"B_AssaultPack_rgr_CTRGMedic_F",
		"B_AssaultPack_rgr_CTRGLAT_F"
	],
	//INDEP
	[
		"G_FieldPack_Medic",
		"G_TacticalPack_Eng",
		"G_Carryall_Exp",
		"G_FieldPack_LAT",
		"G_Carryall_Ammo",
		"I_Fieldpack_oli_Ammo",
		"I_Fieldpack_oli_LAT",
		"I_Fieldpack_oli_AT",
		"I_Fieldpack_oli_AA",
		"I_Fieldpack_oli_Medic",
		"I_Fieldpack_oli_Repair",
		"I_Carryall_oli_Exp",
		"I_Carryall_oli_Eng",
		"B_Parachute",
		"I_UAV_01_backpack_F",
		"I_Assault_Diver",
		"B_FieldPack_blk_DiverExp",
		"B_TacticalPack_oli_AAR",
		"I_Carryall_oli_AAT",
		"I_Carryall_oli_AAA",
		"I_HMG_01_weapon_F",
		"I_GMG_01_weapon_F",
		"I_Mortar_01_weapon_F",
		"I_HMG_01_support_F",
		"I_Mortar_01_support_F",
		"B_Kitbag_rgr_Para_3_F",
		"B_Kitbag_cbr_Para_5_F",
		"B_Kitbag_rgr_Para_8_F",
		"B_FieldPack_khk_Bandit_1_F",
		"B_Kitbag_cbr_Bandit_2_F",
		"B_FieldPack_cb_Bandit_3_F",
		"B_FieldPack_blk_Bandit_8_F"
	]
]

 

Notice how many OPFOR backpack are actually denoted by B but are _o/ou camo and _g/hex variants. BLUFOR are B but _rgr _mcamo variants.

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

×