CLEO Help auto /accept repar

CLEO related
Status
Not open for further replies.

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
{$CLEO .cs}

0000:

repeat
wait 0
until 0afa:

while true
wait 0

FOR 6@ = 98 TO 99
0AC8: 0@ = allocate_memory_size 260 // ALLOCATE MEMORY FOR THE CHAT STRING
0AB1: @GETCHATENTRYTEXT 1 id 6@ to 0@ // THIS IS A FUNCTION THAT STORES THE LAST CHAT STRING INTO 0@

if
0AD4: $NOT_USED = scan_string 0@ format "Tasteaza /accept repair pentru a accepta." $NOT_USED 5@
then
say "/accept repair" 5@
end

END

end


:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@

davidel offered you repair (ID:46) for 1$. Type /accept repair to accept.

i need to detect the last part of the phrase "Type /accept repair to accept."
when it detects to automatically type /accept repair
why it doesnt work? nothing happens.. no error etc
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,719
Solutions
1
Reaction score
111
C++:
assuming 0@ == chat line

if 0C29: 1@ = search in_string 0@ this_string "hello"
then printf "found hello in chat" 100
end
also you might have to use the "get chat line" opcode for getting the chatline. With 0c29 you don't have to be specific it basically just means if the string contains that word then the condition is true.
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
can you put it in my code please?
Code:
{$CLEO}
{$INCLUDE SF}
0000:

repeat
wait 0
until SAMP.Available()


0BE3: raknet setup_incoming_rpc_hook @chat_hook

WHILE TRUE
WAIT 0

END

:chat_hook
0BE5: raknet 31@ = get_hook_param PARAM_PACKETID
if 31@ == RPC_ScrClientMessage
then 
    alloc 28@ 129
    0C11: memset destination 28@ value 0 size 129
    0BE5: raknet 30@ = get_hook_param PARAM_BITSTREAM
    0BE7: raknet 27@ = bit_stream_read 30@ type BS_TYPE_INT //color
    0BE7: raknet 29@ = bit_stream_read 30@ type BS_TYPE_INT //lenght
    0BE8: raknet bit_stream 30@ read_array 28@ size 29@ //string
    0C0D: struct 28@ offset 29@ size 1 = 0
    
    IF 0C18: $NOT_STRING = strstr string1 28@ string2 "text" //conditia pentru text
    THEN
        //NOP
        say "/accept repair"
    THEN
    
    free 28@
end
0BE0: raknet hook_ret true
There ya go
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,719
Solutions
1
Reaction score
111
I imagine that code you posted would spam the chat as it loops through all of the chat so once you have done /repair it will still do /repair until that chatline is gone. It's also a non-sampfuncs equivalent when you clearly are using sampfuncs.
C++:
{$CLEO .CS}

THREAD 'AutoRepair'
alloc 0@ 256

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0
   
    0B75: samp get_chat_string 99 text_to 0@ prefix_to $NOT_USED color_to $NOT_USED prefix_color_to $NOT_USED
    IF
        0C29: $NOT_USED = stristr string1 "Tasteaza /accept repair pentru a accepta." string2 0@
    THEN
        0AF9: samp say_msg "/repair"
        WAIT 3000 // Delay to stop spam while that chat line is still there.
    END
   
END
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
I imagine that code you posted would spam the chat as it loops through all of the chat so once you have done /repair it will still do /repair until that chatline is gone. It's also a non-sampfuncs equivalent when you clearly are using sampfuncs.
C++:
{$CLEO .CS}

THREAD 'AutoRepair'

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0
   
    0B75: samp get_chat_string 99 text_to 0@ prefix_to $NOT_USED color_to $NOT_USED prefix_color_to $NOT_USED
    IF
        0C29: $NOT_USED = stristr string1 "Tasteaza /accept repair pentru a accepta." string2 0@
    THEN
        0AF9: samp say_msg "/repair"
        WAIT 3000 // Delay to stop spam while that chat line is still there.
    END
   
END
don't you have to allocate some memory for that?
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
{$CLEO}
{$INCLUDE SF}
0000:

repeat
wait 0
until SAMP.Available()


0BE3: raknet setup_incoming_rpc_hook @chat_hook

WHILE TRUE
WAIT 0

END

:chat_hook
0BE5: raknet 31@ = get_hook_param PARAM_PACKETID
if 31@ == RPC_ScrClientMessage
then
    alloc 28@ 129
    0C11: memset destination 28@ value 0 size 129
    0BE5: raknet 30@ = get_hook_param PARAM_BITSTREAM
    0BE7: raknet 27@ = bit_stream_read 30@ type BS_TYPE_INT //color
    0BE7: raknet 29@ = bit_stream_read 30@ type BS_TYPE_INT //lenght
    0BE8: raknet bit_stream 30@ read_array 28@ size 29@ //string
    0C0D: struct 28@ offset 29@ size 1 = 0
   
    IF 0C18: $NOT_STRING = strstr string1 28@ string2 "text" //conditia pentru text
    THEN
        //NOP
        say "/accept repair"
    THEN
   
    free 28@
end
0BE0: raknet hook_ret true
There ya go
how can i make to activate with 0B34: samp register_client_command ? i tried and i cant get it done
uknown server command..
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
how can i make to activate with 0B34: samp register_client_command ? i tried and i cant get it done
uknown server command..
Code:
{$CLEO}
{$INCLUDE SF}
0000:
repeat
wait 0
until SAMP.Available()

0BE3: raknet setup_incoming_rpc_hook @chat_hook
30@ = 0
0B34: "autorepair" @status
WHILE TRUE
WAIT 0
END
:chat_hook
0BE5: raknet 31@ = get_hook_param PARAM_PACKETID
if 31@ == RPC_ScrClientMessage
then  
    alloc 28@ 129
    0C11: memset destination 28@ value 0 size 129
    0BE5: raknet 30@ = get_hook_param PARAM_BITSTREAM
    0BE7: raknet 27@ = bit_stream_read 30@ type BS_TYPE_INT //color
    0BE7: raknet 29@ = bit_stream_read 30@ type BS_TYPE_INT //lenght
    0BE8: raknet bit_stream 30@ read_array 28@ size 29@ //string
    0C0D: struct 28@ offset 29@ size 1 = 0
   
    IF 0C18: $NOT_STRING = strstr string1 28@ string2 "text" //conditia pentru text
    THEN
        IF 30@ == 1
        THEN
            //NOP
            say "/accept repair"
        END
    END
   
    free 28@
end
0BE0: raknet hook_ret true
:status
SAMP.IsCommandTyped(20@)
0B12: 30@ = 30@ XOR 1
IF 30@ == 1
THEN
    chatmsg "{ffff00}[AutoRepair]: {cecece}Autorepair on!" -1
ELSE
    chatmsg "{ffff00}[AutoRepair]: {cecece}Autorepair off!" -1
END
SAMP.CmdRet()
not 100% sure it works but try it.
 
Status
Not open for further replies.
Top