CLEO Help Script to write custom command

CLEO related
Status
Not open for further replies.

oose

New member
Joined
Oct 18, 2018
Messages
2
Reaction score
0
Hello,

what I'm trying to achieve is when i write command with some added text it changes what certain key does.

For exampe:
By default in script if I press key 2 (KEYCODE - 50) it sends command to samp: "/ant ID_OR_NICK"
when I write command "/setant 12" it should change that if I press key 2 (KEYCODE - 50) it would send command to samp: "/ant 12", if i write "/setant Oose", it would send after keypress "/ant Oose"

Now what I have is this code:
Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0AFA: is_samp_structures_available
0B34: "setant" @setant
1@v = "ID_OR_NICK"


While True
Wait 0
0AC8: 0@ = allocate_memory_size 260
0AB1: @ant 1 id 99 to 0@    
if
0AB0:   key_pressed 50
then
0AF9: samp say_msg "/ant %s" 1@v
END
0AC9: free_allocated_memory 0@
END


:setant
SAMP.IsCommandTyped(0@)
0AD4: $PLAYER_CHAR = scan_string 0@ format "%s" 1@v
CmdRet

:ant
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252
005A: 1@ += 0@
1@ += 28
0AB2: 1 1@

Problem is that nor key_pressed 50 statment works, nor :setant works (if I write /setant something, it starts to lag and samp screen starts flickering)


Could someone please explain what should I change?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,492
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
I dont know if it works but here you go:

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY
0B34: samp register_client_command "setant" to_label @setant



WHILE TRUE
    WAIT 0
    IF
    0AB0: key_pressed 50
    THEN
        IF
        0B23:  samp is_player_connected 1@
        THEN
            0B36: samp 2@ = get_player_nickname 1@
            0AF9: samp say_msg "/ant %s" 2@
    
            
            REPEAT
                WAIT 0 // Anti_Spam
            UNTIL 8ab0: key_not_pressed 50
        END
    END
END




:setant
0B35: samp 0@ = get_last_command_params
IF
0AD4: 33@ = scan_string 0@ format "%d" 1@
THEN
    IF
    0B23:  samp is_player_connected 1@
    THEN
        0B36: samp 2@ = get_player_nickname 1@
        0AF8: samp add_message_to_chat "Actions will Apply to PlayerID: %d, %s" color -1 1@ 2@
    END
ELSE // IF you entered player name:

    0C17: 2@ = strlen 0@
    IF NOT 2@ == 0
    THEN
        0ab1: @get_playerid_by_name 1 0@ 1@   
        IF
        0B23:  samp is_player_connected 1@
        THEN
            0B36: samp 2@ = get_player_nickname 1@
            0AF8: samp add_message_to_chat "Actions will Apply to PlayerID: %d, %s" color -1 1@ 2@
    
    
        END
    END
END
0B43: samp cmd_ret









:getPlayerIdByName
for 1@ = 0 to 1000
    if SAMP.IsPlayerConnected(1@)
    then
        2@ = SAMP.GetPlayerNickname(1@)
        if 0C14: strcmp string1 0@ string2 2@
        then break
        end
    end
end
0ab2: 1 1@
 

oose

New member
Joined
Oct 18, 2018
Messages
2
Reaction score
0
I dont know if it works but here you go:

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY
0B34: samp register_client_command "setant" to_label @setant



WHILE TRUE
    WAIT 0
    IF
    0AB0: key_pressed 50
    THEN
        IF
        0B23:  samp is_player_connected 1@
        THEN
            0B36: samp 2@ = get_player_nickname 1@
            0AF9: samp say_msg "/ant %s" 2@
   
           
            REPEAT
                WAIT 0 // Anti_Spam
            UNTIL 8ab0: key_not_pressed 50
        END
    END
END




:setant
0B35: samp 0@ = get_last_command_params
IF
0AD4: 33@ = scan_string 0@ format "%d" 1@
THEN
    IF
    0B23:  samp is_player_connected 1@
    THEN
        0B36: samp 2@ = get_player_nickname 1@
        0AF8: samp add_message_to_chat "Actions will Apply to PlayerID: %d, %s" color -1 1@ 2@
    END
ELSE // IF you entered player name:

    0C17: 2@ = strlen 0@
    IF NOT 2@ == 0
    THEN
        0ab1: @get_playerid_by_name 1 0@ 1@  
        IF
        0B23:  samp is_player_connected 1@
        THEN
            0B36: samp 2@ = get_player_nickname 1@
            0AF8: samp add_message_to_chat "Actions will Apply to PlayerID: %d, %s" color -1 1@ 2@
   
   
        END
    END
END
0B43: samp cmd_ret









:getPlayerIdByName
for 1@ = 0 to 1000
    if SAMP.IsPlayerConnected(1@)
    then
        2@ = SAMP.GetPlayerNickname(1@)
        if 0C14: strcmp string1 0@ string2 2@
        then break
        end
    end
end
0ab2: 1 1@
Thanks for response. For some reason when i set for instance "/setant 12" and I press 2 ir sends command "/ant d"
 
Status
Not open for further replies.
Top