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

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

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

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

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. 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. News

    2. Forum Support

    3. Site Suggestions

Please be aware that this is not a tutorial request forum! Use the appropriate topic for the effect.
Sign in to follow this  
T@zz

CLEO Advanced Script tutorial

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

 

 

Share this post


Link to post
Share on other sites
DK22Pac

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

Share this post


Link to post
Share on other sites
Gyaviste

How to switch to high level syntax?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

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