Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    2. News

    1. Red Dead Redemption 2

      1. News
      2. Red Dead Online
    1. GTA Online

      1. After Hours
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

spaceeinstein

How To Create A Mission

Recommended Posts

spaceeinstein

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. Note that starting a new game is a requirement. With the advent of CLEO, you can insert scripts and missions without the need to start a new game, but the basic concepts of coding it remains the same.

 

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 Script

Creating a 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 script using Sanny Builder. It should work for GTA III, Vice City, and San Andreas.

 

Start your script

Prior to the advent of CLEO, this section was one of the first steps in understanding how to create scripts. First make sure you are working with a decompiled main.scm file. If you don't have a decompiled file, go to Sanny Builder and press F5. Find and open the main.scm file for decompiling. The program will create the main.txt file in the same directory. That is the file you will be working with. Now we need a command to start your first script by using opcode 004F (or create_thread command). Find:

create_thread
 

Insert before it

004F: create_thread @simple_script
 

simple_script is an arbitrary but unique name for a label. It helps the game locate your script.

 

Insert your code

Next create your script by inserting it in the appropriate place. Find:

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

That is where the MAIN section ends and the first mission begins. Insert your script between it. The simplest scripts have this format:

:simple_script
// Insert your code here
004E: end_thread
 

Your script can include a series of opcodes like creating a ped and creating a vehicle.

 

Loops

The example above shows you a script that ends immediately. If you want your script to run continuously, you have insert a loop. For most cases, looping 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:

:simple_script
while true
    0001: wait 0 ms
    // Insert your code here
end
 

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

 

Conditions

Conditional opcodes are used to check whether the action is performed rather than to perform the action. If the condition is satisfied, it returns true, otherwise it returns false. In Sanny Builder, conditional opcodes 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.

:simple_script
while true
    0001: wait 100 ms
    if
        // Conditional opcode, e.g.
        00E1:   player 0 pressed_key 13
    then
        // Command if the condition returns true, e.g. if the key is being pressed, then add $2000
        0109: player $PLAYER_CHAR money += 2000
    else
        // Command if the condition returns false, e.g. if the key is not being pressed, then subtract $10
        0109: player $PLAYER_CHAR money += -10
    end
end
 

For IF statements with more than one conditions, you need to either add and or or after if.

 

if and means if all of the conditions are met, then perform the command.

// ...
if and
    00E1:   player 0 pressed_key 4  // first condition
    00E1:   player 0 pressed_key 19  // second condition
then
    // command
end
// ...
 

This shows that if all conditions (if both keys 4 and 19 are pressed in this example) are met, the command will be performed. Otherwise, the code will skip the command and continue onwards.

 

if or means if any one of these conditions are met, then perform the command.

// ...
if or
    00E1:   player 0 pressed_key 4  // first condition
    00E1:   player 0 pressed_key 19  // second condition
then
    // command
end
// ...
 

This shows that if either condition (if either key 4 or key 19 is pressed in this example) is met, the command will be performed. Otherwise, the code will skip the command and continue onwards.

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

00E1:   player 0 pressed_key 4 // IS pressed
80E1:   not player 0 pressed_key 4 // is NOT pressed

 

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 script so it is recommended that you start practicing with simple scripts 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 GTA III, Vice City, and San Andreas.

 

Define your mission

First define your mission. Find:

DEFINE MISSIONS
 

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

DEFINE MISSION {xxx} AT @simple_mission
 

where {xxx} is the mission index, one more from the previous mission.

 

Insert your trigger

Next create a script that will trigger your mission to start. Find:

create_thread
 

Insert before it

 

004F: create_thread @mission_trigger
 

Find

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

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

:mission_trigger
while true
    0001: wait 0
    if
        0256:   player $PLAYER_CHAR defined
    then
        if
            $ONMISSION == 0
        then
            if
                // Condition to start your mission
            then
                0417: start_mission {xxx}
                $ONMISSION = 1
            end
        end
    end
end
 

where {xxx} is your mission index or the label of your mission.

 

Insert your mission

Lastly insert your mission. If you are using GTA III or Vice City, scroll all the way to the end of the file to insert your mission. If you are using San Andreas, find:

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

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

 

:simple_mission
03A4: name_thread 'MISSA'
0050: gosub @simple_mission_begin
if
    0112:   wasted_or_busted
then
    0050: gosub @simple_mission_failed
end
0050: gosub @simple_mission_cleanup
004E: end_thread

:simple_mission_begin
// Place the contents of your mission
0051: return

:simple_mission_failed
// Died or got busted during your mission
0051: return

:simple_mission_cleanup
// Clean up the contents of your mission so you can end it
$ONMISSION = 0
00D8: mission_cleanup
0051: return
 

Final note

Following this tutorial requires you to start a new game. CLEO is a newer and better way to insert scripts and missions into the 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.

Edited by spaceeinstein

Share this post


Link to post
Share on other sites
Indi

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

Share this post


Link to post
Share on other sites
spaceeinstein

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.

Edited by spaceeinstein

Share this post


Link to post
Share on other sites
Indi

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.

Edited by Indi.

Share this post


Link to post
Share on other sites
spaceeinstein

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.

Share this post


Link to post
Share on other sites
grim666

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)

Share this post


Link to post
Share on other sites
ThaGTAGamer

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

Share this post


Link to post
Share on other sites
ali amroo

thank you for this tutorial but is complicated.

 

------------

ali amroo

Share this post


Link to post
Share on other sites
Udra

Thanks for the info :]

Share this post


Link to post
Share on other sites
Rameez_Iqbal

How to edit cheat codes?????

Share this post


Link to post
Share on other sites
Wolf_Gamer

thank you so much

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.