{"name":"isKindOf","title":"isKindOf","type":"command","url":"https://community.bistudio.com/wiki/isKindOf","revid":341247,"updated":"2023-05-18T10:50:41Z","groups":["Object Manipulation"],"status":"ok","games":{"ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofpe 1.00","arma3_since":"0.50","description":"Checks whether the given object or type is (a subtype) of the given type.\nWhile Syntax 1 and Syntax 2 only support **CfgVehicles**, Arma 2 v1.00**CfgAmmo** and **CfgNonAIVehicles**, Syntax 3 can be used with any config, including the mission config.","syntaxes":[{"syntax":"object isKindOf typeName","params":[{"name":"object","type":"Object","type_expr":"Object"},{"name":"typeName","type":"String","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"object"},"right":{"text":"typeName"}},{"syntax":"class1 isKindOf class2","params":[{"name":"class1","type":"String","type_expr":"String"},{"name":"class2","type":"String","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"class1"},"right":{"text":"class2"}},{"syntax":"class1 isKindOf [class2, targetConfig]","since":"arma3 1.48","params":[{"name":"class1","type":"String","type_expr":"String"},{"name":"class2","type":"String","type_expr":"String"},{"name":"targetConfig","type":"Config","type_expr":"Config"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"class1"},"right":{"text":"[class2, targetConfig]"}}],"examples":[{"code":["vehicle player isKindOf \"Tank\";"]},{"code":["\"BMP2\" isKindOf \"Tank\";"]},{"code":["currentWeapon player isKindOf [\"Rifle\", configFile >> \"CfgWeapons\"];"]},{"code":["private _isSoldier = player isKindOf \"CAManBase\";"]}],"see_also":["typeOf","countType","inheritsFrom","configHierarchy"],"notes":[{"user":"Kronzky","date":"2007-04-23T16:34:00Z","text":"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.)"},{"user":"James","date":"2015-06-16T17:54:00Z","text":"In case you cannot use isKindOf because of the reasons stated, just use BIS_fnc_returnParents with class names as return value:\n\n```sqf\n_isKindOf = \"Rifle\" in [configFile >> \"CfgWeapons\" >> \"BWA3_G36K\", true] call BIS_fnc_returnParents; // is true\n```"},{"user":"Basstard","date":"2015-09-06T22:21:00Z","text":"In Arma 3 isKindOf works well with CfgWeapons and CfgMagazines using the syntax from example 3.\nIt should be prefered to James' solution as it performs more than 25x faster. Tested in debug console with the following code snippets:\n\n```sqf\n\"CA_Magazine\" in ([configFile >> \"CfgMagazines\" >> \"HandGrenade\", true] call BIS_fnc_returnParents);    // 0.12111 ms\n\"HandGrenade\" isKindOf [\"CA_Magazine\", configFile >> \"CfgMagazines\"];                                    // 0.00439453 ms\n```\n\nWhen checking in CfgVehicles the syntax from Example 2 performs a little faster."}]}