Arma 3 Scripting

isKindOf

  • Arma 3 v0.50
  • First in Operation Flashpoint: Elite v1.00

Command · Markdown · JSON · original wiki page

Description

Checks whether the given object or type is (a subtype) of the given type.

While #Syntax 1 and #Syntax 2 only support CfgVehicles, Arma 2 v1.00CfgAmmo and CfgNonAIVehicles, #Syntax 3 can be used with any config, including the mission config.

Syntax

Syntax 1

object isKindOf typeName

Parameters:

Returns: Boolean

Syntax 2

class1 isKindOf class2

Parameters:

Returns: Boolean

Syntax 3

since arma3 1.48

class1 isKindOf [class2, targetConfig]

Parameters:

Returns: Boolean

Examples

Example 1

vehicle player isKindOf "Tank";

Example 2

"BMP2" isKindOf "Tank";

Example 3

currentWeapon player isKindOf ["Rifle", configFile >> "CfgWeapons"];

Example 4

private _isSoldier = player isKindOf "CAManBase";

See also

typeOf · countType · inheritsFrom · configHierarchy

Community notes

Kronzky

This command can be used on the whole hierarchical class tree (i.e. when checking a HMMWV, one could test for "HMMWV50", "Car", "LandVehicle", etc., all of which would return true.)

Basstard

In Arma 3 isKindOf works well with CfgWeapons and CfgMagazines using the syntax from example 3.

It should be prefered to James' solution as it performs more than 25x faster. Tested in debug console with the following code snippets:

"CA_Magazine" in ([configFile >> "CfgMagazines" >> "HandGrenade", true] call BIS_fnc_returnParents);    // 0.12111 ms
"HandGrenade" isKindOf ["CA_Magazine", configFile >> "CfgMagazines"];                                    // 0.00439453 ms

When checking in CfgVehicles the syntax from #Example 2 performs a little faster.