CLEO Help [Req]Explain Please.

CLEO related
Status
Not open for further replies.

NoJustNo

Active member
Joined
Jul 26, 2014
Messages
178
Reaction score
0
I Want someone to explain Me Those Commands : While , Then.
What Is The Usage And When To Use ... and Why Would They Be Necessary ?
Thx In Advance.
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
WHILE is used for LOOPS. THEN is used for conditions.

Press F12 (HELP) on sanny builder > Expand Coding > Select "CONDITIONS" to see what "THEN" does and select "LOOPS" to see what "WHILE" does.
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1
It's like speaking common English.

WHILE
me fartin
IF
neger  in da box
THEN
fart
use lighter
ELSE
get neger in da box
REPEAT UNTIL
neger ded
END
 

NoJustNo

Active member
Joined
Jul 26, 2014
Messages
178
Reaction score
0
Mr.Ze link said:
It's like speaking common English.

WHILE
me fartin
IF
neger  in da box
THEN
fart
use lighter
ELSE
get neger in da box
REPEAT UNTIL
neger ded
END

I like how u explain it xD
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
while 0AB0: key_pressed XX //condition
    // do stuff
    0209: 0@ = random_int_in_ranges 0 10
    0AD1: "%d" 100 0@
end

Basically if condition is true do stuff in a loop.
 

NoJustNo

Active member
Joined
Jul 26, 2014
Messages
178
Reaction score
0
springfield link said:
while 0AB0: key_pressed XX //condition
    // do stuff
    0209: 0@ = random_int_in_ranges 0 10
    0AD1: "%d" 100 0@
end

Basically if condition is true do stuff in a loop.

And how to stop the loops?
and if possible please explain: 0AD1: "%d" 100 0@
this : %d and the numbers after it , i really cant get what it does
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
NoJustNo link said:
[quote author=springfield link=topic=9032.msg52572#msg52572 date=1407259064]
while 0AB0: key_pressed XX //condition
    // do stuff
    0209: 0@ = random_int_in_ranges 0 10
    0AD1: "%d" 100 0@
end

Basically if condition is true do stuff in a loop.

And how to stop the loops?
and if possible please explain: 0AD1: "%d" 100 0@
this : %d and the numbers after it , i really cant get what it does
[/quote]
If u use "end" it'll turn off automatically until u press the activation key or something again.


% - Params
100 - Time
0@ - handle
As u can see 0209 , It's randomly choose a number from 0 - 10
And then it's being Displayed in 0AD1 also use as printf ( just like print "aa" )  it's print a format text.
Code:
%d - Numbers
%s - Letters
For example:
Code:
0B2B: samp 1@ = get_player_id_by_actor_handle $PLAYER_ACTOR
0B36: samp 2@ = get_player_nickname 1@
printf "~R~Hello, %s , Your ID is: %d" 1000 2@


Result: Hello, NoJustNo , Your ID is: 69
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1
As I explained, and as Srpgfld did; WHILE usually indicates that there will be a loop. To stop a WHILE function, usually we put UNTIL. And when there is a loop, at the beginning of the loop we usually put conditions; such as IF NOT Player.Dead - the script will loop as long as the player is alive. And then you can deactivate the loop by putting condition duch as IF 0@ == 1 - so loop will happen as long as the command is active, when you type the command again it will go 0@ == 0 - the condition above is not fulfilled so loop want happen until you retype the command (0@ == 1 again) - and you can combine it with other conditions such as Player.Dead:
IF AND
0@ == 1
NOT Player.Dead($PLAYER_ACTOR)
THEN
bla bla
REPEAT

  OR

IF
0@ == 1
THEN
        IF
      NOT Player.Dead($PLAYER_ACTOR)
      THEN
      bla blsabka
      END
REPEAT

I'm writing this on my phone and haven't scripted in a month really; if there are any errors, PLEASE, Springfield, Opcode, TH3RM4L - correct me.

Enjoy scripting, lad!
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,493
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
Code:
While true
    wait 0
end
-> this is important to avoid crashing... its the main loop of the script, you write your code after 'wait 0'


WHILE LOOP:

Code:
WHILE TRUE
WAIT 0
    while 0118:   actor $PLAYER_ACTOR dead
        wait 0
        0AD1: show_formatted_text_highpriority "I'M DEAD!" time 10
    end
END

-> while the player is dead it will say "IM DEAD", so its looping between while and end.

REPEAT LOOP

Code:
WHILE TRUE
WAIT 0
    repeat
        wait 0
        0AD1: show_formatted_text_highpriority "I'M NOT DEAD YET!" time 10
    until 0118:   actor $PLAYER_ACTOR dead
END

-> it will loop the code between 'repeat' and 'until' soo. in this case it will show "I'M NOT DEAD YET!" until the player dies

FOR LOOP


Code:
WHILE TRUE
WAIT 0
    FOR 0@ = 0 TO 10
        0AD1: show_formatted_text_highpriority "Already Repeated: %d times!" time 1000 0@
    END
END

-> in that example the code between 'FOR' and 'END' will repeat 10 times. Also 0@ will be the counter that shows how many times it already looped.
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1
Also, this is a wrong section you posted in, should be CLEO - Help as this is help request, not a tutorial.
moderators dont do their job K
 
Status
Not open for further replies.
Top