Create a thread

Creating a simple thread is one of the first steps in understanding how to code. This article will show you the basic steps on how to create the simplest thread using Sanny Builder. It should work for GTA 3, Vice City, and San Andreas.

Create your thread
First create your thread using opcode 004F (or create_thread command). Find Insert before it mythread is an arbitrary label. You can name the label with anything.

Insert your contents
Next you have to insert the contents into your thread. Find That is where the MAIN section ends and the first mission begins. Insert your contents between it. The simplest format of a thread have this format The contents can include simple opcodes or longer threads like in the examples of creating a ped and creating a vehicle.

Thread names
Your thread can have a name. Use opcode 03A4 to name your thread. It is essential if you need to end your thread from another part of the script with opcode 0459.

Loops
The example above shows you a thread that ends straight away. If you want the thread to run continuously, you have to loop the thread. For the most part, looping the thread requires opcode 0001 (or wait command) to be placed somewhere within the loop or else the game will crash. There are exceptions but it is safer to have it. The simplest loop has this format This thread will repeat itself indefinitely so be careful what you put in it.

Conditions
Conditional opcodes checks whether the action is performed rather than to perform the action. In Sanny Builder, they are noted by spaces between the opcode and the description of the opcode. Conditions start with IF statements that checks if an action is performed. For IF statements with more than one conditions, you need to either add and or or after 00D6: if.

if and means if all of the conditions are met. This means if both the first and second conditions are met, perform the command. Else jump to label CheckEnd.

if or means if either one of these conditions are met. This means if either the first or the second condition is met, perform the command. Else jump to label CheckEnd.

Opcodes normally starts with the number 0, but conditional opcodes can start with the number 8. This checks if the condition is NOT performed.

Final Notes
Using this format requires you to start a new game. If you do not understand what is being said here, try looking into the Tutorial Forum for more in-depth tutorials or the Mission Coding Forum on how to understand this.