I have been meaning to do a tut in English, as I know that many of know only speak that language , now this will explain things, for information on things please browse our mission coding forum. Anyway the point of this is to help, when you first get into mission coding, everything is going to be very hard, even if the task is generally easy.
Getting started, the tools you need to get started are the following Sanny Builder this is the best tool for compiling the scripts you make. Additionally there exist other tools such as Point, or Barton Water duck's Mission Builder, however none of these tools are as effective as Sanny Builder, if you choose to download one of these other than Sanny Builder that is your choice. However this tut actually does apply to Sanny Builder more.
Now this tool is generally for decompiling the main.scm file, the main.scm file is a binary type file, that contains most of the games script. If you open this file with a hexadecimal editor(e.g. Hex Workshop, Flex HEX, and Hex editor Neo), it will look something like the following:
When you downloaded Sanny Builder do not expect everything done for you, remember YOU are the programmer(scripter), Sanny Builder is your girlfriend , (if your a female, I'm not trying to call you a gay, I'm just assuming your a male), install Sanny Builder, follow the intrustions she gives you, once installed, open a new page in Sanny Builder copy-&-paste this small script for your first experience:
In the top of Sanny Builder there is a option which says "Run"(if you have your Sanny Builder in a different language for example in German "Run" is "Start" in Russian for example "Зеофсл"), anyway click on this and click "Compile" there is a screen(my Sanny Builder is in Russian language) :
F5 = De-compile a file
F6 = Compile
F7 = Compile & Copy
F8 = Run GTA: San Andreas
After you have did this you will see something like that(of course that the design of Sanny Builder is based up-on Windows Version):
The file becomes a CS file, now what you choose to do with this file now is up to you generally, you may delete it.
Download ZAZ's CLEO 3 basics from there And read the ReadMe file
{$CLEO .cs} = The CLEO script detective, and {$CLEO} also means the same, where as {$CLEO .cm} stands for a CLEO mission.
If you press # while in Sanny Builder a list of models name will appear, now obviously not all model are on this, only defined ones, as of Sanny Builder v3.04 Sanny Builder has the feature to convert model names to there ID and vise versa. Use the Ctrl+Alt+H feature to convert a model name to ID and vice versa.
A beginner in mission coding should start with the most easiest thing possible for example a car spawn script, thus, the user can learn, a beginner should never try to make a mission, experience comes slowly, if you are jump to a head of your limits your going to feel way out of your league,
A simple car spawn script:
XYZ are the co-ordinates of where the vehicle is placed, and angle is the Z angle of the vehicle. 014C is needed to tell the vehicle to generate 0 means do not, and 101 means the vehicle can spawn, 0A17 sets the vehicle owned to the player, so if a cop sees you enter it you will not get a wanted star, 0A93 ends the thread, the thread is read once, because it is not in a loop, it is not necessary for it to be in one, as this will keep spawning that vehicle over and over again. (Note: If you save, this vehicle will always be present in the that save game file because of opcode 0A95). To get co-ordinates you can right click on your mouse on Sanny Builder and go to player coords(or CTRL+SHIFT+C, for player coords insert) (CTRL+SHIFT+E for the players angle). (Ctrl = Strg on a German keyboard).
Sanny Builder has built in tools go to tools in Sanny Builder menu
Going to "ID tools" in the "Tools" menu there is two options "Player Coords and angle" or "Opcode Search Tool"
To search for a opcode type something like if your search for a car opcode type "car", in the co-ordinates manger, you get the co-ordinates of your player, stand in a place of the game and go to this to get the players coords, you can also get insert the players coords and angle by clicking right mouse button, then select "Insert" then "Player Coords" (or CTRL+SHIFT+C, for player coords insert).
In the options menu also exist "code converter", "make opcodes text" "Add macro" and "Options", in the "Options" here you can select/change a lot of options. The "Options" menu has 4 tabs, "general", "Formats", "Editor", and "Highlighter", the "general" tab has options such as select different languages such as Russian, German, English, and more.
Selecting the language:
Now my Sanny Builder is in Russian:
0A93: end_custom_thread lets a CLEO script end.
The original version of this code of the main.scm is 004E: end_thread
This same opcode must be used when ending a CLEO mission script.
Again:
0A93: end_custom_thread should be used in normal CLEO scripts to end the thread:
004E: end_thread in s CLEO mission script:
004F: create_thread @Label(or create_thread @Label)starts an ordinary thread in the main.scm, in CLEO scripts/missions, we do not use this - there is no need. Scripts with the extension(*.cs) are loaded when the game starts, in addition we can make a file with extension(*.s), this is not loaded, when the game starts, and you can start the script through a normal CLEO script/mission:
Read more about this opcode in Sanny Builder -> Help -> CLEO 3: opcodes
(ThreadName will be the name of the file your starting with the extension(*.s)).
In CLEO scripts, to start missions we create a normal script, and start the *.cm(Custom Mission) file through this script:
So this would start a mission file with the name "MyMission.cm" note; that the file extension is not needed to specify, this opcode was made to search for a file with the extension (*.cm)
This starts a mission script of the main.scm. This opcode can also be used in a CLEO script, to start a mission of the main.scm
CLEO scripts with the extension *.cs are loaded when the game has been started. If the script has a parked car generator, and if you save your game the vehicle will be copied. This happens with the parked car generators, pickups, and script placed objects.
To prevent you need to use this opcode in that CLEO script:
To understand this you need to understand normal global and local variables,
using global variables in CLEO scripts can cause bugs or/and crashes, Seemann made such opcodes to help with this problem. Opcode 0AB3 and 0AB4 accordingly, var 0 up to var 999 can be stored.
For beginners only simple struct should be used use 0A93: end_custom_thread in CLEO script to end the thread(in main.scm use 004E: end_thread to make the code be read more than once and be in a loop jump and re-loop it, a wait is needed if the code is within a running loop.
Code within a loop:
This is needed most of the time, usually it will not be needed if the code does not have the player in it, or does not check to check if defined - this opcode is used as a condition and if it's false, it means the player has been wasted or busted.
In the latest version of Sanny Builder, it has the option to convert
hexadecimal numbers to decimal ones and vice versa (Ctrl+H).
@ (at sign)is a common data type, this sign is used for two things:
1: In jump instruction to tell the script where what label to go to. These opcodes:
2: The local varible sign
The local variables are made with a number, and then the @ sign
In ranges 0@...31@ is possible in normal threads, 32@ and 33@ are for timers. In mission scripts you use local variables in ranges 0@...1023@
$ (dollar sign) is common data type, and is used to mark the global variables.
The global variables are made with numbers, words, and etc, and then the $ sign. As has been said, using global variables in CLEO scripts can cause stupid bugs bugs or/and crashes.
Some global variables such as $PLAYER_CHAR, $PLAYER_ACTOR, $ONMISSION are valid, and ones in the Customvariables.ini. global variables nubmers DO have a limit, to this limit is: 16383
# Marks a model name of a model:
In CLEO scripts models which are defined in vehicles.ide, peds.ide or default.ide can only be used. For the others use there ID, you can display a list by typing # in Sanny Builder, in the main.scm the list will also contain the models which have been defined at the beginning of the main.scm.
'...'
Short strings, like the GXT entry's:
"..."
Long string to insert body part names, particle names, IFP files, texture names, etc:
@s - This repents a local short sting varible, it can be used like this:
@v This repents a local long sting varible, it can be used like this:
s$ - This repents a global short sting varible, it can be used like this:
sv - This repents a global long sting varible, it can be used like this:
...more to come...
Getting started, the tools you need to get started are the following Sanny Builder this is the best tool for compiling the scripts you make. Additionally there exist other tools such as Point, or Barton Water duck's Mission Builder, however none of these tools are as effective as Sanny Builder, if you choose to download one of these other than Sanny Builder that is your choice. However this tut actually does apply to Sanny Builder more.
Now this tool is generally for decompiling the main.scm file, the main.scm file is a binary type file, that contains most of the games script. If you open this file with a hexadecimal editor(e.g. Hex Workshop, Flex HEX, and Hex editor Neo), it will look something like the following:
When you downloaded Sanny Builder do not expect everything done for you, remember YOU are the programmer(scripter), Sanny Builder is your girlfriend , (if your a female, I'm not trying to call you a gay, I'm just assuming your a male), install Sanny Builder, follow the intrustions she gives you, once installed, open a new page in Sanny Builder copy-&-paste this small script for your first experience:
- Code:
{$CLEO}
0000:
while true
wait 250
if
0256: player $PLAYER_CHAR defined
then
if
00E1: key_pressed 0 17
then
00BA: text_styled 'FEM_OK' 1000 ms style 1
break
end
end
end
0A93: end_custom_thread
In the top of Sanny Builder there is a option which says "Run"(if you have your Sanny Builder in a different language for example in German "Run" is "Start" in Russian for example "Зеофсл"), anyway click on this and click "Compile" there is a screen(my Sanny Builder is in Russian language) :
F5 = De-compile a file
F6 = Compile
F7 = Compile & Copy
F8 = Run GTA: San Andreas
After you have did this you will see something like that(of course that the design of Sanny Builder is based up-on Windows Version):
The file becomes a CS file, now what you choose to do with this file now is up to you generally, you may delete it.
Download ZAZ's CLEO 3 basics from there And read the ReadMe file
{$CLEO .cs} = The CLEO script detective, and {$CLEO} also means the same, where as {$CLEO .cm} stands for a CLEO mission.
If you press # while in Sanny Builder a list of models name will appear, now obviously not all model are on this, only defined ones, as of Sanny Builder v3.04 Sanny Builder has the feature to convert model names to there ID and vise versa. Use the Ctrl+Alt+H feature to convert a model name to ID and vice versa.
A beginner in mission coding should start with the most easiest thing possible for example a car spawn script, thus, the user can learn, a beginner should never try to make a mission, experience comes slowly, if you are jump to a head of your limits your going to feel way out of your league,
A simple car spawn script:
- Code:
{$CLEO}
0000:
0A95: enable_thread_saving
014B: 0@ = init_parked_car_generator #INFERNUS -1 -1 1 alarm 0 door_lock 0 0 10000 at x y z angle 180.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101
0A17: set_parked_car_generator 0@ to_player_owned 1
0A93: end_custom_thread
XYZ are the co-ordinates of where the vehicle is placed, and angle is the Z angle of the vehicle. 014C is needed to tell the vehicle to generate 0 means do not, and 101 means the vehicle can spawn, 0A17 sets the vehicle owned to the player, so if a cop sees you enter it you will not get a wanted star, 0A93 ends the thread, the thread is read once, because it is not in a loop, it is not necessary for it to be in one, as this will keep spawning that vehicle over and over again. (Note: If you save, this vehicle will always be present in the that save game file because of opcode 0A95). To get co-ordinates you can right click on your mouse on Sanny Builder and go to player coords(or CTRL+SHIFT+C, for player coords insert) (CTRL+SHIFT+E for the players angle). (Ctrl = Strg on a German keyboard).
Useful Tools
Sanny Builder has built in tools go to tools in Sanny Builder menu
Going to "ID tools" in the "Tools" menu there is two options "Player Coords and angle" or "Opcode Search Tool"
To search for a opcode type something like if your search for a car opcode type "car", in the co-ordinates manger, you get the co-ordinates of your player, stand in a place of the game and go to this to get the players coords, you can also get insert the players coords and angle by clicking right mouse button, then select "Insert" then "Player Coords" (or CTRL+SHIFT+C, for player coords insert).
In the options menu also exist "code converter", "make opcodes text" "Add macro" and "Options", in the "Options" here you can select/change a lot of options. The "Options" menu has 4 tabs, "general", "Formats", "Editor", and "Highlighter", the "general" tab has options such as select different languages such as Russian, German, English, and more.
Selecting the language:
Now my Sanny Builder is in Russian:
CLEO considerations
0A93: end_custom_thread lets a CLEO script end.
The original version of this code of the main.scm is 004E: end_thread
This same opcode must be used when ending a CLEO mission script.
- Code:
004E: end_thread
Again:
0A93: end_custom_thread should be used in normal CLEO scripts to end the thread:
- Code:
{$CLEO .cs}
// ....script
0A93: end_custom_thread
004E: end_thread in s CLEO mission script:
- Code:
{$CLEO .cm}
/ ....mission
004E: end_thread
004F: create_thread @Label(or create_thread @Label)starts an ordinary thread in the main.scm, in CLEO scripts/missions, we do not use this - there is no need. Scripts with the extension(*.cs) are loaded when the game starts, in addition we can make a file with extension(*.s), this is not loaded, when the game starts, and you can start the script through a normal CLEO script/mission:
- Code:
0A92: create_custom_thread "ThreadName.s"
Read more about this opcode in Sanny Builder -> Help -> CLEO 3: opcodes
(ThreadName will be the name of the file your starting with the extension(*.s)).
In CLEO scripts, to start missions we create a normal script, and start the *.cm(Custom Mission) file through this script:
- Code:
0A94: start_custom_mission "MyMission"
So this would start a mission file with the name "MyMission.cm" note; that the file extension is not needed to specify, this opcode was made to search for a file with the extension (*.cm)
- Code:
0417: start_mission 4
This starts a mission script of the main.scm. This opcode can also be used in a CLEO script, to start a mission of the main.scm
Store the Script State
CLEO scripts with the extension *.cs are loaded when the game has been started. If the script has a parked car generator, and if you save your game the vehicle will be copied. This happens with the parked car generators, pickups, and script placed objects.
To prevent you need to use this opcode in that CLEO script:
- Code:
0A95: enable_thread_saving
Special vars
To understand this you need to understand normal global and local variables,
using global variables in CLEO scripts can cause bugs or/and crashes, Seemann made such opcodes to help with this problem. Opcode 0AB3 and 0AB4 accordingly, var 0 up to var 999 can be stored.
- Code:
0AB4: 1@ = var 15
0AB3: var 0 = 1@
Script Structure
For beginners only simple struct should be used use 0A93: end_custom_thread in CLEO script to end the thread(in main.scm use 004E: end_thread to make the code be read more than once and be in a loop jump and re-loop it, a wait is needed if the code is within a running loop.
Code within a loop:
- Code:
{$CLEO}
0000:
:Example
0001: wait 250 ms // -- this is needed at the code is within a loop
00d6: if
0256: player $PLAYER_CHAR defined
004d: jump_if_false @Example
00d6: if
0ab0: key_pressed 8
004d: jump_if_false @Example
08b2: toggle_thermal_vision 1
:Example_02
0001: wait 0 ms // --
00d6: if
0256: player $PLAYER_CHAR defined
004d: jump_if_false @Example_02
00d6: if
0ab0: key_pressed 8
004d: jump_if_false @Example_02
08b2: toggle_thermal_vision 0
0002: jump @Akt_01 // retrun to restart the script
- Code:
0256: player $PLAYER_CHAR defined
This is needed most of the time, usually it will not be needed if the code does not have the player in it, or does not check to check if defined - this opcode is used as a condition and if it's false, it means the player has been wasted or busted.
Hexadecimal Convert
In the latest version of Sanny Builder, it has the option to convert
hexadecimal numbers to decimal ones and vice versa (Ctrl+H).
Data Types
@ (at sign)is a common data type, this sign is used for two things:
1: In jump instruction to tell the script where what label to go to. These opcodes:
- Code:
0002: jump @Label
0050: gosub @Label
004D: jump_if_false @Label
2: The local varible sign
The local variables are made with a number, and then the @ sign
In ranges 0@...31@ is possible in normal threads, 32@ and 33@ are for timers. In mission scripts you use local variables in ranges 0@...1023@
$ (dollar sign) is common data type, and is used to mark the global variables.
The global variables are made with numbers, words, and etc, and then the $ sign. As has been said, using global variables in CLEO scripts can cause stupid bugs bugs or/and crashes.
Some global variables such as $PLAYER_CHAR, $PLAYER_ACTOR, $ONMISSION are valid, and ones in the Customvariables.ini. global variables nubmers DO have a limit, to this limit is: 16383
# Marks a model name of a model:
- Code:
0247: load_model #INFERNUS
In CLEO scripts models which are defined in vehicles.ide, peds.ide or default.ide can only be used. For the others use there ID, you can display a list by typing # in Sanny Builder, in the main.scm the list will also contain the models which have been defined at the beginning of the main.scm.
'...'
Short strings, like the GXT entry's:
- Code:
07FB: set_interior 'GYM1' access 1 // Ganton Gym
"..."
Long string to insert body part names, particle names, IFP files, texture names, etc:
- Code:
087B: set_player $PLAYER_CHAR clothes_texture "PLAYER_FACE" model "HEAD" body_part 1
@s - This repents a local short sting varible, it can be used like this:
- Code:
05AA: 0@s = 'ENTRY'
00BC: show_text_highpriority GXT 0@s time 5000 flag 1
@v This repents a local long sting varible, it can be used like this:
- Code:
06D2: 0@v = "IFPFILE" // @v = string
0812: AS_actor $PLAYER_ACTOR perform_animation "Name" IFP_file 0@v 1000.0 loopA 0 lockX 0 lockY 0 lockF 1 time -1
s$ - This repents a global short sting varible, it can be used like this:
- Code:
05A9: s$_GXT_Reference = 'GXT'
00BC: show_text_highpriority GXT s$_GXT_Reference time 5000 flag 1
sv - This repents a global long sting varible, it can be used like this:
- Code:
06D1: v$1200 = "Bat_block"// 16-byte strings
0605: actor $PLAYER_ACTOR perform_animation_sequence v$1200 from_file "BASEBALL" 4.0 1 0 0 0 -1 ms
...more to come...
Last edited by gtasbigfoot on Thu Apr 16, 2009 1:42 am; edited 2 times in total