Quantcast

Jump to content

» «
Photo

How To Create A Mission

9 replies to this topic
spaceeinstein
  • spaceeinstein

    巧克力

  • Members
  • Joined: 17 Jul 2003

#1

Posted 30 November 2008 - 01:25 AM Edited by spaceeinstein, 23 December 2008 - 10:16 PM.

A Guide to Understanding the Basics of Coding
(My interpretations)
See final notes for more useful links. This is going to sync with the articles in GTAModding.


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

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.

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.

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.

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.

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 Mission Coding Forum on how to understand this. A more in-depth look into how the script works is located here.

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


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


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


Final note
Using this format requires you to start a new game. If you do not understand what is being said here, try laboriously searching through the Mission Coding forum for more information.


GTAModding Article

If there are any errors, misunderstandings, or suggestions, post here.

Indi
  • Indi

    "Party's over, kid!"

  • Andolini Mafia Family
  • Joined: 22 Nov 2008
  • None

#2

Posted 11 December 2008 - 02:33 AM

You should add like a simple attack CJ script or something like that, it will help us some more. I get everything in this tutorial icon14.gif

spaceeinstein
  • spaceeinstein

    巧克力

  • Members
  • Joined: 17 Jul 2003

#3

Posted 11 December 2008 - 04:01 AM Edited by spaceeinstein, 11 December 2008 - 04:31 AM.

The first step is to create simple scripts. This tutorial is intended for those who already know how to make simple scripts. I'll try to make a tutorial on that later on. This is a tutorial though, I'll be only showing the basics of what you need to know so you can build on top of that.

Since this thread is here, I'll post links that can help putting contents into the threads/missions.

Coding Bible I
Coding Bible II
Too bad he didn't come back. He was on a roll with all those tutorials.

Indi
  • Indi

    "Party's over, kid!"

  • Andolini Mafia Family
  • Joined: 22 Nov 2008
  • None

#4

Posted 11 December 2008 - 04:41 AM Edited by Indi., 11 December 2008 - 04:50 AM.

I know how to do markers, pickups, car spawns e.t.c. but not everything else. I've always had trouble with missions, everything else I've been fine with. Oh and I also have another suggestion, you could start us off on threads and opcodes, and what not. I think that covers it.

spaceeinstein
  • spaceeinstein

    巧克力

  • Members
  • Joined: 17 Jul 2003

#5

Posted 23 December 2008 - 09:35 PM

I can't give examples to every opcodes that is available in the game. It's best for you to search for them and copy what they did or do trial and error. There are already successful mission scripts out there in the web and usually the user-made scripts are simpler to understand. My GTA2 Missions mod has the basic stuff for a working mission.

I've updated the first post with more contents.

grim666
  • grim666

    Player Hater

  • Members
  • Joined: 24 Dec 2008

#6

Posted 24 December 2008 - 01:23 PM

i don't know where to put this but does anyone know how to put the wall climbing sa script in a cleo file?
i just complains that i don't have label 1 (using sanny builder)

ThaGTAGamer
  • ThaGTAGamer

    Player Hater

  • Members
  • Joined: 30 Mar 2009

#7

Posted 05 April 2009 - 08:48 AM

Yo, thanks for tutorial, it is great, but, I don't understand so much in coding.. you know...
This helps ,e just a little bit. cryani.gif

ali amroo
  • ali amroo

    Player Hater

  • Members
  • Joined: 06 Apr 2010

#8

Posted 06 April 2010 - 11:02 AM

thank you for this tutorial but is complicated.

------------
ali amroo

Udra
  • Udra

    Player Hater

  • Members
  • Joined: 27 May 2010

#9

Posted 27 May 2010 - 03:46 PM

Thanks for the info :]

Rameez_Iqbal
  • Rameez_Iqbal

    Player Hater

  • Members
  • Joined: 01 Apr 2011

#10

Posted 20 October 2012 - 05:22 AM

How to edit cheat codes?????




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users