GTA :: SA
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Welcome dear guest to our website! Enjoy!
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 Personal mission...

Go down 
AuthorMessage
Admin
Admin
Admin


Posts : 18
Join date : 2010-06-14

Personal mission... Empty
PostSubject: Personal mission...   Personal mission... EmptyTue Jun 15, 2010 12:05 pm

INFO
____________________________________________________

Opcodes
Sanny Builder has the latest compiled list of opcodes. It is located in the program's Opcode Search Tool feature. These opcodes have many functions so it's best to look through the entire list to get the feel of what is available to you. You can do so much with scripting with what you have already. To understand how each opcode does, either look at documentations of them littered throughout the web or test the opcodes yourself through trial and error. This is the best way to learn how to use opcodes. You can check the game's original script (main.scm) and see how the developers use the opcodes in their scripts.

Create a Thread
Creating a simple thread (simple script) 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.

STEP 1
____________________________________________________

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

Code:
create_thread

Insert before it:

Code:
004F: create_thread @mythread

"mythread" is an arbitrary label. You can name the label with anything.

STEP 2
____________________________________________________

Insert your contents
Next you have to insert the contents into your thread. Find
Code:
//-------------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
Code:
: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.

STEP 3
____________________________________________________

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 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

Code:
: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.

STEP 4
____________________________________________________

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 opccode and the description of the opcode. Conditions start with IF statements that checks if an action is performed.

Code:
 :Cbeck
 0001: wait 0 ms
 00D6: if
 // Conditional opcode
 004D: jump_if_false @CheckEnd
 // Command

:CbeckEnd
0002: jump @Check

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.

Code:
:Cbeck
 0001: wait 0 ms
 00D6: if and
 // First condition
 // Second condition
 004D: jump_if_false @CheckEnd
 // Command
 
 :CbeckEnd
 0002: jump @Check

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.

Code:
:Cbeck
 0001: wait 0 ms
 00D6: if or
 // First condition
 // Second condition
 004D: jump_if_false @CheckEnd
 // Command
 
 :CbeckEnd
 0002: jump @Check

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.
Using this format requires you to start a new game.


STEP 5
____________________________________________________

Create a Mission
Creating a mission is tough. The style is no different than creating a thread so it is recommended that you start practicing with simple threads and work your way up instead of attempting to create a mission right away. There are many ways to create a mission so to simplify this for beginners, the rest of the article will show the basic structure of creating a working mission. The format uses Sanny Builder. It should work for GTA3, Vice City, and San Andreas.

Define your mission
First define your mission. Find

Code:
DEFINE MISSIONS

Increment that number by one. Scroll down until you see the last defined mission. Define your mission below it.

Code:
DEFINE MISSION ### AT @MissionStart

STEP 6
____________________________________________________

Insert your trigger
Next create a thread that will trigger your mission to start. Find

Code:
create_thread

Insert before it

Code:
004F: create_thread @MissionTrigger

Find

Code:
//-------------Mission 0---------------

That is where the MAIN section ends and the first mission begins. Insert your trigger between that.

Code:
:MissionTrigger
 0001: wait 0 ms
 00D6: if
 0256:  player $PLAYER_CHAR defined
 004D: jump_if_false @MissionTriggerEnd
 00D6: if
 0038:  $ONMISSION == 0
 004D: jump_if_false @MissionTriggerEnd
 00D6: if
 // Place your condition to start your mission
 004D: jump_if_false @MissionTriggerEnd
 0417: start_mission ###
 0004: $ONMISSION = 1
 
 :MissionTriggerEnd
 jump @MissionTrigger

STEP 7
____________________________________________________

Insert your mission
Last insert your mission. If you are using GTA3 or Vice City, scroll all the way to the end of the file to insert your mission. If you are using San Andreas, find


Code:
//-------------External script 0 (PLAYER_PARACHUTE)---------------


That is where the last mission ends and the first external scrpt starts. Insert your mission between that.


Code:
:MissionStart
 03A4: name_thread 'NAME'
 0050: gosub @MissionBegin
 00D6: if
 0112:  wasted_or_busted
 004D: jump_if_false @MissionEnd
 0050: gosub @MissionFailed
 
 :MissionEnd
 0050: gosub @MissionCleanup
 004E: end_thread
 
 ::MissionBegin
 // This section is where you place the contents of your mission
 0051: return
 
 :MissionFailed
 // This section is what happens after you died or got busted during your mission
 0051: return
 
 :MissionCleanup
 // This section is where you clean up the contents of your mission so you can end it
 0004: $ONMISSION = 0
 00D8: mission_cleanup
 0051: return

That's all.
Enjoy Smile
Back to top Go down
https://4funteam-sa.darkbb.com
 
Personal mission...
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
GTA :: SA :: Others :: Tutorials :: How to create a mission...-
Jump to:  
Free forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com