wozzsta 16 Posted March 8, 2016 Im trying to make an array of the UAVs like this _uav = ["B_UGV_01_rcws_F","B_UGV_01_F","B_UAV_01_F","B_UAV_02_F","B_UAV_02_CAS_F"]; and when they spawn i want them to have a crew so i use this. if (_vehicle isKindOf "_uav") then { createVehicleCrew _vehicle; { diag_log [_x, faction _x, side _x, side group _x]; } forEach crew _vehicle; }; but it doesnt work, it only works when i name them by their ID like this. if (_vehicle isKindOf "B_UGV_01_rcws_F") then { createVehicleCrew _vehicle; { diag_log [_x, faction _x, side _x, side group _x]; } forEach crew _vehicle; }; and i can only have one uav per statement, can anyone help? Cheers Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted March 8, 2016 if ((typeOf _vehicle) in _uav) then { https://community.bistudio.com/wiki/typeOf 1 Share this post Link to post Share on other sites
Tajin 349 Posted March 8, 2016 isKindOf works too but then you'd normally just specify the parent-class that all those UAVs have in common. (don't know it by heart) something like this: if (_vehicle isKindOf "UAV") {... Depends on what you want. (all UAVs or a specific list of them) Share this post Link to post Share on other sites
sarogahtyp 1108 Posted March 8, 2016 What about that? allUnitsUAV Share this post Link to post Share on other sites
Bnae 1431 Posted March 8, 2016 Try this _uav = ["B_UGV_01_rcws_F","B_UGV_01_F","B_UAV_01_F","B_UAV_02_F","B_UAV_02_CAS_F"]; if (_vehicle isKindOf _uav) then { createVehicleCrew _vehicle; { diag_log [_x, faction _x, side _x, side group _x]; } forEach crew _vehicle; }; Share this post Link to post Share on other sites
sarogahtyp 1108 Posted March 8, 2016 Try this if (_vehicle isKindOf _uav) then I think that should not work cause _uav is an array of strings and not a single string as requested by isKindOf I would suggest: if (typeOf _vehicle in _uav) then Share this post Link to post Share on other sites
Bnae 1431 Posted March 8, 2016 I think that should not work cause _uav is an array of strings and not a single string as requested by isKindOf Sorry my fault if ((typeOf _vehicle) in _uav) then { Share this post Link to post Share on other sites
wozzsta 16 Posted March 8, 2016 hey guys, Thanks for all the suggestions, i went with if (typeOf _vehicle in _uav) then And it seems to work perfectly, Cheers :) 1 Share this post Link to post Share on other sites
MarkCode82 21 Posted March 9, 2016 Could also do this: _uav = ["B_UGV_01_rcws_F","B_UGV_01_F","B_UAV_01_F","B_UAV_02_F","B_UAV_02_CAS_F"]; { if (_vehicle isKindOf _x) then { } forEach _uav; createVehicleCrew _vehicle; { /* Doing below will make debugging easier, always name your debug data it will make it easier to find bugs. omission of key information from your debug output can come back to but you in the bum big time */ diag_log format ["Vehicle Name: %1 \n Vehicle Faction name: %2 \n Vehicle: Side %3 \n Vehicle Group Side: %4",_x,(faction _x),(side _x),(side group _x)]; } forEach crew _vehicle; }; Share this post Link to post Share on other sites
Deadfast 43 Posted March 9, 2016 No, you couldn't, that's a script error. if ({_vehicle isKindOf _x} count _uav > 0) then ... ...would work. But as others have suggested I'd strongly recommend using isKindOf instead. Share this post Link to post Share on other sites
wozzsta 16 Posted March 9, 2016 No, you couldn't, that's a script error. if ({_vehicle isKindOf _x} count _uav > 0) then ... ...would work. But as others have suggested I'd strongly recommend using isKindOf instead. What are the advantages of iskindof, over typeof? :) Share this post Link to post Share on other sites
sarogahtyp 1108 Posted March 10, 2016 (edited) What are the advantages of iskindof, over typeof? :) You could just measure it to decide it. Kindly tell us what is faster,please _typo_sum = 0; for "_i" from 1 to 1000 do { _typo_start = diag_tickTime; if ((typeOf _vehicle) in _uav) then { /*do nothing cuz we measure the time of the condition*/ }; _typo_time = diag_tickTime - _typo_start; _typo_sum = _typo_sum + typo_time; }; systemchat format ["typo time: %1 ms", (_typo_sum / 1000)]; _kindo_sum = 0; for "_i" from 1 to 1000 do { _kindo_start = diag_tickTime; { if (_vehicle isKindOf _x) then { /*do nothing cuz we measure the time of the condition*/ }; } forEach _uav; _kindo_time = diag_tickTime - _kindo_start; _kindo_sum = _kindo_sum + kindo_time; }; systemchat format ["kindo time: %1 ms", (_kindo_sum / 1000)]; Edited March 10, 2016 by sarogahtyp Share this post Link to post Share on other sites
Tajin 349 Posted March 10, 2016 You could just measure it to decide it. Not really, you can't compare 2 commands that do totally different things. It just comes down to what you want to do. isTypeOf (combined with an Array) is better when you only want to allow a specific selection of classes. isKindOf is ideal if you want to limit to everything in a specific sub-category (all UAVs for example). Share this post Link to post Share on other sites
sarogahtyp 1108 Posted March 10, 2016 Not really, you can't compare 2 commands that do totally different things. It just comes down to what you want to do. isTypeOf (combined with an Array) is better when you only want to allow a specific selection of classes. isKindOf is ideal if you want to limit to everything in a specific sub-category (all UAVs for example). we have a given example here with a specific class name string which should be compared. i cant see a difference between line 7 and 23 0f my code if _uav contains an array of class name strings. or is there a subtype of that class names?point that out please. Share this post Link to post Share on other sites
Tajin 349 Posted March 10, 2016 _unit isTypeOf "classname" > only returns true if _unit is exactly the same class _unit isKindOf "classname" > returns true if _unit is of the same class or of any subclass that is derived from "classname" using isKindOf as 1:1 replacement for isTypeOf doesn't make sense and can be an Issue if you DONT want it to return true for subclasses. isTypeOf is the right tool if you have a specific list of classnames that you want to allow isKindOf is the right tool if you want to allow all UAVs with no exceptions, as you only need to do a single check against the base-class which all UAVs have in common. like I said earlier: Depends on what you want. (all UAVs or a specific list of them) Share this post Link to post Share on other sites
wozzsta 16 Posted March 10, 2016 Thanks guys, appreciate the detailed explanations. :) Share this post Link to post Share on other sites