CLEO Help [SA:MP] Read chat and auto reply

CLEO related
Status
Not open for further replies.

Cataopcode

Member
Joined
Jul 8, 2015
Messages
17
Reaction score
0
I want to create a script but I don;t know how.
When someone says something like ' what guns do you use?' my script auto answer ' I use m4....'
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
226
Location
( ͡° ͜ʖ ͡°)
You can get the last chat string using:
0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@

Then you display it using:
0AD1: show_formatted_text_highpriority "ChatString: %s" time 2000 2@

and then you create a check to filter out the thingys:

if
0AD4: 33@ = scan_string 2@ format "what guns do you use? "
then
say "i use m4"

or you hook the incoming chat packets..
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
226
Location
( ͡° ͜ʖ ͡°)
Here is an OLD autotyper i made some years ago ( GETCHATENTRYTEXT function doesnt work anymore(old offsets) )
Code:
{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available


WHILE TRUE
    WAIT 0
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 1@ = allocate_memory_size 260
    0AC8: 2@ = allocate_memory_size 260
    0AC8: 5@ = allocate_memory_size 260
    0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@
    
    IF
    0C18: 1@ = strstr string1 0@ string2 ">> Server: First to type '{FF0000}"
    THEN
        IF
        0C18: 2@ = strstr string1 1@ string2 "{FFCC00}"
        THEN
            0C17: 3@ = strlen 0@
            0C17: 4@ = strlen 2@
            0062: 3@ -= 4@
            3@ -= 2
            0AB1: @COPY_STRING 4 text 0@ start 33 end 3@ to_buffer 5@
            0209: 6@ = random_int_in_ranges 3500 4100
            WAIT 6@
            0AF9: SAY 5@
            WAIT 20000
        END
    END
    
    0AC9: free_allocated_memory 0@
    0AC9: free_allocated_memory 1@
    0AC9: free_allocated_memory 2@
    0AC9: free_allocated_memory 5@
END





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

:copy_string
var
    1@: int
    2@: int
    4@: int
    5@: int
end
if 1@ < 0
then
    059A: return_false
    ret 0
end
0C17: 5@ = strlen 0@
if 2@ > 5@
then
    2@ = 5@
end
if 5@ <= 0
then
    059A: return_false
    ret 0
end
if 2@ < 1@
then
    059A: return_false
    ret 0
end
if 1@ >= 1
then
    for 4@ = 0 to 1@
    inc(0@)
    end
end
2@ -= 1@
inc(2@)
0C10: memcpy destination 3@ source 0@ size 2@
0485: return_true
ret 0
 

Cataopcode

Member
Joined
Jul 8, 2015
Messages
17
Reaction score
0
{$CLEO .cs}:
0000: NOP
:Autoreply
03A4: name_thread "Autoreply"
wait 1
:Autoreply_1
wait 0
if
0256: player $player_char defined
004D: jump_if_false @Autoreply

0B75: samp get_chat_string 1@ text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@


0AD1: show_formatted_text_highpriority "ChatString: %s" time 2000 2@
if
0AD4: 4@ = scan_string 0@v format "Salut Catalin" 5@ 6@ 7@ //IF and SET
then
say "Salut si tie"
0A93: end_custom_thread
 

Attachments

  • 1545934827136.png
    1545934827136.png
    74.5 KB · Views: 31

Cataopcode

Member
Joined
Jul 8, 2015
Messages
17
Reaction score
0
{$CLEO .cs}:
0000: NOP
:Autoreply
03A4: name_thread "Autoreply"
wait 1
:Autoreply_1
wait 0
if
0256: player $player_char defined
004D: jump_if_false @Autoreply

0B75: samp get_chat_string 1@ text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@


0AD1: show_formatted_text_highpriority "ChatString: %s" time 2000 2@
if
0AD4: 4@ = scan_string 0@v format "Salut Catalin" 5@ 6@ 7@ //IF and SET
then
say "Salut si tie"
end

but crashing in game

Warning(s007): Exception 0xC0000005 at 0x465F70

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x571A00

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x409A95

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x409A95

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:09] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Connected. Joining the game...

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x409A95

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x409A95

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:10] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:11] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:11] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:11] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:11] Warning(s007): Exception 0xC0000005 at 0x0

[20:27:11] Warning(s007): Exception 0xC0000005 at 0x0
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
226
Location
( ͡° ͜ʖ ͡°)
Hmm... looks like you need to read more tutorials and do simple things first before you can even make such a mod..

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY


WHILE TRUE
    WAIT 0
    IF
    0256: player $player_char defined
    THEN
        0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@               
        0AD1: show_formatted_text_highpriority "ChatString: %s" time 2000 2@
        
        if
        0AD4: 33@ = scan_string 2@ format "Salut Catalin" //IF and SET   0C21: stricmp string1 0@ string2 1@
        then
            say "Salut si tie"   
        end
    
    END
END
 

CristianSS

Active member
Joined
Jul 24, 2017
Messages
27
Reaction score
0
You can create it in c++
pSAMP->getChat()->chatEntry[99].szText // Use this to get the last chat line. And then use strstr on it to search what do you want.
 

Hidend

Expert
Joined
Mar 4, 2013
Messages
625
Reaction score
39
You should allocate memory to 2@, i tried to do it myself and tested it but it does answer "Salut si tie" 4 times idk why
EDIT: I added two wait and now it doesn't do that weird

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY


WHILE TRUE
    WAIT 0
    IF
    0256:  player $PLAYER_CHAR defined
    THEN
        0AC8: 2@ = allocate_memory_size 128
        0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@              
        0AD1: show_formatted_text_highpriority "ChatString: %s" time 2000 2@
        IF
        0C29: 33@ = stristr string1 2@ string2 "Salut Catalin"
        then
            wait 1000
            say "Salut si tie" 
            wait 150 
        end
        free 2@
    END
END
 
Last edited:

Cataopcode

Member
Joined
Jul 8, 2015
Messages
17
Reaction score
0
You should allocate memory to 2@, i tried to do it myself and tested it but it does answer "Salut si tie" 4 times idk why
EDIT: I added two wait and now it doesn't do that weird

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY


WHILE TRUE
    WAIT 0
    IF
    0256:  player $PLAYER_CHAR defined
    THEN
        0AC8: 2@ = allocate_memory_size 128
        0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@             
        0AD1: show_formatted_text_highpriority "ChatString: %s" time 2000 2@
        IF
        0C29: 33@ = stristr string1 2@ string2 "Salut Catalin"
        then
            wait 1000
            say "Salut si tie"
            wait 150
        end
        free 2@
    END
END
Thank you, it works, crashing but i will look into it and try to make it work
 

Krc

Active member
Joined
Mar 30, 2018
Messages
193
Reaction score
25
Location
Lithuania
Thank you, it works, crashing but i will look into it and try to make it work
Add
alloc 260

Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0256: player $PLAYER_CHAR defined

0AC8: 0@ = allocate_memory_size 260
0AC8: 1@ = allocate_memory_size 260

While True
Wait 0
0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@       
If
0C29: $NOT_USED = stristr string1 0@ string2 "Salut Catalin"
Then
say "Salut si tie"
wait 1000
end
free 0@
free 1@
END
 
Last edited:

Cataopcode

Member
Joined
Jul 8, 2015
Messages
17
Reaction score
0
Add
alloc 260

Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0256: player $PLAYER_CHAR defined

0AC8: 0@ = allocate_memory_size 260
0AC8: 1@ = allocate_memory_size 260

While True
Wait 0
0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@      
If
0C29: $NOT_USED = stristr string1 0@ string2 "Salut Catalin"
Then
say "Salut si tie"
wait 1000
end
free 0@
free 1@
END
Thank you, i will try
it works or it crashes, i tested it and it works so is your fault
Worked but It crashed at some point
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,115
Solutions
5
Reaction score
879
Location
Lithuania
@Cataopcode

Say no to Crash !!!

PHP:
{$CLEO .cs}

0000: NOP

REPEAT
Wait 0
Until 0afa:

While True
Wait 0

if
0B61:  samp is_local_player_spawned
then
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 1@ = allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@     
    If
    0C29: $NOT_USED = stristr string1 0@ string2 "Salut Catalin"
    Then
        say "Salut si tie"
        wait 1000
    end
end

END
 

Cataopcode

Member
Joined
Jul 8, 2015
Messages
17
Reaction score
0
@Cataopcode

Say no to Crash !!!

PHP:
{$CLEO .cs}

0000: NOP

REPEAT
Wait 0
Until 0afa:

While True
Wait 0

if
0B61:  samp is_local_player_spawned
then
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 1@ = allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@    
    If
    0C29: $NOT_USED = stristr string1 0@ string2 "Salut Catalin"
    Then
        say "Salut si tie"
        wait 1000
    end
end

END
Thank you, you are the best, is working perfectly
 

TheDjCody

Active member
Joined
Sep 6, 2018
Messages
40
Reaction score
5
@Cataopcode

Say no to Crash !!!

PHP:
{$CLEO .cs}

0000: NOP

REPEAT
Wait 0
Until 0afa:

While True
Wait 0

if
0B61:  samp is_local_player_spawned
then
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 1@ = allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@    
    If
    0C29: $NOT_USED = stristr string1 0@ string2 "Salut Catalin"
    Then
        say "Salut si tie"
        wait 1000
    end
end

END

Exellent, I'm looking for this.
 
Status
Not open for further replies.
Top