Subroutines (GTA2)

From WikiGTA - The Complete Grand Theft Auto Walkthrough
Jump to: navigation, search

Main Page > GTA2 > Modding Tutorial > Subroutines

Subroutines are used to easily "jump" to a set of commands within the script.


A subroutine is created with the next command:

//code goes here 
name An unique name for the subroutine. Note the : at the end of the name!
RETURN This closes the subroutine. Every command in the subroutine has to be between the name: and RETURN.

You can script the subroutine where ever you want, even before LEVELSTART!


To activate a subroutine at the start of the game, use this command:


The FORWARD must be before LEVELSTART


To jump to the subroutine mid-game, you use the next command:

GOSUB name:

Again, don't forget the : at the end of the name. A GOSUB can be everywhere where you want to jump to the subroutine: inside an IF, a WHILE, etc, as long as it's after LEVELSTART.

Modding tutorials of Grand Theft Auto 2
Mapping Map Editor · Buildings · Roads · Water & animations · Slopes · Flat tiles · Collision info · Level edge · Zones · Putting a level ingame
Scripting Declarering: Main script · Script Compiler · Code lists · Commands · Vehicles · Objects · Sounds · Characters
Programming: IF · WHILE · COUNTERs · Subroutines · THREAD TRIGGERs · Kill Frenzies
Both Manual · Lighting · Car shops · Cranes & crushers · Gangs · Subway · Multiplayer levels
File types .gci · .gmp · .gxt · .mis · .mmp · .scr · .seq · .tmp · .sty
Other Texting · Physics · Creating vehicles · Terminology · Installing levels