Jump to content

how a thread is activated?


Recommended Posts

All the codes I used had a different structure of this one, and it was like this:

 

-Event: What happens to activate the followed actions (Ex: Player enters a sphere).

-Condition: there is no need to explain..

-Action: What happens..

 

Like this one:

 

:Models_Loaded01if0248: not model #GREENWOO availableelse_jump @Creating_Army01wait 0 msjump @Models_Loaded01

 

The event would be when the model #GREENWOO is available, i have no problem with this.

 

The problem is that in many threads there is no event (for my understanding), like in this one:

 

:Load_Models010247: load_model #GREENWOO038B: load_requested_models 

 

The thing I dont understand is when the thread starts to work.. The game starts and just this happens? or i must put in some other thread "jump @Load_Models01" or something like that?

 

 

 

 

 

Link to comment
https://gtaforums.com/topic/463666-how-a-thread-is-activated/
Share on other sites

Ok I will read it..

 

I have another questions u.u

 

1) Im trying to make the threads with "events" (its easier for me confused.gif .. im used to it), like this:

 

{$CLEO}:Init_War01   $modelsused_war01 = 0   $modelsloaded_war01 = 0   $modelsloading_war01 = 0   $inwar01 = 0   02A7: $sphere_war01 = create_icon_marker_and_sphere 6 at 2518.5596 -1692.0238 18.052end_thread:EnterSphere_War01   if and       $onmission == 0        00FF: actor $PLAYER_ACTOR sphere $sphere_war01 in_sphere 2518.5596 -1692.0238 18.052 radius 15.0 15.0 15.0 on_foot   then       $inwar01 = 1   else       wait 0 ms       jump @EnterSphere_War01   endend_thread:LoadModels_War01   wait 0 ms   until $inwar01 == 1   0247: load_model #GREENWOO   038B: load_requested_models   $modelsloading_war01 = 1end_thread :ModelsLoaded_War01   wait 0 ms   until $modelsloading_war01 == 1   if and       0248: not model #GREENWOO available   then       wait 0 ms       jump @ModelsLoaded_War01   else       $modelsloaded_war01 = 1       $modelsloading_war01 = 0   endend_thread :CreatingArmy_War01   wait 0 ms   until $modelsloaded_war01 == 1   $greenwood = car.Create(#GREENWOO, 2498.4966, -1651.4208, 13.515)   car.Angle($greenwood) = 177.0116   $modelsused_war01 = 1   $modelsloaded_war01 = 0end_thread :ClearModels_War01   wait 0 ms   until $modelsused_war01 == 1   0249: release_model #GREENWOO   $modelsused_war01 = 0 end_thread

 

 

Is this right?? confused.gif

 

2) I have an error when I whant to compile it.. it appears this error:

user posted image

The problem is in this line: until $inwar01 == 1

 

I dont understand which is the problem.. its an integer variable, i dont find any error sad.gif

 

Thanks for your help smile.gif

Link to comment
https://gtaforums.com/topic/463666-how-a-thread-is-activated/#findComment-1060215720
Share on other sites

 

Never use custom global variables in your CLEO-scripts ($car, $foo, $blahblah, etc), or your script will work incorrectly. You may use only a few global variables

 

 

Use the opcode 0A93, if you need to stop a CLEO-thread.

 

Not end_thread

 

2. You cannot use until alone until goes with repeat

 

Syntax

 

 

repeat[code]until [condition] 

 

 

repeat   wait 0until 0@ == 0xFF 

 

 

Why do you want end_thread

Edited by BnB
Link to comment
https://gtaforums.com/topic/463666-how-a-thread-is-activated/#findComment-1060215736
Share on other sites

 

I dont need to use end_thread? i thought it was neccesary always i finish a thread ...

 

thank you bennington ^^

no, we normaly let the code jump back to the beginning

 

we are writing Loops

 

a loop must beginn with a wait, mostly wait 0 ms

 

 

:Aktwait 0jump @Akt

 

example:

 

{$CLEO .cs}:Akt03A4: name_thread 'AKT':Akt_010001: wait 0 msif0256: player $PLAYER_CHAR defined004D: jump_if_false @Akt_01if0AB0:   key_pressed 8//-----------------key = Backspace004D: jump_if_false @Akt_0108B2: toggle_thermal_vision 10001: wait 3000 ms08B2: toggle_thermal_vision 00002: jump @Akt_01//--------Normal jump instruction to 1.LoopAdress

 

 

 

to create stuff, like actor, car, object etc.. needs to define a variable to declare the instance of an item

 

and your script should have a cleanup part to terminate the created instances

 

like the car in script below

 

{$CLEO .cs}:akt03A4: name_thread 'AKT':akt01//----------------------------1.Loop Adress0001: wait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @akt01if00DF:   actor $PLAYER_ACTOR driving004D: jump_if_false @akt0103C0: 1@ = actor $PLAYER_ACTOR car0229: set_car 1@ color_to 17 002AC: set_car 1@ immunities BP 1 FP 1 EP 1 CP 1 MP 1053F: set_car 1@ tires_vulnerability 0:akt03//----------------------------2.Loop Adress0001: wait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @akt03if80DF:   not actor $PLAYER_ACTOR driving004D: jump_if_false @akt0301C3: remove_references_to_car 1@0002: jump @akt01//--------Normal jump instruction to 1.LoopAdress

 

 

 

 

 

 

 

 

 

 

 

Link to comment
https://gtaforums.com/topic/463666-how-a-thread-is-activated/#findComment-1060216934
Share on other sites

 

I dont need to use end_thread? i thought it was neccesary always i finish a thread ...

 

thank you bennington ^^

Actually it had a bit of irony...

At least your choosing right topic titles tounge2.gif

OK, enough of that.

Edited by Bennington
Link to comment
https://gtaforums.com/topic/463666-how-a-thread-is-activated/#findComment-1060217165
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
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

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