CLEO Help CLEO sript doesnt deactivate

CLEO related
Status
Not open for further replies.

seks

Member
Joined
Jan 27, 2020
Messages
8
Reaction score
0
Location
saz
Everything works fine but I can't deactivate this script; once I press "X" it keeps looping over and over. I do need it to loop but I also want to be able to stop it whenever I wish, and I need those delays too (2 seconds for the first command and 11 seconds for the second command).

PHP:
{$CLEO .cs}

0000: NOP

WAIT 10000

WHILE TRUE
WAIT 0

IF
0@ == TRUE
THEN
    WAIT 2000
    0C8F: samp process_chat_input "/getmats"
    WAIT 11000
    0C8F: samp process_chat_input "/cps"
END

IF 0AB0:   key_pressed 88 {X}
THEN
    IF
    0@ == FALSE
    THEN
        0@ = TRUE
        0AD1: "ON" 1337
    ELSE
        0@ = FALSE
        0AD1: "OFF" 1337
    END
END
END
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
Using only 0AB0: key_pressed without other checks is not a good way to toggle something as it will spam the shit out of your game.


Here is a good way without spamming it:


Code:
$boolswitch = false {Keep it turned off at first}


while true
    wait 0
    if 0AB0: key_pressed 88
    then
        repeat
        wait 0
        until 8AB0: not_pressed 88
        0B12: $yourvar = $yourvar XOR TRUE {aka 1 -> switches bool depending on current status} 
    end

     if $yourvar == TRUE {when its activated}
     then
                     action
       else {when not activated}
                   action
       end
end
 

seks

Member
Joined
Jan 27, 2020
Messages
8
Reaction score
0
Location
saz
Code:
$boolswitch = false {Keep it turned off at first}

while true
    wait 0
    if 0AB0: key_pressed 88
    then
        repeat
        wait 0
        until 8AB0: not_pressed 88
        0B12: $yourvar = $yourvar XOR TRUE {aka 1 -> switches bool depending on current status}
    end

     if $yourvar == TRUE {when its activated}
     then
                     action
       else {when not activated}
                   action
       end
end
Thank you,
I have tried to implement this but it still doesn't work as intented, Once activated it never stops even if I keep pressing "X" and I feel like its the delays (2s + 11s) are preventing me to do so but at the same time I need these delays...
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
881
Location
Lithuania
PHP:
{$CLEO .cs}

0000: NOP

WAIT 10000

WHILE TRUE
WAIT 0

IF
0@ == TRUE
THEN
    WAIT 2000
    0C8F: samp process_chat_input "/getmats"
    WAIT 11000
    0C8F: samp process_chat_input "/cps"
END

IF 0AB0:   key_pressed 88 {X}
THEN
    IF
    0@ == FALSE
    THEN
        0@ = TRUE
        0AD1: "ON" 1337
    ELSE
        0@ = FALSE
        0AD1: "OFF" 1337
    END
Wait 1000 // anti key spam
END
END
 

seks

Member
Joined
Jan 27, 2020
Messages
8
Reaction score
0
Location
saz
PHP:
{$CLEO .cs}

0000: NOP

WAIT 10000

WHILE TRUE
WAIT 0

IF
0@ == TRUE
THEN
    WAIT 2000
    0C8F: samp process_chat_input "/getmats"
    WAIT 11000
    0C8F: samp process_chat_input "/cps"
END

IF 0AB0:   key_pressed 88 {X}
THEN
    IF
    0@ == FALSE
    THEN
        0@ = TRUE
        0AD1: "ON" 1337
    ELSE
        0@ = FALSE
        0AD1: "OFF" 1337
    END
Wait 1000 // anti key spam
END
END
YES, some progress thank you a lot ! but I need to time my button press right after the execution of :
Code:
 WAIT 11000 0C8F: samp process_chat_input "/cps"
to deactivate the script..Is there any way to improve it?
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
881
Location
Lithuania
I see you making code for getmats, can you make video about what exactly you wanna finally to do , then i can help you finish code.
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
881
Location
Lithuania
A little bit of example
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

32@ = 0 // keep timer active
33@ = 0 // keep timer active

/*
0AB0: 88 {X} // if X key press
8AB0: 88 {X} // if " NOT " X key pressed
at begin 8 means - NOT
*/


WHILE TRUE
WAIT 0

IF 0AB0: 88 {X}
THEN
    repeat // repeat wait until key will be released
    wait 0
    until 8AB0: 88 {X}
    IF
    0@ == FALSE
    THEN
        0@ = TRUE
        0AD1: "ON" 1337
        32@ = 0 // reset timer, make sure it starts count only when you activate it
        33@ = 0 // reset timer, make sure it starts count only when you activate it
    ELSE
        0@ = FALSE
        0AD1: "OFF" 1337
    END
END

IF
0@ == TRUE
THEN
    if
    32@ > 2000
    then
        0C8F: samp process_chat_input "/getmats"
    end
    if
    33@ > 13000
    then
        0C8F: samp process_chat_input "/cps"
    end
    32@ = 0 // reset timer , start count again
    33@ = 0 // reset timer , start count again
    0@ = 0 // turn off code after all
END

END
 
Last edited:
Status
Not open for further replies.
Top