CLEO Help *SIGH* How can I make my keybind script shorter?

CLEO related
Status
Not open for further replies.

Supermacy31

Active member
Joined
Mar 13, 2013
Messages
173
Reaction score
0
It seriously seems like my keybind script is long.

I want it to be shorter. The problem is, I don't know how to make it shorter. Like seriously. Can somebody help me? Guide me in the right direction? I've been at this for like 1-2 days now and every time that I try to make it shorter, it either breaks the script or it makes the script do weird ass things. Help!!!

Code:
{$CLEO .cs}
0000:
repeat
wait 40
until 0AFA: is_samp_structures_available

:Listener
wait 0 

//The hotkeys:
if and 
0AB0: key_pressed 111 //Key starts from NumpadDiv
8B21: not samp is_chat_opened 
then
0AF1: write_int 111 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 103
8B21: not samp is_chat_opened 
then
0AF1: write_int 103 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 104 
8B21: not samp is_chat_opened 
then
0AF1: write_int 104 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 105 
8B21: not samp is_chat_opened 
then
0AF1: write_int 105 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 100 
8B21: not samp is_chat_opened 
then
0AF1: write_int 100 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 101 
8B21: not samp is_chat_opened 
then
0AF1: write_int 101 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 102 
8B21: not samp is_chat_opened 
then
0AF1: write_int 102 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 97 
8B21: not samp is_chat_opened 
then
0AF1: write_int 97 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 98 
8B21: not samp is_chat_opened 
then
0AF1: write_int 98 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 99
8B21: not samp is_chat_opened 
then
0AF1: write_int 99 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

if and 
0AB0: key_pressed 96 
8B21: not samp is_chat_opened 
then
0AF1: write_int 96 to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
jump @KBind
end

//

jump @Listener

:KBind
wait 0

//What did you last pressed, good sir?
0AF0: 0@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"

if 
0@ == 111 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 103 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m1"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 104 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m2"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 105 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m3"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 100 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m4"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 101 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m5"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 102 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m6"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 97 
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m7"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 98
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m8"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 99
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m9"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

if 
0@ == 96
then
0AC8: 1@ = allocate_memory_size 260
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m10"
0AF9: samp say_msg 1@
0AC9: free_allocated_memory 1@ //Free!
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
end

jump @Listener

This works by the way, just don't know how to make it shorter.


*SIGH*
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Code:
{$CLEO .cs}
0000:
repeat
wait 40
until 0AFA: is_samp_structures_available

0AC8: 1@ = allocate_memory_size 260
0AF0: 31@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"

:Listener
wait 0 

if 0B21: samp is_chat_opened
then
jump @Listener
end  

//The hotkeys:
if 0AB0: key_pressed 111 //Key starts from NumpadDiv
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
30@ = true
end

if 0AB0: key_pressed 103 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m1"
30@ = true
end

if 0AB0: key_pressed 104  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m2"
30@ = true
end

if 0AB0: key_pressed 105 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m3"
30@ = true
end

if 0AB0: key_pressed 100  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m4"
30@ = true
end

if 0AB0: key_pressed 101  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m5"
30@ = true
end

if 0AB0: key_pressed 102  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m6"
30@ = true
end

if 0AB0: key_pressed 97 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m7"
30@ = true
end

if 0AB0: key_pressed 98 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m8"
30@ = true
end

if 0AB0: key_pressed 99
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m9"
30@ = true
end

if 0AB0: key_pressed 96 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m10"
30@ = true
end

if 30@ == true //if one of the binds was activated and read from the ini file
then
30@ = false
0AF9: samp say_msg 1@
0AD3: 1@ = format ""//idk if it's neccessary but it could prevent the previous longer string interfering with the new shorter one
wait 31@   
end

jump @Listener
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
Idk what your code does, but you could replace those lengthy checks with a 'for'.

[shcode=cpp]
if 8B21: not samp is_chat_opened
then
   for 0@ = 90 to 111
       if 0ab0: 0@
       then  0AF1: write_int 0@ to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
       end
   end
end
[/shcode]
 

Supermacy31

Active member
Joined
Mar 13, 2013
Messages
173
Reaction score
0
monday said:
Code:
{$CLEO .cs}
0000:
repeat
wait 40
until 0AFA: is_samp_structures_available

0AC8: 1@ = allocate_memory_size 260
0AF0: 31@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"

:Listener
wait 0 

if 0B21: samp is_chat_opened
then
jump @Listener
end  

//The hotkeys:
if 0AB0: key_pressed 111 //Key starts from NumpadDiv
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
30@ = true
end

if 0AB0: key_pressed 103 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m1"
30@ = true
end

if 0AB0: key_pressed 104  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m2"
30@ = true
end

if 0AB0: key_pressed 105 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m3"
30@ = true
end

if 0AB0: key_pressed 100  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m4"
30@ = true
end

if 0AB0: key_pressed 101  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m5"
30@ = true
end

if 0AB0: key_pressed 102  
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m6"
30@ = true
end

if 0AB0: key_pressed 97 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m7"
30@ = true
end

if 0AB0: key_pressed 98 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m8"
30@ = true
end

if 0AB0: key_pressed 99
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m9"
30@ = true
end

if 0AB0: key_pressed 96 
then
0AF4: 1@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m10"
30@ = true
end

if 30@ == true //if one of the binds was activated and read from the ini file
then
30@ = false
0AF9: samp say_msg 1@
0AD3: 1@ = format ""//idk if it's neccessary but it could prevent the previous longer string interfering with the new shorter one
wait 31@   
end

jump @Listener
I tested it. Thanks a lot. I really appreciate it.

May use in the future or may use as a reference in the future.


springfield said:
Idk what your code does, but you could replace those lengthy checks with a 'for'.

[shcode=cpp]
if 8B21: not samp is_chat_opened
then
   for 0@ = 90 to 111
       if 0ab0: 0@
       then  0AF1: write_int 0@ to_ini_file "cleo\kbult.ini" section "kb" key "lastpressed"
       end
   end
end
[/shcode]
Thanks a lot. May consider for loops in the future but they are a bit 'eeky in CLEO.
 
Status
Not open for further replies.
Top