Sanny Builder
Search…
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.

General Syntax

San Andreas: <array name>(<index var name>,<size><type>)
1
$index = 0
2
$array($index,10i) = 1
Copied!
<array name>: local or global variable <index var name>: any variable containing an index of the element to read or write <size>: any value greater than 0 <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.
1
$index = 0
2
$array($index,10) = 1
Copied!

Array Declaration

Arrays can be declared using the VAR..END construct: var <array name>: array <size> of <type> end
1
var
2
$FloatArray: array 10 of Float
3
end
Copied!

Accessing array elements after declaration

After declaring an array you can work access its elements using square brackets:
1
var
2
$FloatArray: array 10 of Float
3
end
4
$index = 1
5
$FloatArray[$index] += 100.0
Copied!

Using constant indexes

You can use positive integer numbers and zero to access a particular array element:
1
var
2
$FloatArray: array 10 of Float
3
end
4
$FloatArray[1] += 100.0
Copied!
Elements of an array containing string literals can be accessed with string variables:
1
// initializing first three elements of the $strings array
2
s$strings[0] = 'str1'
3
s$strings[1] = 'str2'
4
s$strings[2] = 'str3'
Copied!
An array can be declared as a collection of class instances:
1
var
2
$players: array 2 of Player
3
end
4
$players[0].Build
Copied!
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 1yr ago