Skip to content

API ArrayContains en

Codex edited this page Oct 4, 2026 · 1 revision

ArrayContains

Русский · English · Українська · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

API · Basic

ClassicUO • Runtime API

Checks whether a value is in an allowed or already processed array.

Exact syntax

ArrayContains(array:Any, pattern:Any) -> Integer

Parameters

  • array — Array to inspect. A non-Array first argument returns 0.
  • pattern — Any value to find among the direct elements.

Returns

Integer Boolean: 1/True for a match, 0/False otherwise. Use If ArrayContains(...) or compare with True/1. This is not an index or match count.

Behavior

  • Local query: no server request, item movement or modification of the array. Examples use sample data, not a live inventory.
  • Checks the value kind, then compares direct elements until the first equal value. Integer 1 equals Decimal 1.0; String "1" does not equal either. Strings use exact case-sensitive comparison.
  • Nested Arrays and reference Objects compare by identity. Structure values are an exception: the same declared Structure type and equal field values compare equal (Array/Object fields keep their own equality rules). No recursive search. An empty array returns 0; uninitialized Array slots contain Unit and can match Unit.

Internal functions: from call to result

Checks the value kind, then compares direct elements until the first equal value. Integer 1 equals Decimal 1.0; String "1" does not equal either. Strings use exact case-sensitive comparison.

1. ArrayContains

Checks the value kind, then compares direct elements until the first equal value. Integer 1 equals Decimal 1.0; String "1" does not equal either. Strings use exact case-sensitive comparison.

Integer Boolean: 1/True for a match, 0/False otherwise. Use If ArrayContains(...) or compare with True/1. This is not an index or match count.

Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApi.cs; function ArrayContains.

2. Equals

Checks the value kind, then compares direct elements until the first equal value. Integer 1 equals Decimal 1.0; String "1" does not equal either. Strings use exact case-sensitive comparison.

Nested Arrays and reference Objects compare by identity. Structure values are an exception: the same declared Structure type and equal field values compare equal (Array/Object fields keep their own equality rules). No recursive search. An empty array returns 0; uninitialized Array slots contain Unit and can match Unit.

Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionValue.cs; function Equals.

3. ValueEquals

Nested Arrays and reference Objects compare by identity. Structure values are an exception: the same declared Structure type and equal field values compare equal (Array/Object fields keep their own equality rules). No recursive search. An empty array returns 0; uninitialized Array slots contain Unit and can match Unit.

Integer Boolean: 1/True for a match, 0/False otherwise. Use If ArrayContains(...) or compare with True/1. This is not an index or match count.

Project source: external/InjectionScript/src/InjectionScript/Runtime/ObjectTypes/StructureObject.cs; function ValueEquals.

Nested Arrays and reference Objects compare by identity. Structure values are an exception: the same declared Structure type and equal field values compare equal (Array/Object fields keep their own equality rules). No recursive search. An empty array returns 0; uninitialized Array slots contain Unit and can match Unit.

Examples

Allow selected item graphics

# Allow selected item graphics
#
# Checks whether a value is in an allowed or already processed array.
#
# Integer Boolean: 1/True for a match, 0/False otherwise. Use If ArrayContains(...) or compare
# with True/1. This is not an index or match count.

SUB Main()
    # The numeric graphic 0x0EED is in the sample list: Main returns allowed. This classifies a
    # graphic; it neither searches nor transfers items.
    # Local query: no server request, item movement or modification of the array. Examples use
    # sample data, not a live inventory.

    Dim allowed(1)
    allowed[0] = 0x0EED
    allowed[1] = 0x0F7A
    Dim graphic = 0x0EED
    If ArrayContains(allowed, graphic) = True Then
        Return "allowed"
    End If
    Return "skip"
END SUB

Parameter and execution notes:

  • The numeric graphic 0x0EED is in the sample list: Main returns allowed. This classifies a graphic; it neither searches nor transfers items.
  • Local query: no server request, item movement or modification of the array. Examples use sample data, not a live inventory.

Avoid processing a serial twice

# Avoid processing a serial twice
#
# Checks whether a value is in an allowed or already processed array.
#
# Integer Boolean: 1/True for a match, 0/False otherwise. Use If ArrayContains(...) or compare
# with True/1. This is not an index or match count.

SUB Main()
    # ASC explicitly converts the hexadecimal setting to an Integer serial before searching. The
    # known serial returns already queued. Searching the original String would not match the
    # Integer.
    # Local query: no server request, item movement or modification of the array. Examples use
    # sample data, not a live inventory.

    Dim queued(1)
    queued[0] = 0x40001234
    queued[1] = 0x40005678
    Dim incoming = "0x40001234"
    Dim serial = ASC(incoming, 0)
    If serial = 0 Then
        Return "invalid"
    End If
    If ArrayContains(queued, serial) Then
        Return "already queued"
    End If
    Return "new"
END SUB

Parameter and execution notes:

  • ASC explicitly converts the hexadecimal setting to an Integer serial before searching. The known serial returns already queued. Searching the original String would not match the Integer.
  • Local query: no server request, item movement or modification of the array. Examples use sample data, not a live inventory.

Understand nested route points

# Understand nested route points
#
# Checks whether a value is in an allowed or already processed array.
#
# Integer Boolean: 1/True for a match, 0/False otherwise. Use If ArrayContains(...) or compare
# with True/1. This is not an index or match count.

SUB Main()
    # route contains the same point reference, not sameCoordinates. Equal coordinates do not make
    # distinct arrays identical: Main returns 1|0.
    # Local query: no server request, item movement or modification of the array. Examples use
    # sample data, not a live inventory.

    Dim point(1)
    point[0] = 100
    point[1] = 200
    Dim sameCoordinates(1)
    sameCoordinates[0] = 100
    sameCoordinates[1] = 200
    Dim route(0)
    route[0] = point
    Return CStr(ArrayContains(route, point)) & "|" & CStr(ArrayContains(route, sameCoordinates))
END SUB

Parameter and execution notes:

  • route contains the same point reference, not sameCoordinates. Equal coordinates do not make distinct arrays identical: Main returns 1|0.
  • Local query: no server request, item movement or modification of the array. Examples use sample data, not a live inventory.

Clone this wiki locally