CLEO Help Cleo Keybinder problem! Please help me!

CLEO related
Status
Not open for further replies.

Radu15

Member
Joined
Mar 20, 2020
Messages
21
Reaction score
0
Location
Romania
Hello ! If I use this code:
{$CLEO .cs}

thread 'TESTCLEO'

:TESTCLEO_01
wait 0
if and
0AB0: key_pressed 34
0AFA: is_samp_structures_available
else_jump @TESTCLEO_01
0AF9: samp say_msg "/stats"
wait 1000
jump @TESTCLEO_01

All is working fine but I want to use multiple keybinds not only one keybind. I tried this:

thread 'TESTCLEO'

:TESTCLEO_01
wait 0
if and
0AB0: key_pressed 34
0AFA: is_samp_structures_available
else_jump @TESTCLEO_01
0AF9: samp say_msg "/lcalls"
wait 1000s

thread 'TESTCLEO1'
:TESTCLEO1_01
wait 0
if and
0AB0: key_pressed 35
0AFA: is_samp_structures_available
else_jump @TESTCLEO1_01
0AF9: samp say_msg "/stats"
wait 1000
jump @TESTCLEO1_01

But the first command is working only 1 time.
Can anyone help me please?
 

Radu15

Member
Joined
Mar 20, 2020
Messages
21
Reaction score
0
Location
Romania
I want for example if I press key 35 to write /stats in chat and if I press key 36 to write /vehicles in chat. And these Keybind to work every time I press these keys.
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Code:
{$CLEO}
{$INCLUDE SF}
0000:
thread "Keybinder"

repeat
wait 0
until SAMP.Available()

WHILE TRUE
WAIT 0

    IF key_down 35
    THEN
        say "/stats"
    END
    
    IF key_down 36
    THEN
        say "/vehicles"
    END
    
END
This should work.
 

Hidend

Expert
Joined
Mar 4, 2013
Messages
656
Reaction score
50
High level is logical, simpler to use and easier with bigger and complex scripts. It also looks more clean.
As a wise man once said
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Yea it is working, but I wonder if you can use the same code I gave you.
Why do you want that structure..? It's useless and the one I gave you it's simpler as Hidend said. Make your life easier. Using jump to other labels it's more complicated and a higher chance of getting something wrong.
 
Status
Not open for further replies.
Top