Search the Community
Showing results for tags 'iskindof'.
Found 3 results
-
Guys, dudes, folks, Can you help me to make my function a little bit more elegant to save server performance? I feel my snippet is not even a good way to do this: I want to call a function that will check an array of a couple of classnames (it should be only vehicles BUT mission editors can make mistakes). So, to verify this, the function will analyze if each classname corresponds to some of those object types. Calling: _itShouldBeOnlyVehiclesClassnames = ["B_G_Offroad_01_armed_F", "B_Soldier_F", "B_Heli_Light_01_dynamicLoadout_F"]; _isValid = [_itShouldBeOnlyVehiclesClassnames, ["Car", "Motorcycle", "Tank", "WheeledAPC", "TrackedAPC", "Helicopter"]] call TAG_fnc_is_valid_classnames_type; if _isValid then { /* a lot of things happen! */ }; The function itself: TAG_fnc_is_valid_classnames_type = { // This function checks if each classname in an array is one of the classname types allowed to be valid. // Returns _isValid. Bool. params ["_classnames", "_allowedTypes"]; private ["_isValid", "_classnamesOk", "_classnamesAmount", "_eachAllowedType"]; // Initial values: _isValid = true; _classnamesOk = []; // Declarations: _classnamesAmount = count _classnames; // Main function: { _eachAllowedType = _x; { // If the classname is an allowed type, include this valid classname in another array: if ( _x isKindOf _eachAllowedType ) then { _classnamesOk pushBack _x }; } forEach _classnames; } forEach _allowedTypes; // If there's difference between the size of both arrays, it's coz some classname is not an allowed type: if ( count _classnames isNotEqualTo count _classnamesOk ) then { // Update the validation flag: _isValid = false; }; // Return: _isValid; }; Small challenge: Print out an error message indicating exactly which classname(s) is/are not part of the "allowed type of objects".
-
Are there smarter ways to know if my object is a trigger OR a visible object that can be killed/destroyed? My current solution looks not fancy at all, but works: // If the object is a trigger, when triggerActivation command is used, it returns this array: [by, type, repeating] if ( count (triggerActivation _myObject) == 3 ) then { systemChat "The obj is a trigger!"; } else { // If the object is a unit or a building or vehicle, triggerActivation command will return an empty array: [] systemChat "The obj is a visible object that can be destroyed or killed!"; }; Wiki of triggerActivation. Wiki of count.
-
Setting random scale for all IsKindOf objects
tommytom1 posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
mossRocks = [ "Land_RM_boulder1", "Land_Cliff_stone_small_F", "Land_Cliff_stone_medium_F", "Land_Cliff_stone_big_F", "Land_RM_boulder5", "Land_RM_boulder4", "Land_RM_boulder3", "Land_RM_boulder2" ]; { _objectType = typeOf _x; if (_objectType isKindOf mossRocks) then { _scale = selectRandom [0.9, 1.4]; _x setObjectScale _scale; }; } forEach mossRocks; im trying to pick a random number between 0.9 and 1.4 and have it set Scale for all my lil mossy rocks in my mission im doing this from the init.sqf and from some reason it doesn't work is there any obvious errors in the code im missing? (probably:D)