Jump to content

Gta Cleo Script Multitasks


Zintro

Recommended Posts

Hi, if i wanna make a cleo script and this one needs something like a small function that runs all the time (as loop) like when you write a custom mission and it can be canceled at any moment by keypress or when you alwaye need to check if the player in car or not to hide marker above car this must be created by a loop right ? but i don't want the game to stay stuck in it but run it in the same time while the mission is performed, i was thinking of creating two scripts run at the same time to solve it but i really don't know if it works, i'll appreciate any help . (Sorry for bad language :) )

Edited by Zintro
Link to comment
Share on other sites

14 hours ago, Zintro said:

i was thinking of creating two scripts run at the same time to solve it but i really don't know if it works

yes, it's possible with opcode 004F, 0913 and 0A92

there can be attached up to 30 additional parameter
 

004F: create_thread @AUDIOL 1@ 1 1 2 0

0913: run_external_script 1 (PARACHUTE) -1 -10.0 10.0 -5.0 -2.0 10.0 12.0 1 70@

0A92: create_custom_thread "SMGshootRockets.CS" 1

 

let's focus to 0A92: create_custom_thread "MultiThread_var.cs" 1 2 3 4

 

So you can assigne information to the script start command

And you can put more scripts inside same cleo script file

 

It needs a check for the information at script beginn

Example:

Spoiler

 

the SMGshootRockets script creates a own thread for each rocket

so it can be checked if each rocket collides, while new rockets can be shot

 

 

 

 

more examples

 

in high level

{$CLEO .s}
:MultiThread
if
0@ == 0
else_jump @MultiThread_20

thread 'MULTHRD'
0A92: create_custom_thread "MultiThread.cs" 1 2 3 4 

    while true
    wait 0
    03F0: enable_text_draw 1  
    045A: draw_text_1number 100.0 100.0 GXT 'NUMBER' number 0@ 
    end 


:MultiThread_20// second thread
if
0@ == 1
then
    03A4: name_thread 'SECONDT'

    while true
        wait 0
        03F0: enable_text_draw 1  
        045A: draw_text_1number 150.0 120.0 GXT 'NUMBER' number 0@
        045A: draw_text_1number 160.0 120.0 GXT 'NUMBER' number 1@ 
        045A: draw_text_1number 170.0 120.0 GXT 'NUMBER' number 2@
        045A: draw_text_1number 180.0 120.0 GXT 'NUMBER' number 3@ 
    end
end
0A93: end_custom_thread

 

 

classic syntax


{$CLEO .cs}
:MultiThread//-- 0@ = 0 by default
if
0@ == 0
jf @MultiThread_20

03A4: name_thread 'MULTHRD'  

:MultiThread_10
wait 0
03F0: enable_text_draw 1  
045A: draw_text_1number 200.0 40.0 GXT 'NUMBER' number 0@  // ~1~  
if 
0AB0:   key_pressed 8//---------------------- Backspace 
004D: jump_if_false @MultiThread_10 
0A92: create_custom_thread "MultiThread_end.cs" 1 2 3 4 

//The started(second)thread assignes now the first param of 0A92: to 0@, the second param to 1@ and so on
// the second thread beginns also with
//:MultiThread//-- but 0@ = 1 because of the  first param of 0A92:
//if
//0@ == 0
//jf @MultiThread_20


:MultiThread_11
wait 0
03F0: enable_text_draw 1  
045A: draw_text_1number 200.0 40.0 GXT 'NUMBER' number 0@  // ~1~  
jump @MultiThread_11 

/////////////////////////////////////////////////////////
////// second thread


:MultiThread_20
if
0@ == 1
jf @MultiThread_50
03A4: name_thread 'SECONDT'
wait 1000

:MultiThread_21
wait 0
03F0: enable_text_draw 1  
045A: draw_text_1number 200.0 60.0 GXT 'NUMBER' number 0@  // ~1~ 
045A: draw_text_1number 240.0 60.0 GXT 'NUMBER' number 1@  // ~1~ 
045A: draw_text_1number 260.0 60.0 GXT 'NUMBER' number 2@  // ~1~ 
045A: draw_text_1number 280.0 60.0 GXT 'NUMBER' number 3@  // ~1~ 
if 
0AB0:   key_pressed 8//---------------------- Backspace 
004D: jump_if_false @MultiThread_21
0459: end_thread_named 'SECONDT' 
wait 1000
jump @MultiThread_21

:MultiThread_50
0A93: end_custom_thread

 

 

 

 

 

//////////////////////////////////////////////////////////////////////////

 

 

Another method:

Make separated script and use Opcode 0AB3: and 0AB4: to communicate

 

 

 

 

 

 

 

 

 

 

 

Link to comment
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
  • 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.