Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Description:Returns a sub-array of elements that satisfy a specific condition. The originally passed array is not modified. The function takes every element of the passed array, evaluates it in the condition, and, if the condition is true, adds it to the returned array.

In the condition, the element that is being currently tested is assigned to the variable "_x".

Care must be taken that the condition does not cause errors. For example, if your condition assumes all elements are numbers, errors occur if your array includes strings.

This function is similar to the count command, only it returns the elements of the array that satisfy the condition, rather than simply returning the element count.


Syntax:[array, condition] call fn_vbs_conditionalSelect
  • array: Array - Array to select from
  • condition: Code - For each element, if true, the element is selected.
Return Value:Array - A sub-array of elements that satisfy the specific condition.


When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.


_array = [[10,0,8,2,6,4], {_x > 5}] call fn_vbs_conditionalSelect
// Returns: [10,8,6]
_array = [[10,true,8,player], {typename _x == "STRING"}] call fn_vbs_conditionalSelect
// Returns: []

Additional Information

See also: