Category:Code Snippets

From GTAMods Wiki
Revision as of 17:23, 13 December 2005 by Random_download (talk | contribs)
Jump to navigation Jump to search

A collection of code snippets often used in the mission script, or to accomplish certain tasks.

Note: Don't just post your code, also give an explanation what it does and in which context it has to be used.

Arrays in Vice City

:label
0006:  0@ =  10   //these are the values we want to return from the array
0051:  reutrn
0006:  0@ =  78   //the space that the 0006 and the 0051 opcodes take up in total is 9 bytes because:
0051:  return     //opcode(2 bytes) + ptype(1 byte) + var(2 bytes) + ptype(1 byte) + smallint(1 byte) + opcode(2 bytes) = 9
0006:  0@ =  36
0051:  return

008B:  1@ = $index    //if we want the second value then $index = 1 (because for the first value $index = 0)
0012:  1@ *= 9        //9 * 1 = 9 (9 because the 0006 + 0051 opcodes take up 9 bytes in this case)
000A:  1@ +=  ££label //add the value of ££label to 1@
0050:  gosub 1@       //gosub to ££label + 9, so 0@ returns 78