Arrays
An array represents an indexed collection of elements of the same type (called the base type). You can work with any element directly via its index. An index numeration begins with a zero. Arrays are supported in San Andreas, LCS and VCS.
San Andreas:
<array name>(<index var name>,<size><type>)
$index = 0
$array($index,10i) = 1
<array name>
: local or global variable
<index var name>
: any variable containing an index of the element to read or write
<size>
: a value between 1 and 255 (inclusive)
<type>
: one of characters i
f
s
v
:Letter | Item Type | Item Size (bytes) |
i | integer | 4 |
f | float | 4 |
s | string | 8 |
v | string | 16 |
Liberty City Stories, Vice City Stories:
<array name>(<index var name>,<size>)
In LCS, VCS, array elements are only 4 bytes in length. Therefore, there is no need in type declaration.
$index = 0
$array($index,10) = 1
var
$FloatArray: array 10 of Float
end
After declaring an array you can work access its elements using square brackets:
var
$FloatArray: array 10 of Float
end
$index = 1
$FloatArray[$index] += 100.0
You can use positive integer numbers and zero to access a particular array element:
var
$FloatArray: array 10 of Float
end
$FloatArray[1] += 100.0
// initializing first three elements of the $strings array
s$strings[0] = 'str1'
s$strings[1] = 'str2'
s$strings[2] = 'str3'
var
$players: array 2 of Player
end
$players[0].Build
By default in the
GTA SA
edit mode, the disassembler prints array elements with the numbers as indexes. The same feature is available in LCS and VCS but is disabled by default. You can turn this feature on and off using the debug option CONSTANT_INDEXES
. Last modified 4mo ago