There are currently three methods of creating arrays in Vice City scripts. The first one (Barton Waterduck's method) has been largely deprecated now due to the fact that, although simple to use in his Mission Builders (using pseudo commands), the generated code was large and complicated.
Barton Waterduck's Arrays
Example of array code in the builder (note: this feature was introduced about v1.3):
Example of this code compiled and decompiled:
This method of array is most notably used in PatrickW's Marina Carpark Mod.
The second method of simulating arrays is CyQ's method. This uses one exploit of the SCM scripting engine in that parameters can be variables (in almost every OpCode, a lot of the defining OpCodes are strangely limited). It also uses the fact that an address, once compiled, is merely an offset from the start of the file (or mission). CyQ arrays calculate the address of a piece of code, store it in a variable then jump to the contents of that variable.
Note: This method requires detailed SCM knowledge to use due to the byte counting and files including this can (reputably) not be decompiled properly (at least by VC Mission Builder). A basic example which you can use to make arrays is explained below:
To retrieve data. $var0 - $var2 are the globals where the data is stored. [email protected] is the local variable we will work on in the script.
To store data.
This method creates an offset from a label based on the index passed to it and a constant representing the number of bytes per short code block when compiled (for more detail on this please see the Vice City SCM Format article). The drawback with this method is that you have to create all the variable writing blocks yourself (although with copy and paste this doesn't take long).
This method of array (and other implementations of the variable jumping exploit) are most notably found in the original Myriad Islands VC SCM (ironically written by Barton Waterduck).
Possibly the most difficult and complex implementation of arrays, it is the most accurate representation of arrays (with the index actually changing the array pointer) but it was more created as a 'this is possible' piece than an actual feasible piece.
It uses standard variable storage to store special numbers at consecutive points in the variable block. These numbers, once as HEX characters in memory will look like compiled SCM code which will be able to run and will bypass the Mission Builder limitation of restricting DMA variables to remain within the variable block. The code in here contains the array index and when code updates the pointer, the actual DMA address of the variable is altered (this is after preprocessing of the index value, similar to multiplying and adding an address in CyQ's arrays).
The concepts behind it however (code rewriting, still in development by Y_Less) are more useful with uses such as variable text and code hooking.
The most notable use of code rewriting (as these arrays are never used in real life) is Demarest's Darkpactor code, which uses code developed by him and Y_Less to rewrite threads to run the Darkpact code, unlike in older versions where you had to physically swap SCMs after adding the code.