CLEO Help How do I read a string in the chat?

CLEO related
Status
Not open for further replies.

Yender

New member
Joined
Mar 26, 2019
Messages
4
Reaction score
1
I want my script to make me leave every time someone joins the server (there will be a message in the chat like "PLAYERNAME joined the server.")

I tried

"0AD4: 4@ = scan_string 0@v format "%d + %d = %d" 5@ 6@ 7@ "
and
"0C29: 2@ = stristr string1 0@ string2 1@"
but don't know how to use them properly.

Code:
{$CLEO}
0000:NOP

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available

   :check
   wait 100
    if
    0C29: 2@ = stristr string1 1@ string2 "joined the server"
    jf @check
        0B28: samp disconnect_with_reason 1@
    jump @check

this shit will make my game crash. What do the parameters mean?
 

batonkal

Active member
Joined
May 6, 2017
Messages
100
Reaction score
16
Location
Bosnia and Herzegovina
You first need to scan chat and then you need to compare.

Because with this you are comparing string "joined the server" with non-existent variable 1@

0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
^ - Use this to get last chat string.

And for
0B28: samp disconnect_with_reason 1@
use
0B28: samp disconnect_with_reason 0 - instant quit
or
0B28: samp disconnect_with_reason 1 - timeout (exit after 15 seconds)


Try this (didn't test this):
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 "joined the server"
    then
        0B28: samp disconnect_with_reason 0
    end
end

END
 
Last edited:

truongvi2013

Active member
Joined
May 26, 2016
Messages
82
Reaction score
10
Location
Vietnam
You first need to scan chat and then you need to compare.

Because with this you are comparing string "joined the server" with non-existent variable 1@

0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
^ - Use this to get last chat string.

And for
0B28: samp disconnect_with_reason 1@
use
0B28: samp disconnect_with_reason 0 - instant quit
or
0B28: samp disconnect_with_reason 1 - timeout (exit after 15 seconds)


Try this (didn't test this):
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 "joined the server"
    then
        0B28: samp disconnect_with_reason 0
    end
end

END


How i can replace scan string 0C29 using 0AD4(noSampFuncs 0.3.DL)
Offsets are correct
but 0AD4: not working for me
it doesn't scan anything and spamming "Working......"(<--Test if success code)





Code:
{$CLEO .cs}

0000: NOP

wait 10000

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10 //0.3.DL Offsets
FUNC_SEND_CMD_03DL = 0x69340 //0.3.DL Offsets
end

/*0AC8: 9@ = allocate_memory_size 260 - Tried to allocate before while true but still not working*/

while true
wait 0
0AC8: 9@ = allocate_memory_size 260 //Allocate memory for 9@ (Tried lower to 145 but still not working either)
0AB1: @getChatEntryText 1 id 99 to 9@ //Function store last string into 9@
if
0AD4: $NOT_USED = scan_string 9@ format "You have received new messages (/openmails)" //This is static text,the color is white,or no color at all?
then
    0AD1: show_formatted_text_highpriority "Working...." time 2000 //My test if success code,i will place my 0AB1: @SEND_CMD ...... here later if the script is working.
    wait 0
end

end //end for while true



:SEND_CMD
//0AB1: @SEND_CMD 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SEND_CMD_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END
0AB2: 0

:getChatEntryText
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += SAMP_CHAT_INFO_OFFSET_03DL
    0A8D: 1@ readMem 1@ sz 4 vp 0
    1@ += 0x132
    0@ *= 0xFC
    005A: 1@ += 0@
    1@ += 0x20
    0AA3: 1@
END
0AB2: ret 1 1@
 
Status
Not open for further replies.
Top