Difference between revisions of "Create a script"

From GTAMods Wiki
Jump to navigation Jump to search
(New page: 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...)
 
m
Line 2: Line 2:
  
 
==Create your thread==
 
==Create your thread==
First create your thread using [[004F]] (or create_thread). Find
+
First create your thread using [[004F]] (or ''create_thread'' command). Find
 
   create_thread
 
   create_thread
 
Insert before it
 
Insert before it
 
   004F: create_thread @mythread
 
   004F: create_thread @mythread
<i>mythread</i> is an arbitrary label. You can name the label with anything.
+
''mythread'' is an arbitrary label. You can name the label with anything.
  
 
==Insert your contents==
 
==Insert your contents==
Line 18: Line 18:
  
 
==Loops==
 
==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. Looping the thread requires [[0001]] (wait) to be placed somewhere within the loop or else the game will crash. The simplest loop has this format
+
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. Looping the thread requires [[0001]] (or ''wait'' command) to be placed somewhere within the loop or else the game will crash. The simplest loop has this format
 
   :mythread
 
   :mythread
 
   [[0001]]: wait 0 ms
 
   [[0001]]: wait 0 ms

Revision as of 04:15, 11 December 2008

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 GTA3, Vice City, and San Andreas.

Create your thread

First create your thread using 004F (or create_thread command). Find

 create_thread

Insert before it

 004F: create_thread @mythread

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

 //-------------Mission 0---------------

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

 :mythread
 // Insert your contents here
 004E: end_thread

The contents can include simple opcodes or longer threads like in the examples of creating a ped and creating a vehicle.

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. Looping the thread requires 0001 (or wait command) to be placed somewhere within the loop or else the game will crash. The simplest loop has this format

 :mythread
 0001: wait 0 ms
 // Insert your contents here
 0002: jump @mythread

This thread will repeat itself indefinitely so be careful what you put in it.

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.