GSC reference › Built-in
ArrayIntersect()
Built-in (engine)
Server + client
Utility
Returns an array of values that are present in both arrays.
Signature
ArrayIntersect(<array1>, <array2>, [matchKeys])
Parameters
| Name | Required? | Details |
|---|---|---|
| array1 | Required | An Array |
| array2 | Required | An Array |
| matchKeys | Optional | Optionally returns an array of matching key/value pairs from the two input arrays (preserving the keys). |
Returns
Returns an array of values that are present in both arrays.
Example (from Treyarch's docs)
newArray = ArrayIntersect( array1, array2 )
Real uses in BO3's scripts
Called 4 times in the decompiled scripts. A few, zombies first:
- scripts/shared/util_shared.gsc, line 3995
a_ret = arrayintersect(a_ret, a_ents); - scripts/shared/util_shared.gsc, line 4023
a_ret = arrayintersect(a_ret, a_ents); - scripts/cp/_training_sim.gsc, line 1355
return arrayintersect(var_5ea0ba06, var_389e3f9d); - scripts/cp/lotus_util.csc, line 132
var_41cebe05 = arrayintersect(var_62b3e03f, level.var_707bc057);
Related built-ins
- array()Create an array
- Assert()Assert that the given statement is correct.
- GetDvarInt()Gets the value of a dvar.
- IsArray()Checks whether this entity/variable is an array
- GetDvarString()Gets the value of a dvar.
- ArrayRemoveValue()Remove a value from an array (may affect multiple indexes)
- GetDvarFloat()Gets the value of a dvar.
- IsSubStr()Returns true/false if <substring> is a substring of <string>.
- GetArrayKeys()Returns an array consisting of the keys of the input array.
- ArrayCombine()Combine two arrays into and returns one new array
- IsInArray()Searches an array to determine if a given value is present in that array
- StrTok()Tokenizes <string> by the delimiters <delim>.
New to GSC?
Start with the basics, or paste a compile error to get the fix.
Built-in descriptions, parameters and examples come from Treyarch's BO3 mod tools docs. Usage links point at shiversoftdev/t7-source (decompiled BO3 scripts).