Repeat Statement

Hello, Today i will explain the "repeat" statement



now repeat means , loop through things until some point that you defined


this will give you a god mode when you press 1 + 2 and when you press 0 it will stop

this is our code:

Code:
{$CLEO}
                                                                                         
0000: NOP 
0@ = 0 // learn more about this at (http://ugbase.eu/tutorials/)read-commands-and-do-something-about-tut-open-source-codes/)

:GODSTART //our first label with active keys check and conditions
wait 0  
if and
 0256: $PLAYER_ACTOR //is actor defined?   
0AB0: key_pressed 49   //1
0AB0: key_pressed 50 //2
0184:   actor $PLAYER_ACTOR health <> 0 //"<>" means not equal
jf @GODSTART //if any of these conditions is false then jump again until it get all true
0@ = 1 // ENABLE IT      
018C: play_sound 1083 at 0.0 0.0 0.0 // this is enable sound , just for effect 
jump [member=6130]goD[/member] // now jump at the next label
 

:god      // our main script label
wait 0
0ACD: show_text_highpriority "GOD-ON " time 1500 //we put this before repeat so we don't get the massage all the time while we activated the cheat 
repeat  //here is our repeat statement , the explanation is below don't worry
wait 0 //after every repeat we need wait to avoid crashing
actor.SetImmunities($PLAYER_ACTOR, 1 , 1 , 1 ,1 ,1)  // bullet , fire , explosion , car , melee
UNTIL key_down 48 OR Actor.Dead($PLAYER_ACTOR)     // the explanation is below too
0ACD: show_text_highpriority "GOD-OFF" time 1500 
actor.SetImmunities($PLAYER_ACTOR, 0 , 0 , 0 ,0 ,0)  // bullet , fire , explosion , car , melee  
0@ = 0     //disable it   
jump @GODSTART //jump again at the check label of conditions

so now "repeat" means , the code below it will repeat until you press  0 or you die

Code:
REPEAT //this will repeat the code below it 
wait 0 //after every repeat we need wait to avoid crashing
actor.SetImmunities($PLAYER_ACTOR, 1 , 1 , 1 ,1 ,1)  // bullet , fire , explosion , car , melee ( 1 for active , 0 for deactivate)
UNTIL key_down 48 OR Actor.Dead($PLAYER_ACTOR)     //this will end the repeat if you clicked 0 or you died

"until" can hold more than 1  condition not like others saying

this will end the repeat statement that's why we didn't add the "end"

we add "OR"  so we can add more than one conditions , i think we can add "AND" too so it will stop if all the conditions are true.

until key_down 48 OR Actor.Dead($PLAYER_ACTOR)
this will stop if you pressed 0 OR if you died , it will stop the loop if any of these conditions became true


PS: using capital or small letters doesn't effect the code


this is repeat statement , it is not hard xD



you can make "if" and "while" statement into the repeat too


like this:

Code:
{$CLEO}
0000: NOP
31@ = 0 // learn more about this at (http://ugbase.eu/tutorials/)read-commands-and-do-something-about-tut-open-source-codes/)

:START
wait 0
REPEAT
wait 0  
WHILE 044B:   actor $PLAYER_ACTOR on_foot // we can use "WHILE NOT  00DF:  actor $PLAYER_ACTOR driving"  too
wait 0  //we have to add "wait" after while 
0ACD: show_text_highpriority "god-on" time 1500
actor.SetImmunities($PLAYER_ACTOR, 1 , 1 , 1 ,1 ,1)  // bullet , fire , explosion , car , mele // this to make the actor  super (enable the god mode)
end  //you have to end this before "until" , this is "while" closer 
WHILE 00DF:  actor $PLAYER_ACTOR driving // another while
wait 0  //we have to add "wait" after while  
0ACD: show_text_highpriority "god-ONHOLD" time 1500
actor.SetImmunities($PLAYER_ACTOR, 0 , 0 , 0 , 0 , 0)  // bullet , fire , explosion , car , mele // this to make the actor normal again (disable the god mode)
end  //the end of the second while 
UNTIL key_down 48 OR Actor.Dead($PLAYER_ACTOR)       //key 0
0ACD: show_text_highpriority "GOD-OFF" time 1500 //the off massage
actor.SetImmunities($PLAYER_ACTOR, 0 , 0 , 0 , 0 , 0)  // bullet , fire , explosion , car , mele  // this to make the actor normal again (disable the god mode)
31@ = 0            // deactivate it 
jump  @START


see we just made "while" in the "repeat" statement , we can use "if" too.



like this:

Code:
{$CLEO}
0000: NOP
31@ = 0 // learn more about this at (http://ugbase.eu/tutorials/)read-commands-and-do-something-about-tut-open-source-codes/)

:START
wait 0
REPEAT
wait 0  
if
 044B:   actor $PLAYER_ACTOR on_foot 
then
0ACD: show_text_highpriority "god-on" time 1500
actor.SetImmunities($PLAYER_ACTOR, 1 , 1 , 1 ,1 ,1)  // bullet , fire , explosion , car , mele // this to make the actor  super (enable the god mode)
end  //you have to end this before "until" , this is "then" closer 

if 00DF:  actor $PLAYER_ACTOR driving 
then
0ACD: show_text_highpriority "god-ONHOLD" time 1500
actor.SetImmunities($PLAYER_ACTOR, 0 , 0 , 0 , 0 , 0)  // bullet , fire , explosion , car , mele // this to make the actor normal again (disable the god mode)
end  //the end of the second "then"
UNTIL key_down 48 OR Actor.Dead($PLAYER_ACTOR)       //key 0
0ACD: show_text_highpriority "GOD-OFF" time 1500 //the off massage
actor.SetImmunities($PLAYER_ACTOR, 0 , 0 , 0 , 0 , 0)  // bullet , fire , explosion , car , mele  // this to make the actor normal again (disable the god mode)
31@ = 0            // deactivate it 
jump  @START

see we just made "if" in the "repeat" statement.


this will work the same , this is pretty advance scripts , if you stuck at some point , i'm always here to help and explain it to you more, i recommended to read again  so you fully understand it.



thanks for following my tutorials.
if i helped you please hit the thanks button and the little heart(rep.) under my name so you can make me more trusted for users so they can reach me easily.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
158
Re: 10)REPEAT STATEMENT -TUT

Is it going to work if I make repeat within repeat?

Like:

repeat
wait 0
        repeat
        wait 0     
        until
until
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Re: 10)REPEAT STATEMENT -TUT

monday link said:
Is it going to work if I make repeat within repeat?

Like:

repeat
wait 0
        repeat
        wait 0     
        until
until

It will.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
158
Re: 10)REPEAT STATEMENT -TUT

Nice, thanks
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Re: 10)REPEAT STATEMENT -TUT

Code:
{$CLEO .cs}
0000:


WHILE TRUE
    WAIT 0
    REPEAT
        WAIT 0
    UNTIL 0AB0: 2 OR 0AB0: 1
END

Decompiled:

Code:
{$CLEO .cs}
0000: NOP 

:Noname_2
wait 0 

:Noname_6
wait 0 
key_down 2 
else_jump @Noname_6 
jump @Noname_2

That means: YOU CAN ONLY USE ONE CONDITION FOR UNTIL
 
Top