More about if statement and labels

hello, i changed to text since i'm too lazzy to make a video.

let's start << i will explain the first code too so you guys can follow if you didn't understand the video:

so here is our last script:


Code:
{$CLEO}

0000: NOP


// this is comment ...

{this
is
comment 
also
}
:MAIN
wait 0
if and
056D:   actor $PLAYER_ACTOR defined
0AB0: 49 //key 1 pressed?
jf @MAIN
0332: set_actor $PLAYER_ACTOR bleeding 1  
jump @MAIN

explaining the codes:

so now we now that we have to put these two lines before starting codes to avoid crashes:

Code:
{$CLEO}

0000: NOP


and this is how we comment and make notes :
Code:
//this is comment and won't be read by sanny/gta


now to start with the real codes , we have to use labels , and labels is kinda a big function contain many inner functions that will run one by one ,, and labels will be read one by one by sanny/gta  but we can customize the run process too

Code:
:MAIN
//so we started with the label MAIN < we can name labels anything
//now under this we have our codes that will run ,But before we start putting codes we have to add:

wait 0 

// this will avoid crashing
//now after this we start with "if" statement , and if statement is  like (if this/these conditions equaled to true 
//then run the below code ,, if not the jump [member=23507]Label[/member]) , basically 50%  of cleo  is "if" statement , and it is pretty 
//easy but tricky.
//now we add our "if" statment:

if
0AB0: 49 //key 1 pressed? // now this is our conditions if it true it will set actor bleeding to on.
jf @MAIN //if not it will jump @MAIN.as you saw (jf @MAIN) is a shorter statement of (jump_if_false @MAIN)
// now we said @MAIN so the code loop for ever until you pressed 1 , or close the game :)
0332: set_actor $PLAYER_ACTOR bleeding 1  //if the conditions = true , then this code will run and make actor bleeding
jump @MAIN // now we said @MAIN so the code will go back to the start and loop for ever until you pressed 1 , or close the game.

now  if we want to make 2 or more conditions we replace "IF" with "IF AND" like this:

Code:
if and  // with "if and" we have 2 or more conditions and both must equal to true !
056D:   actor $PLAYER_ACTOR defined  //define the actor , if not equal to true the code will be bypass and 
//jump at main again , thanks to jf @MAIN  
0AB0: 49 //key 1 pressed?  // if key pressed 1 the script will run the codes under "jf @main" if not then it will 
//bypass and go back to main
jf @MAIN // so this is a backup plan , if the conditions is false , we won't crash , but we will go up and loop 
//again to check if you pressed 1
0332: set_actor $PLAYER_ACTOR bleeding 1  // set bleeding state on/active
jump @MAIN // after everything finished , this code will let us jump at main (@MAIN) again so we loop 
//forever until you close the game



new stuff:

but now we need more controls , we want to active and deactivate using two different keys. and we can do it with 2 labels easily .

Code:
{$CLEO}

0000: NOP


// this is comment ...


:MAIN  // our first label , this will run first , and active the bleed
wait 0  // avoid crashes and freezing  we have to wait in milliseconds 
if and  // for 2 or more conditions we use "if and"
056D:   actor $PLAYER_ACTOR defined  // our first condition
0AB0: 49 //key 1 pressed?  //our second condition
//there is no problem with sorting the conditions ,, it will run all , so if we put key press first then actor define 
//won't be a problem :)
jf @MAIN // as we said our backup plan XD
0332: set_actor $PLAYER_ACTOR bleeding 1  //active bleeding state , 1 = on
jump @second //now this will change  from main to second so we jump to the next label to check for other 
//codes and conditions , if we make it @MAIN , then label second won't be read since there is no redirect for 
//it in label main

:second // our next label to stop the bleed
wait 0 // avoid crashing and freezing 
if  // for 1 condition 
// no need to define the actor , because from the first step we add the condition for it , and if it is not equal to true it will go to main again until it became true :)
0AB0: 50 //key 2 pressed? // key 2 press = off 
jf @second // so if we pressed another key it will go to second again and it will loop in label second until you 
//press 2 to stop bleeding ,, this can be changed from script to another ,, some people want to jump 
//@MAIN again so they don't stick in @Second label , and run the codes in label main again .
0332: set_actor $PLAYER_ACTOR bleeding 0  //  0 = off , deactivate the bleeding
jump @MAIN // here we make it @MAIN so we loop again from the start after everything finished


but we can make it in another way too:

this is the tricky one , it is easy and very useful and i recommended you understand it:

Code:
:MAIN  // our first label , this will run first , and active the bleed
wait 0  // avoid crashes and freezing  we have to wait in milliseconds 
if and  // for 2 or more conditions we use "if and"
056D:   actor $PLAYER_ACTOR defined  // our first condition
0AB0: 49 //key 1 pressed?  //our second condition
//there is no problem with sorting the conditions ,, it will run all , so if we put key press first then actor define 
//won't be a problem :)


jf @second // now we changed from MAIN to second , this will be like this , (if  actor is defined and key pressed is 1 then run the code below , if the conditions not equal to true then jump at second so we check the codes there) and this will lead to many new changes :P


0332: set_actor $PLAYER_ACTOR bleeding 1  //active bleeding state , 1 = on

jump @MAIN// since we cover label second with "jf" statement above , we have to jump at main  after this , so if the conditions are true the codes will run and then it will jump again @MAIN again to loop forever.

 


:second // our next label to stop the bleed
wait 0 // avoid crashing and freezing 
if and // for 2 or more conditions 

056D:   actor $PLAYER_ACTOR defined   //we need to define the actor , because if the label MAIN failed with defining the actor and jumped to the second label , we need to require GTA to define the actor in label second too , so we don't get crash.

0AB0: 50 //key 2 pressed? // key 2 press = off 

jf @MAIN // so if we pressed another key it will go to MAIN again and loop there until you press one of the 
//keys (1 or 2), (so if we didn't press 1 in the first step it will jump at second and it will check if we pressed 2 
//but if we didn't then it will go to main and check if we pressed 1  again, this will loop forever until you close 
//the game or smash on of the keys heh

0332: set_actor $PLAYER_ACTOR bleeding 0  //  0 = off , deactivate the bleeding
jump @MAIN // here we make it @MAIN so we loop again from the start after everything finished


now you learned much stuff :)
that's all i have for you today , if you have any question , even half a question or stupid  one or if you didn't understand a step , then ask me , i will explain it to you again with slower process :)


i recommended you to read it again after you finished so you understand everything


the full codes without explanations:

the easy one:

Code:
{$CLEO}

0000: NOP


// this is comment ...


:MAIN
wait 0
if and
056D:   actor $PLAYER_ACTOR defined
0AB0: 49 //key 1 pressed?
jf @MAIN
0332: set_actor $PLAYER_ACTOR bleeding 1  
jump @second
 

:second
wait 0
if 
0AB0: 50 //key 2 pressed?
jf @second
0332: set_actor $PLAYER_ACTOR bleeding 0  
jump @MAIN

the tricky one:

Code:
{$CLEO}

0000: NOP


// this is comment ...

:MAIN
wait 0
if and
056D:   actor $PLAYER_ACTOR defined
0AB0: 49 //key 1 pressed?
jf @second
0332: set_actor $PLAYER_ACTOR bleeding 1  
jump @MAIN
 

:second
wait 0
if and
056D:   actor $PLAYER_ACTOR defined
0AB0: 50 //key 2 pressed?
jf @MAIN
0332: set_actor $PLAYER_ACTOR bleeding 0  
jump @MAIN

you can make a single line comment:
Code:
// this is comment
Or a whole part commented:
Code:
{this
is
comment 
also
}
so the comment opener is " { " and the closer is " } "  they both called curly braces





thank you for following my tutorial.


PS: if i wrote something  wrong please comment it , because i made a full tutorial but ugbase required me to login again :( , so i lost the whole thing ....
so i typed it all over again, and i'm too sleepy so maybe i forgot something



edit: this is a link for activation keys >> http://ugbase.eu/tutorials/how-to-change-the-activation-keys-on-a-cleo-script/

in the next tutorial i will explain more about it and how to use different keys in different ways.
 

iLost

Well-known member
Joined
Jun 5, 2014
Messages
216
Reaction score
0
Re: 4)more about if statement and labels-TUT

WoW Nice Black hat! Finally , Someone can Teach Me ON Making Mod ! u are COOL!  :urtheman:

First Coment reply  :forever_hurra:
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: 4)more about if statement and labels-TUT

FransHopper link said:
WoW Nice Black hat! Finally , Someone can Teach Me ON Making Mod ! u are COOL!  :urtheman:

First Coment reply  :forever_hurra:

hahaha thank you xD

i'm really get happy and pushed up and smile when you guys encourage me :)
wish all of you get a good time scripting and keep cleo flag up and high ...
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: 4)more about if statement and labels-TUT

NoJustNo link said:
thx alot , man , but i didn't understand this (in the tricky one):
:MAIN
wait 0
if and
056D:  actor $PLAYER_ACTOR defined
0AB0: 49 //key 1 pressed?
jf @second


Why jf @second? And what is false in here , what can be false so it goes to @second?


Sorry i haven't got internet  , it will jump to second if you didn't pressed 1 or if actor is not define

Actor is always defined but we have to add this to make sure

But in every thing you click this cleo will loop and check if you pressed 1 , but what if you clicked 2 or pressed T to speak ? Well this is the point of jf @second and by jf it will check  in the second label if this key you pressed is equal to the key which is registered in the script to do a specific function.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
Re: 4)more about if statement and labels-TUT

Scripting was like black magic for me until I saw your tutorial, nice and clear explanation, thank you :)
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: 4)more about if statement and labels-TUT

monday link said:
Scripting was like black magic for me until I saw your tutorial, nice and clear explanation, thank you :)

you're welcome :)
thank you for following my tutorials
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
Re: 4)more about if statement and labels-TUT

By the way, why some of Cleo mods are visible to every player around while other mods aren't?
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: 4)more about if statement and labels-TUT

monday link said:
By the way, why some of Cleo mods are visible to every player around while other mods aren't?

if you mean some cleos are openable(decompile-able) and others are not
that's because some people crypt their cleos so others can't steal their codes , some people make it open source so others can check their codes and learn from it :)
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
Re: 4)more about if statement and labels-TUT

Hmm, good to know because i wondered why is it like that but I was asking about different matter to be honest. For example when you enter a server with other people online and you use 2 different cleo mods. One makes your dude bleeding, the other one makes your dude deformed. Other players can see on their screen that your dude is deformed but can't see the bleeding. And here's my question, why some mods are visible to everyone while other's aren't?
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: 4)more about if statement and labels-TUT

monday link said:
Hmm, good to know because i wondered why is it like that but I was asking about different matter to be honest. For example when you enter a server with other people online and you use 2 different cleo mods. One makes your dude bleeding, the other one makes your dude deformed. Other players can see on their screen that your dude is deformed but can't see the bleeding. And here's my question, why some mods are visible to everyone while other's aren't?


ah you mean sync thing


well some script (cheats) only can be seen by you like spawning object or bleeding it is client sided , so others can't see you bleeding but they will see your health decreasing

for some scripts(cheats) it is visible like deforme because your actor is sync with the server so others will see you

another thing come here like burning cars

with cars you can set all cars(get all cars by snippet) on fire and exploding them
but it wont be synced

so you have to teleport into the car and then do something with it and then teleport back from the car (leave the car) in this way the cheats on car will be visible because when you enter the car , it will be client and server sided


visible for you only = not synced
visible for everyone = synced

sync = the data which get read or not ,, so if not synced your data won't be read from the server , but if synced then your data will be read from the server
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
Re: 4)more about if statement and labels-TUT

Oh now I get it, thanks.
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: 4)more about if statement and labels-TUT

~updated , added more about comment functions and explanations
 
Top