Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Forum Support

    3. Suggestions

CLEO Advanced Script tutorial


T@zz
 Share

Recommended Posts

This is CLEO Advanced script tutorial. It will be useful to beginners as well as intermediates and advanced modders. High Level scripting is not so difficult as you might think on the other hand it's a bit easier if you grasp the concept clearly. I know there is a great tutorial about CLEO Scripting by ZAZ but it doesn't include clearly the concepts like high level scripting, using high level structures, call scm method, memory scripting etc. But to understand the tutorial fully you do need to know the basic of scripting.

Now without wasting time let’s start our tutorial.

 

HIGH LEVEL STRUCTURES

Conditional statements: Sanny Builder supports high level conditional statements like:

IF...THEN...END statement:

High Level syntax:

 

if                key_pressed 8                      // Condition           then                0A1E: dump_screen 1  // Action                end

In Low Level:

 

:slow_10001: wait  0 msif0AB0:   key_pressed 8//-----------------key = Backspace004D: jump_if_false @slow_10A1E: dump_screen 1  // Action0002: jump @slow_1

IF...THEN...ELSE..END statement:

High Level Syntax:

 

ifPlayer.Defined($PLAYER_CHAR)thenActor.DestroyInstantly($PLAYER_ACTOR)elsePlayer.Build($PLAYER_CHAR)end

 

Will be same as:

Low level:

 

ifPlayer.Defined($PLAYER_CHAR)jf @LABELActor.DestroyInstantly($PLAYER_ACTOR)jump @LABEL2:LABELPlayer.Build($PLAYER_CHAR):LABEL2

 

Now let’s work with it by using the above script in a CLEO Script:

(In low level script)

 

{$CLEO} :slow_003A4: name_thread 'SLW' :slow_10001: wait  0 msif0AB0:   key_pressed 8//-----------------key = Backspace004D: jump_if_false @slow_1015D: set_gamespeed  .30001: wait  50 ms :slow_20001: wait  0 msif0AB0:   key_pressed 8//-----------------key = Backspace004D: jump_if_false @slow_2015D: set_gamespeed  1.00001: wait  1000 ms0002: jump @slow_1 

Will be same as:

 

{$CLEO}0000:while true   wait 0    if        key_pressed 8    then        015D: set_gamespeed 0.3        wait 50    end       if        key_pressed 8    then    015D: set_gamespeed 1.0    wait 1000    endend

 

Try to look at the code you will easily understand the High level script easily than the low level.

You might have come across the while structure, so let’s know workaround with it.

WHILE...END Structure

Loop WHILE is working until the condition returns True. The condition is evaluated before the loop iterations. Hence, if the condition is false, the statement sequence is never executed.

The general syntax is as follows:

WHILE <condition>...END

Operator WHILE may accept the logic constants True and False:

While True..End - loop executes infinitely until the loop stopped by command Break.

While False .. End - loop is ignored by the compiler.

 

Using Continue & Break commands:

If you want to skip the current iteration and proceed to the next, use the command Continue. You can use it as (jf continue) or as only continue.

Ex:

// Use of jf continue commandifkey_pressed 8jf continue // uses instead of a label // *****************************// //Use of continue as separate command ifnot key_pressed 8thencontinue // uses as a jump to the next iteration

The useful command, Break, causes the flow of loop to exit. It can be used both as a separate command or parameter (jf break).It also stops the while true...end loop.

For...End loop:

General Syntax:

 

FOR <counter> = <initial value> TO/DOWNTO <final value> step <int> = 1...END

<counter> - variable that is used as the loop iterations (repeats) counter.

<initial value> - starting value of the counter (any value including the model identifiers).

TO/DOWNTO - at TO the counter is increased, at DOWNTO - is decreased.

<final value> - - final value of the loop when finished.
(any value including the model identifiers).

<step> - value of an increment or reduction of the counter after iteration.
(optional). By default its value is equal to 1.

Basically this is quite old command & not pretty usable still you can use it for many purposes like:

Clearing map fog:

{$CLEO}for [email protected] = 354164 to 354188&0([email protected],1i) = 16843009end

Can be used for Checking all peds, weapons etc..I just lack much ideas with for loop.

Anyways let’s move to next part.

REPEAT..UNTIL statement:

This loop continues until the condition is returned either true or false depending upon the logic operator used.

Repeat .. Until True - loop has the only iteration
Repeat .. Until False - loop executes infinitely until it's stopped by Break.

 

KEYWORDS:

Sanny Builder provides you some useful keywords which can be used instead of the opcodes.

For example:

wait 0 is same as 00001: wait 0

create_thread @NONAME_01 is same as 0004: create_thread @NONAME_01

By pressing CTRL + SPACE you can view the list of all keywords.

 

VAR..END Structure:

VAR..END contruct allows to declare variables and their types for advanced use. You can use them as special CLEO Global variables as using simple Global variables will create crashes or random bugs.

Example:

 

var  $TIME : Int   // Declare the data type of the variable as Int, Float.$SCORE : Int  //Same as above ?end$TIME = 180000                        //Same as below ?$SCORE = 0                       //Using the variable in the script.end_custom_thread                    //same as 004E:

A code snippet from my RC Mission mod.

 

Also you can set an initial value for the variable when declaring it.
For this purpose write symbol = and after that, the initial value
:

var$fVar: float = 1.0end

 

Variable $fVar will be remembered as Float and also the compiler will write an opcode in the SCM.

0005: $fVar = 1.0 

Initialization is allowed for the variables only.

 

 

More things would be added soon.

TO DO LIST:

 

  • call_scm_functions
  • hex..end structures
  • Memory scripting
  • Arrays (Advanced way)
  • etc..

 

 

Link to comment
Share on other sites

That is not advanced scripting, that's SB syntax.

  • KEKW 2
Link to comment
Share on other sites

  • 8 months later...

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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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