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. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    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 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 Mods
    10. GTA Vice City

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

      1. Guides & Strategies
      2. Help & Support
      3. GTA 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

ZAZ

[SA] ~ CLEO Script Tutorial ~

Recommended Posts

Diegoti

 

Hello i have to said something:

I come from the Warcraft 3 world editor, where all the scripts had three factors.

 

Event -> Something that must happen for the script to run

examples: cj jumps, a car explodes, cj dies, cj enters X area. etc

Standart Cleo scripts start automaticly as soon as ingame world is present, initialized by cleo.asi

 

As example a very simple script that displays the internal timer [email protected]

(local variable [email protected] and [email protected] are reserved for timer, never use it for anything else)

 

Low level script

 

{$CLEO .cs}thread 'TIMER':Runwait 003F0: enable_text_draw 1045A: text_draw_1number  100.0  200.0 'NUMBER' [email protected]    // valuejump @Run
High level script

 

{$CLEO .cs}thread 'timer'while truewait 003F0: enable_text_draw 1 045A: draw_text_1number 100.0  200.0 GXT 'NUMBER' number [email protected]

It's also possible to initialized a script by another script. In any way, it requires always a standart cleo script initialized by cleo.asi as trigger script

1. The mission script

 

The trigger script needs opcode 0A94: to start a mission script

 

{$CLEO .cs}thread 'Trigger'$ONMISSION =  10A94: start_custom_mission "MyMission"0A93: end_custom_thread
The mission script must have {$CLEO .cm} as *.cm file and the file must have the name that is called by the trigger script, in this case MyMission.cm

 

{$CLEO .cm}thread 'Mission'00BA: text_styled 'M_PASS'  5000 ms  1$ONMISSION =  0004E: end_thread

 

 

2. Another standart cleo script with extention *.s

 

The trigger script needs opcode 0A92: to start a another standart cleo script

 

{$CLEO .cs}thread 'Trigger'0A92: create_custom_thread "timer.s"0A93: end_custom_thread
The other script must have {$CLEO .s} as *.s file and the file must have the name that is called by the trigger script, in this case timer.s

 

{$CLEO .s}thread 'timer'while truewait 003F0: enable_text_draw 1 045A: draw_text_1number 100.0  200.0 GXT 'NUMBER' number [email protected]    if        [email protected] > 7000    then        [email protected] = 0    endend
you can also give other extensions by renaming the file manually, for example rename timer.s into timer.xxx

and use following in the trigger script:

 

0A92: create_custom_thread "timer.xxx"

 

 

Condition -> This is what decides to run or not to run the script (its like a IF)

example: cj dies -> if cj is in x area -> run action so

Condition isn't required to run a script but it's the propper way to let the code pass inside the the script to the action part.

Also should the trigger script have conditions in case if you want to start another script.

 

But mostly we have a standart Cleo script that starts automaticly

Best way is to build a loop, let's say a default loop that contains the main conditions, that needs to be passed and then can go to the action codes

Check always if player_char is present or ready with opcode 0256: and then the main condition, then the action

And in following an action loop that contains again 0256:

check the script inside the spoiler, it let the player_char do animation by keypress backspace

 

 

Low level script

 

{$CLEO .cs}:IFP_PARKthread 'IFPPARK':IFP_PARK_1wait 0if0256:   player $PLAYER_CHAR definedjf @IFP_PARK_1if0AB0:   key_pressed 8//-----------------key = Backspacejf @IFP_PARK_104ED: load_animation "PARK":IFP_PARK_5wait 0if04EE:   animation "PARK" loadedjf @IFP_PARK_50812: AS_actor $PLAYER_ACTOR perform_animation "Tai_Chi_Loop" IFP_file "PARK" 1.0 loopA 1 lockX 1 lockY 1 lockF 0 time -1 // versionB0001: wait 1000 ms:IFP_PARK_7wait 0if0256:   player $PLAYER_CHAR definedjf @IFP_PARK_12if and8AB0:   not key_pressed 8//-----------------key = Backspace80E1:   not player 0 pressed_key 15jf @IFP_PARK_12jump @IFP_PARK_7:IFP_PARK_120792: disembark_instantly_actor $PLAYER_ACTOR04EF: release_animation "PARK"0001: wait 1000 msjump @IFP_PARK_1
High level script

 

{$CLEO .cs}thread 'Tai_Chi'while truewait 0    if        0256:   player $PLAYER_CHAR defined    then        if            0AB0:   key_pressed 8//-----------------key = Backspace        then            04ED: load_animation "PARK"                    while 84EE:  not animation "PARK" loaded                wait 0            end            0812: AS_actor $PLAYER_ACTOR perform_animation "Tai_Chi_Loop" IFP_file "PARK" 1.0 loopA 1 lockX 1 lockY 1 lockF 0 time -1 // versionB            wait 1000                        while 0256:   player $PLAYER_CHAR defined                wait 0                if or                    0AB0:   key_pressed 8//-----------------key = Backspace                    00E1:   not player 0 pressed_key 15// --- key = Enter/Exit                then                    break                end                end                       0792: disembark_instantly_actor $PLAYER_ACTOR            04EF: release_animation "PARK"             wait 1000        end    endend

 

 

Note: it's important to check if the stuff is alive

check if actor isn't dead if he should do something

check if the car isn't wrecked if it do something of should give informaions

 

Other example:

Cj enters to X area -> If cj is driving a Hydra -> Add 6 stars

Ok, script below gives 6 stars in case if cj is driving a Hydra at Grovesstreet, if not it gives 0 stars

 

 

Low level script

 

{$CLEO .cs}thread 'HYDRA' :HYDRA_1wait 0 if 0256:   player $PLAYER_CHAR defined jf @HYDRA_1 if and00FE:   actor $PLAYER_ACTOR sphere 1 in_sphere 2487.653 -1669.195 13.3359 radius 90.0 90.0 350.0 00DD:   actor $PLAYER_ACTOR driving_car_with_model #HYDRA jf @HYDRA_1 010D: set_player $PLAYER_CHAR wanted_level_to 6 :HYDRA_3wait 0if0256:   player $PLAYER_CHAR defined jf @HYDRA_5 if or80FE:   not actor $PLAYER_ACTOR sphere 0 in_sphere 2487.653 -1669.195 13.3359 radius 100.0 100.0 400.0 80DD:   not actor $PLAYER_ACTOR driving_car_with_model #HYDRA jf @HYDRA_3 :HYDRA_5010D: set_player $PLAYER_CHAR wanted_level_to 0 jump @HYDRA_1 
High level script

 

{$CLEO .cs}thread 'HYDRA'while truewait 0    if        0256:   player $PLAYER_CHAR defined    then        if and            00FE:   actor $PLAYER_ACTOR sphere 1 in_sphere 2487.6528 -1669.1953 13.3359 radius 90.0 90.0 350.0            00DD:   actor $PLAYER_ACTOR driving_car_with_model #hydra        then            010D: set_player $PLAYER_CHAR wanted_level_to 6                        while 0256:   player $PLAYER_CHAR defined                wait 0                if or                    80FE:  not actor $PLAYER_ACTOR sphere 0 in_sphere 2487.6528 -1669.1953 13.3359 radius 100.0 100.0 400.0                    80DD:  not actor $PLAYER_ACTOR driving_car_with_model #hydra                then                    break                end                        end                        010D: set_player $PLAYER_CHAR wanted_level_to 0                    end    endend 

 

Thanks bro!

Share this post


Link to post
Share on other sites
Evil empire

I found a solution with the missing Frosted winter bonus.

 

I'd still like to know about unlocking the quadruple insane stunt through CLEO, please.

Share this post


Link to post
Share on other sites
ZAZ
Posted (edited)

You can't modify main.scm code by cleo script

have you read here and here?

Edited by ZAZ

Share this post


Link to post
Share on other sites
Recommended

@MH-T88

 

I don't think Zaz's Cleo tutorial topic should be used for requesting. It's kind of rude to drop in here and demand someones cleo mod to be fixed. This is more suited: GTA 3D Era Modding Requests & Finds

Share this post


Link to post
Share on other sites
MH-T99
12 hours ago, Recommended said:

@MH-T88

 

I don't think Zaz's Cleo tutorial topic should be used for requesting. It's kind of rude to drop in here and demand someones cleo mod to be fixed. This is more suited: GTA 3D Era Modding Requests & Finds

Sorry, I didn't know this is not the suitable topic. My mistake.

Share this post


Link to post
Share on other sites
LordStarship
On 5/3/2018 at 1:56 PM, Diegoti said:

Hello i have to said something:

I come from the Warcraft 3 world editor, where all the scripts had three factors.

 
Event -> Something that must happen for the script to run
examples: cj jumps, a car explodes, cj dies, cj enters X area. etc
 
Condition -> This is what decides to run or not to run the script (its like a IF)
example: cj dies -> if cj is in x area -> run action so
 
Action -> here is where you specify what will happen
example: cj enters a vehicle (event) -> the vehicle is a Rhino (condition or "if") -> explode vehicle (action)
 
Other example:
Cj enters to X area -> If cj is driving a Hydra -> Add 6 stars
""""""""""""""""""""""""---""""""""""""""""""""""""""""----"""""""""""""""

 

I can understand better if someone explains to me where the "event" and "condition" is.

For WC3 editor, the structure is this:

 

Event Occur > Check Condition > Run Actions

 

As someone that has experienced with the editor for a while, it does work as same as CLEO, but it is easier to do rather than using opcodes.

 

For example:

Event: A unit dies

Condition: Owner of unit is Player 1(Red) and the unit-type is Thrall

Action: Player 1(Red) defeat

Player 2(Blue) victory

 

That is the example of it, if you make it with SannyBuilder it would be like this:

(sorry there are no opcodes and the words aren't as same as the original opcode because i have no time to check Sanny lol)

 

{CLEO. cs}

name_thread 'WC3EX'

 

:WC3EX_12

wait 0

if

Player.Defined ($PLAYER_CHAR)

jf @WC3EX_12

 

:WC3EX_38

load_model #THRALL //Custom model Thrall

load_requested_model

 

:WC3EX_52

@12= (X Coord)

@13= (Y Coord)

@14= (Z Coord)

wait 0

if

model #THRALL available

jf @WC3EX_52

jump @WC3EX_107

 

:WC3EX_107

@4= Actor.Create(CIVMALE, #THRALL, @12, @13, @14)

set_actor @4 health_to 1000

AS_actor @4 attack $PLAYER_ACTOR

 

//Event, Condition//

repeat

wait 0

until actor @4 dies

 

//Action//

play (Mission passed sound)

show text 'MISSPAS' style 1 5000 ms

 

The FXT 'MISSPAS' file can be like this:

 

MISSPAS Mission Passed! The Horde is now your enemy!

 

The Event is:

Actor .... dies

Which means that there is someone dies

 

The Condition is:

Actor @4 dies

Which means the @4 actor dies.

 

And then the action is like the mission pass text and the sound.

 

Simple as that

I still don't understand about array 😰 kinda hard to understand tbh

Share this post


Link to post
Share on other sites
electronicsfan

 

hey good work. I wanted to ask how to run a wav file outside and near a vehicle(esp. trains) and change sounds as per the speed... Thanks.

Share this post


Link to post
Share on other sites
ZAZ
On 9/14/2018 at 8:27 AM, electronicsfan said:

 

hey good work. I wanted to ask how to run a wav file outside and near a vehicle(esp. trains) and change sounds as per the speed... Thanks.

 

load wave, link wave to car and play wave

Quote

040D: unload_wav 1
03CF: load_wav  19800 as  1


repeat
wait  0
until 03D0:   wav  1 loaded

0A16: link_wav 1 to_car [email protected]
03D1: play_wav 1

 

Share this post


Link to post
Share on other sites
electronicsfan
16 minutes ago, ZAZ said:

 

load wave, link wave to car and play wave

 

Also anything we can do to change sound as per speed?? Thx

Share this post


Link to post
Share on other sites
ZAZ

get car speed and build condtional checks to give different wav number

 

02E3: 1@ = car 0@ speed

if
    1@ > 20.0
then
    03CF: load_wav  <number> as  1
else
    03CF: load_wav  <number> as  1
end
Edited by ZAZ

Share this post


Link to post
Share on other sites
electronicsfan
23 hours ago, ZAZ said:

get car speed and build condtional checks to give different wav number

 

02E3: 1@ = car 0@ speed

if
    1@ > 20.0
then
    03CF: load_wav  <number> as  1
else
    03CF: load_wav  <number> as  1
end

I came up with this code but it doesn't run... please give suggestion to improve the code.

 

{$CLEO .cs}

[email protected] = Car.Model(#FREIGHT)
02E3: [email protected] = car [email protected] speed
if
   Actor.DrivingVehicleType($PLAYER_ACTOR, #FREIGHT)
   else_jump @WDGSOUND
if 
  [email protected] > 0.0 
else_jump @WDGSOUND_66 
[email protected] = Audiostream.Load("CLEO\HORN\WDM2_POWER_2.WAV")

:WDGSOUND_66
if 
  [email protected] > 20.0 
else_jump @WDGSOUND_120 
[email protected] = Audiostream.Load("CLEO\HORN\WDM2_POWER_3.WAV")

:WDGSOUND_120
if 
  [email protected] > 40.0 
else_jump @WDGSOUND_174 
2[email protected] = Audiostream.Load("CLEO\HORN\WDM2_POWER_4.WAV")

:WDGSOUND_174
if 
  [email protected] > 60.0 
else_jump @WDGSOUND_228 
[email protected] = Audiostream.Load("CLEO\HORN\WDM2_POWER_5.WAV")

:WDGSOUND_228
[email protected] = Audiostream.Length([email protected])
[email protected] *= 1000 
Audiostream.PerformAction([email protected], STOP)
Audiostream.PerformAction([email protected], PLAY)
wait [email protected]
:WDGSOUND 
return

Share this post


Link to post
Share on other sites
Grinch_

@ZAZ

You should reformat all of your codes in previous posts tough.

Share this post


Link to post
Share on other sites
ZAZ
Posted (edited)

i already did that in the past, as old forum changed to previous version

now the newest agian, I'm too lazy for that, always again because the software can't convert the code format? also i don't like the new

go here to read the tut scripts

Edited by ZAZ

Share this post


Link to post
Share on other sites
Grinch_

How to clear the buffer of 00E1?

Edited by Grinch_

Share this post


Link to post
Share on other sites
ZAZ

what buffer?

00E1:   player 0 pressed_key <key press function number>

 

Share this post


Link to post
Share on other sites
Grinch_
5 minutes ago, ZAZ said:

what buffer?

00E1:   player 0 pressed_key <key press function number>

 

forget that.That was stupid.

Edited by Grinch_

Share this post


Link to post
Share on other sites
SMACKED!
On 3/20/2009 at 7:17 PM, ZAZ said:

To let something happen, when a button is selected needs to press another key to confirm the selection and this requires to script a keypress-check

therefor we need the button ID

Old as hell. In case of topic bumping let me know. I didn't get this part, how to make something to happen if I select a choice in the menu?

Share this post


Link to post
Share on other sites
Grinch_

 

@SMACKED!here

Edited by Grinch_

Share this post


Link to post
Share on other sites
ZAZ
18 hours ago, SMACKED! said:

Old as hell. In case of topic bumping let me know. I didn't get this part, how to make something to happen if I select a choice in the menu?

the selected button is given by opcode 08D7

08D7: 2@ = panel 1@ active_row

 [email protected] = panel active_row

 

it doesn't mater if there's a key_press to to confirm

active_row ID will be given when you read it with opcode 08D7

Share this post


Link to post
Share on other sites
SMACKED!
On 11/23/2018 at 10:37 AM, ZAZ said:

the selected button is given by opcode 08D7

08D7: 2@ = panel 1@ active_row

  [email protected] = panel active_row

 

it doesn't mater if there's a key_press to to confirm

active_row ID will be given when you read it with opcode 08D7

the @2 variable is actually the choice/button?

and the [email protected] variable is the panel right?

On 11/23/2018 at 3:06 AM, Grinch_ said:

thanks! i know it all now

Share this post


Link to post
Share on other sites
Davve95

Sorry for bumping this one, but could you fix the links?

Share this post


Link to post
Share on other sites
ZAZ
1 hour ago, Davve95 said:

Sorry for bumping this one, but could you fix the links?

No sorry, the first 9 links are ancors that worked for the old forum software and was linking to positions inside the first post

Link 10 Additional Themes links to 2. post and link 11, 12, 13, 14, 15 are also ancors that worked for the old forum software and was linking to positions inside the 2.post

All others are working

Edited by ZAZ

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

  • 2 Users Currently Viewing
    0 Members, 0 Anonymous, 2 Guests

×

Important Information

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