CLEO Help CLEO Key Binder - with Loop

CLEO related
Status
Not open for further replies.

Rat

Active member
Joined
Sep 24, 2013
Messages
137
Reaction score
0
Hey y'all.

I'm so new to CLEO scripting and I've been trying to code a key binder but I can't figure out how to make a toggled loop.
Basically what it should do is if I hit Shift+I, it will do:
Code:
0AF9: samp say_msg "/hits"
every 5000ms, and if I hit Shift+I again, it will deactivate the loop.

Code:
:CHECK_HITS
wait 0
if and
0AB0:   key_pressed 16
0AB0:   key_pressed 73
else_jump @CHECK_HITS
0AF9: samp say_msg "/hits"
wait 5000
jump @CHECK_HITS

:yuno:
 

0B36

Expert
Joined
Jan 6, 2014
Messages
1,324
Reaction score
8
[member=6204]esb[/member]

Code:
{$CLEO}

thread "thread"

repeat
wait 0
until SAMP.Available()

0@ = 0 // we define the variable

while true
wait 0
if
    0@ == 1 // check the variable's value
then
    0AF9: samp say_msg "/hits"
    wait 5000
end    
wait 0
if and
        0AB0: 17
        0AB0: 87
then
     if
         0@ == 0 // we check if it's off 
     then
         wait 75
         0@ = 1  // we turn it ON here
     else        
        wait 75  
         0@ = 0  // else, we turn it OFF if's already ON.
     end
end             
end
 

Rat

Active member
Joined
Sep 24, 2013
Messages
137
Reaction score
0
0B36 link said:
[member=6204]esb[/member]

Code:
{$CLEO}

thread "thread"

repeat
wait 0
until SAMP.Available()

0@ = 0 // we define the variable

while true
wait 0
if
    0@ == 1 // check the variable's value
then
    0AF9: samp say_msg "/hits"
    wait 5000
end    
wait 0
if and
        0AB0: 17
        0AB0: 87
then
     if
         0@ == 0 // we check if it's off 
     then
         wait 75
         0@ = 1  // we turn it ON here
     else        
        wait 75  
         0@ = 0  // else, we turn it OFF if's already ON.
     end
end             
end

the toggle is somewhat messed up because once 0@ == 1

Code:
wait 5000

will continuously execute thereby making the deactivation toggle take 5 seconds to hold.
i then have to perfectly time holding the keys, otherwise it will be reactivated.

is there any way i can prevent this?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
226
Location
( ͡° ͜ʖ ͡°)
Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY



WHILE TRUE
    WAIT 0
    IF AND
    0AB0:   key_pressed 16
    0AB0:   key_pressed 73
    THEN
        IF
        0@ == TRUE
        THEN
            0@ = FALSE
            0AF8: samp add_message_to_chat "MOD_DISABLED" color -1
        ELSE
            0@ = TRUE
            0AF8: samp add_message_to_chat "MOD_ENABLED" color -1
        END
        WAIT 350        
    END    
    IF
    0@ == TRUE
    THEN
        IF
        32@ > 5000 // if TIMER_VALUE is bigger than 5 seconds
        THEN
            32@ = 0 // RESET TIMER_VALUE
            0AF9: samp say_msg "/hits"        
        END
    END
END
 

Rat

Active member
Joined
Sep 24, 2013
Messages
137
Reaction score
0
Opcode.eXe link said:
Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY



WHILE TRUE
    WAIT 0
    IF AND
    0AB0:   key_pressed 16
    0AB0:   key_pressed 73
    THEN
        IF
        0@ == TRUE
        THEN
            0@ = FALSE
            0AF8: samp add_message_to_chat "MOD_DISABLED" color -1
        ELSE
            0@ = TRUE
            0AF8: samp add_message_to_chat "MOD_ENABLED" color -1
        END
        WAIT 350        
    END    
    IF
    0@ == TRUE
    THEN
        IF
        32@ > 5000 // if TIMER_VALUE is bigger than 5 seconds
        THEN
            32@ = 0 // RESET TIMER_VALUE
            0AF9: samp say_msg "/hits"        
        END
    END
END

it worked! ha!
thank you!
:eek:h_stop_it_u: :urtheman: :ppffh: :yesyes:
 
Status
Not open for further replies.
Top