CLEO Help Reading chat

CLEO related
Status
Not open for further replies.

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
Hi. Hi need to read the chat, I would like to constantly check for a certain string to appear in the chat. Like "hello" for example. So if someone says "hello" it triggers something, I know how to do the loop and all. I just would like help with this
Code:
0B75: samp get_chat_string 1@ text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@

This is obviously the opcode I'll be using to check strings? If so, what are the arguments? How do I use them? How far back will it check in the chat for the word "Hello"? Can I set the amount of lines back it will check for the word? Because I wan't everytime the word "hello" is said to trigger something, then when it's said again it will trigger again. Not if it's said once in the entire chat it will constantly be looping because it will find "hello" way up in the chat. Thanks
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
I don't know how to use that i use a scm func, but that must be something like this:

1@ = id/number of chatlog line
2@ = the text you got with 1@
3@ = idk
4@ = chatlog line color (maybe, idk)
5@ = prefix color, maybe {COLOR}?

I use this 0AB1: call @GETCHATTEXT 1 id 99 to 3@ to get the last line text.

Here is an example of how to use it:

Code:
{$CLEO .cs}

0000: NOP

WAIT 1000

:HELLOCHAT
wait 0
0AC8: 3@ = allocate_memory_size 260
0AB1: call @GETCHATTEXT 1 id 99 to 3@
if
// also i think you can use 0C18: 2@ = strstr string1 0@ string2 "hello"
0AD4: 4@ = scan_string 3@ format "hello"                                                                       
then
0AF9: "I READ HELLO FROM CHAT"
end
jump @HELLOCHAT

:GETCHATTEXT
wait 500
0AB1: call @GETSAMPBASE 0 1@
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 
005A: 1@ += 0@
1@ += 28
0AB2: ret 1 1@

:GETSAMPBASE
wait 0
0AA2: 31@ = load_library "kernel32.dll" // IF and SET
0AA4: 30@ = get_proc_address "GetModuleHandleA" library 31@ // IF and SET
0AA7: call_function 30@ num_params 1 pop 0 "samp.dll" 0@
0ab2: ret 1 0@

But one problem is you need that "hello" at the last line. That 0B75 is something like the scm func but without get the color of the chat.
 

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
I don't understand what's happening in your code. Why did you use just opcodes on some of the functions? Man who does that? And you never explained a thing. And it doesn't work, because regardless of me typing anything it spams "I READ HELLO FROM CHAT" as soon as I log on (I had to actually increase the wait 1000 to wait 10000 because it started spamming it before I could connect and then said I was banned cause it couldn't connect
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Code:
{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available
// MAKE THE CLEO ONLY WORK IF SAMPFUNCS IS LOADED


WHILE TRUE
    WAIT 0
    0AC8: 0@ = allocate_memory_size 260 // ALLOCATE MEMORY FOR THE CHAT STRING
    0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@ // THIS IS A FUNCTION THAT STORES THE LAST CHAT STRING INTO 0@    
    IF
    0C14: strcmp string1 0@ string2 "HELLO" // COMPARE STRING 0@ WITH "HELLO"
    THEN
        0AF8: samp add_message_to_chat "HELLO was found in chat" color -1
    END    
    0AC9: free_allocated_memory 0@ // FREE THE MEMORY
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: 1 1@
 

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
Thanks so much help Opcode! Now, how do I search for a certain piece of text in the line of code? Like if the chat output: "Billy Talent rocks!" and if I want to find the word "rocks" it will trigger it. Thanks
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
You have to know the exact text to make it work:
Example:
"{FF00FF}Type 123KEEKEK to win 292992$"

IF
0AD4: $FUCK = scan_string 0@ format "{FF00FF}Type %s to win %d$" 1@ 2@
THEN
1@ = 123KEEKEK
2@ = 292992
 
Status
Not open for further replies.
Top