CLEO Help Can make a function to press the spacebar for 0.3 seconds when typing "/space" chat?

CLEO related

tested05

Active member
Joined
Jan 21, 2017
Messages
70
Reaction score
2
Can make a function to press the spacebar for 0.3 seconds when typing "/space" chat?
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
PHP:
{$CLEO .cs}
{$USE bitwise}
0000:

WHILE TRUE
WAIT 0

IF AND
0AB0: key_pressed 18 // KEY_ALT
0AB0: key_pressed 53 // KEY_X
THEN
    0B12: 30@ = 30@ XOR 1        
    IF 0039:   30@ == 1
    THEN 0AD1: show_formatted_text_highpriority "ON" time 1337
    ELSE 0AD1: show_formatted_text_highpriority "OFF" time 137
    END
    WAIT 137
END

IF 30@ == 1
THEN
    IF 0256:   player $PLAYER_CHAR defined
    THEN
        0AB1: @ForcePressGameKeyOffset 1 _KeyOffset 32 // Sprint
        WAIT 2000
    END
END

END
0A93: terminate_this_custom_script

:ForcePressGameKeyOffset
// 0AB1: @ForcePressGameKeyOffset 1 _KeyOffset 0@
0@ += 0xB734D0 // High Priority Controls
0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
0AB2: ret 0
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
PHP:
{$CLEO .cs}
{$USE bitwise}
0000:

WHILE TRUE
WAIT 0

IF AND
0AB0: key_pressed 18 // KEY_ALT
0AB0: key_pressed 53 // KEY_X
THEN
    0B12: 30@ = 30@ XOR 1        
    IF 0039:   30@ == 1
    THEN 0AD1: show_formatted_text_highpriority "ON" time 1337
    ELSE 0AD1: show_formatted_text_highpriority "OFF" time 137
    END
    WAIT 137
END

IF 30@ == 1
THEN
    IF 0256:   player $PLAYER_CHAR defined
    THEN
        0AB1: @get_samp_version_id 0 _returned: ID 0@ 
        0AC8: 1@ = allocate_memory_size 260
        0AD3: 1@ = format "/space"
        0AB1: @SEND_CMD 2 SampVersionID 0@ Text 1@
        WAIT 300
    END
END

END
0A93: terminate_this_custom_script

:get_samp_version_id
// 0AB1: @get_samp_version_id 0 _returned: ID 0@  
30@ = 0
IF 0AA2: 31@ = "samp.dll" // IF and SET
THEN
    31@ += 0x128
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
    IF 29@ == 0x5542F47A
    THEN // 0.3.7 R1
        30@ = 1
    END
    
    IF 29@ == 0x59C30C94
    THEN // 0.3.7 R2
        30@ = 2
    END
    
    IF 29@ == 0x5A6A3130
    THEN // 0.3.DL
        30@ = 3
    END
    
    31@ -= 8 // reading samp.dll + 0x120
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
    
    IF 29@ == 0x5C0B4243
    THEN // 0.3.7 R3 
        30@ = 4
    END  
    
    IF 29@ == 0x5DD606CD
    THEN // 0.3.7 R4
        30@ = 5
    END
    
    IF 29@ == 0x6094ACAB
    THEN // 0.3.7 R4 - v2
        30@ = 6
    END 
END
0AB2: ret 1 30@

:SEND_CMD
{
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "/cmds"
    0AB1: @SEND_CMD 2 SampVersionID 0@ Text 1@
}
IF 0AA2: 2@ = "samp.dll"
THEN
    IF NOT 0@ < 0
    THEN
        IF 0@ == 1 // 0.3.7 R1
        THEN     
            0A8E: 3@ = 2@ + 0x65C60
            0AA5: call 3@ num_param 1 pop 0 1@
        END
        
        IF 0@ == 2 // 0.3.7 R2
        THEN     
            0A8E: 3@ = 2@ + 0x65D30
            0AA5: call 3@ num_param 1 pop 0 1@
        END
   
        IF 0@ == 3 // 0.3.DL
        THEN     
            0A8E: 3@ = 2@ + 0x69340
            0AA5: call 3@ num_param 1 pop 0 1@
        END
   
        IF 0@ == 4 // 0.3.7 R3
        THEN      
            0A8E: 3@ = 2@ + 0x69190
            0AA5: call 3@ num_param 1 pop 0 1@
        END
   
        IF 0@ == 5 // 0.3.7 R4
        THEN     
            0A8E: 3@ = 2@ + 0x698C0
            0AA5: call 3@ num_param 1 pop 0 1@
        END
        
        IF 0@ == 6 // 0.3.7 R4 - v2
        THEN     
            0A8E: 3@ = 2@ + 0x69900
            0AA5: call 3@ num_param 1 pop 0 1@
        END        
    END
END
0AB2: 0
 

tested05

Active member
Joined
Jan 21, 2017
Messages
70
Reaction score
2
PHP:
{$CLEO .cs}
{$USE bitwise}
0000:

WHILE TRUE
WAIT 0

IF AND
0AB0: key_pressed 18 // KEY_ALT
0AB0: key_pressed 53 // KEY_X
THEN
    0B12: 30@ = 30@ XOR 1       
    IF 0039:   30@ == 1
    THEN 0AD1: show_formatted_text_highpriority "ON" time 1337
    ELSE 0AD1: show_formatted_text_highpriority "OFF" time 137
    END
    WAIT 137
END

IF 30@ == 1
THEN
    IF 0256:   player $PLAYER_CHAR defined
    THEN
        0AB1: @get_samp_version_id 0 _returned: ID 0@
        0AC8: 1@ = allocate_memory_size 260
        0AD3: 1@ = format "/space"
        0AB1: @SEND_CMD 2 SampVersionID 0@ Text 1@
        WAIT 300
    END
END

END
0A93: terminate_this_custom_script

:get_samp_version_id
// 0AB1: @get_samp_version_id 0 _returned: ID 0@ 
30@ = 0
IF 0AA2: 31@ = "samp.dll" // IF and SET
THEN
    31@ += 0x128
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
    IF 29@ == 0x5542F47A
    THEN // 0.3.7 R1
        30@ = 1
    END
   
    IF 29@ == 0x59C30C94
    THEN // 0.3.7 R2
        30@ = 2
    END
   
    IF 29@ == 0x5A6A3130
    THEN // 0.3.DL
        30@ = 3
    END
   
    31@ -= 8 // reading samp.dll + 0x120
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
   
    IF 29@ == 0x5C0B4243
    THEN // 0.3.7 R3
        30@ = 4
    END 
   
    IF 29@ == 0x5DD606CD
    THEN // 0.3.7 R4
        30@ = 5
    END
   
    IF 29@ == 0x6094ACAB
    THEN // 0.3.7 R4 - v2
        30@ = 6
    END
END
0AB2: ret 1 30@

:SEND_CMD
{
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "/cmds"
    0AB1: @SEND_CMD 2 SampVersionID 0@ Text 1@
}
IF 0AA2: 2@ = "samp.dll"
THEN
    IF NOT 0@ < 0
    THEN
        IF 0@ == 1 // 0.3.7 R1
        THEN    
            0A8E: 3@ = 2@ + 0x65C60
            0AA5: call 3@ num_param 1 pop 0 1@
        END
       
        IF 0@ == 2 // 0.3.7 R2
        THEN    
            0A8E: 3@ = 2@ + 0x65D30
            0AA5: call 3@ num_param 1 pop 0 1@
        END
  
        IF 0@ == 3 // 0.3.DL
        THEN    
            0A8E: 3@ = 2@ + 0x69340
            0AA5: call 3@ num_param 1 pop 0 1@
        END
  
        IF 0@ == 4 // 0.3.7 R3
        THEN     
            0A8E: 3@ = 2@ + 0x69190
            0AA5: call 3@ num_param 1 pop 0 1@
        END
  
        IF 0@ == 5 // 0.3.7 R4
        THEN    
            0A8E: 3@ = 2@ + 0x698C0
            0AA5: call 3@ num_param 1 pop 0 1@
        END
       
        IF 0@ == 6 // 0.3.7 R4 - v2
        THEN    
            0A8E: 3@ = 2@ + 0x69900
            0AA5: call 3@ num_param 1 pop 0 1@
        END       
    END
END
0AB2: 0
Thanks for your reply. I'm trying to use it in 0.3dl. code above is compiled in sannybuilder, but the code below is "Label "get_samp_version_id" not found." Compilation is not possible because an error is output.
 

tested05

Active member
Joined
Jan 21, 2017
Messages
70
Reaction score
2
Thanks for your reply. I'm trying to use it in 0.3dl. code above is compiled in sannybuilder, but the code below is "Label "get_samp_version_id" not found." Compilation is not possible because an error is output.
PHP:
{$CLEO .cs}
{$USE bitwise}
0000:

WHILE TRUE
WAIT 0

IF AND
0AB0: key_pressed 18 // KEY_ALT
0AB0: key_pressed 53 // KEY_X
THEN
    0B12: 30@ = 30@ XOR 1       
    IF 0039:   30@ == 1
    THEN 0AD1: show_formatted_text_highpriority "ON" time 1337
    ELSE 0AD1: show_formatted_text_highpriority "OFF" time 137
    END
    WAIT 137
END

IF 30@ == 1
THEN
    IF 0256:   player $PLAYER_CHAR defined
    THEN
        0AB1: @get_samp_version_id 0 _returned: ID 0@
        0AC8: 1@ = allocate_memory_size 260
        0AD3: 1@ = format "/space"
        0AB1: @SEND_CMD 2 SampVersionID 0@ Text 1@
        WAIT 300
    END
END

END
0A93: terminate_this_custom_script

:get_samp_version_id
// 0AB1: @get_samp_version_id 0 _returned: ID 0@ 
30@ = 0
IF 0AA2: 31@ = "samp.dll" // IF and SET
THEN
    31@ += 0x128
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
    IF 29@ == 0x5542F47A
    THEN // 0.3.7 R1
        30@ = 1
    END
   
    IF 29@ == 0x59C30C94
    THEN // 0.3.7 R2
        30@ = 2
    END
   
    IF 29@ == 0x5A6A3130
    THEN // 0.3.DL
        30@ = 3
    END
   
    31@ -= 8 // reading samp.dll + 0x120
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
   
    IF 29@ == 0x5C0B4243
    THEN // 0.3.7 R3
        30@ = 4
    END 
   
    IF 29@ == 0x5DD606CD
    THEN // 0.3.7 R4
        30@ = 5
    END
   
    IF 29@ == 0x6094ACAB
    THEN // 0.3.7 R4 - v2
        30@ = 6
    END
END
0AB2: ret 1 30@

:SEND_CMD
{
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "/cmds"
    0AB1: @SEND_CMD 2 SampVersionID 0@ Text 1@
}
IF 0AA2: 2@ = "samp.dll"
THEN
    IF NOT 0@ < 0
    THEN
        IF 0@ == 1 // 0.3.7 R1
        THEN    
            0A8E: 3@ = 2@ + 0x65C60
            0AA5: call 3@ num_param 1 pop 0 1@
        END
       
        IF 0@ == 2 // 0.3.7 R2
        THEN    
            0A8E: 3@ = 2@ + 0x65D30
            0AA5: call 3@ num_param 1 pop 0 1@
        END
  
        IF 0@ == 3 // 0.3.DL
        THEN    
            0A8E: 3@ = 2@ + 0x69340
            0AA5: call 3@ num_param 1 pop 0 1@
        END
  
        IF 0@ == 4 // 0.3.7 R3
        THEN     
            0A8E: 3@ = 2@ + 0x69190
            0AA5: call 3@ num_param 1 pop 0 1@
        END
  
        IF 0@ == 5 // 0.3.7 R4
        THEN    
            0A8E: 3@ = 2@ + 0x698C0
            0AA5: call 3@ num_param 1 pop 0 1@
        END
       
        IF 0@ == 6 // 0.3.7 R4 - v2
        THEN    
            0A8E: 3@ = 2@ + 0x69900
            0AA5: call 3@ num_param 1 pop 0 1@
        END       
    END
END
0AB2: 0
When I tried again, it compiles normally. But it doesn't seem to be working. Perhaps you wrote it so that the on/off text is output when the alt+x key is pressed. But no text is output. It probably doesn't seem to work.
 

tested05

Active member
Joined
Jan 21, 2017
Messages
70
Reaction score
2
thank you for the reply. I found some errors.

0AB0: key_pressed 18 // KEY_ALT
0AB0: key_pressed 88 // KEY_X

This is shown with alt+x keys. The on character is also normally output. But it doesn't seem to be the function I want.... I simply needed the ability to hit the "/space" chat and press the spacebar button for 0.3 seconds. Is this the script you wrote?
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
PHP:
0AB1: @Set_Virtual_Key 2 KeyOffSet 0x20 state 255
WAIT 300 // 0.3s
0AB1: @Set_Virtual_Key 2 KeyOffSet 0x20 state 0

:Set_Virtual_Key
{
    255 = true
    0 = false
    0AB1: @Set_Virtual_Key 2 KeyOffSet 0x57 state 255
}
2@ = 0xB72CC8
0@ *= 2
005A: 2@ += 0@  // (int)
0A8C: write_memory 2@ size 1 value 1@ virtual_protect 0
0AB2: ret 0
 

tested05

Active member
Joined
Jan 21, 2017
Messages
70
Reaction score
2
PHP:
0AB1: @Set_Virtual_Key 2 KeyOffSet 0x20 state 255
WAIT 300 // 0.3s
0AB1: @Set_Virtual_Key 2 KeyOffSet 0x20 state 0

:Set_Virtual_Key
{
    255 = true
    0 = false
    0AB1: @Set_Virtual_Key 2 KeyOffSet 0x57 state 255
}
2@ = 0xB72CC8
0@ *= 2
005A: 2@ += 0@  // (int)
0A8C: write_memory 2@ size 1 value 1@ virtual_protect 0
0AB2: ret 0
Sorry to keep asking. How can I make Set_Virtual_Key work only when the /space command is used?
 
Top