CLEO Help Anyone know how to fix this? (See the picture).

CLEO related
Status
Not open for further replies.

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
How can i fix this? i can't scan text 2 (Strip) its must be "The Strip". But as you can see, it just says "The". How to scan full chat string at 1 lines?

This is the code i use:
Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
thread "EasyTaxi"
0000: NOP

:EasyTaxi_14
wait 0
   SAMP.Available
else_jump @EasyTaxi_14

:EasyTaxi_86
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_86
alloc 0@ 160
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
if
0AD4: $NOT_USED = scan_string 0@ format "Destination: {33AA33}%s" 5@v 
else_jump @EasyTaxi_86
wait 1000
say "/do Terlihat seseorang telah memasuki Taxi milik Ace."
wait 1000
say "Tujuan kemana?"
wait 2000
say "/do Penumpang: %s" 5@v
wait 1000
say "Oke, berangkat kita."
wait 200
free 0@
jump @EasyTaxi_86

Translate to English:
** You can see someone has entering the Ace's Taxi.
(Japanese) Ace Kiramatsu says: Where we go?
** Passenger: The (( Ace Kiramatsu ))
(Japanese) Ace Kiramatsu says: Oke, lets go.
 

Attachments

  • Screenshot_266.png
    Screenshot_266.png
    125.4 KB · Views: 53

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
226
Location
( ͡° ͜ʖ ͡°)
Im not sure if it works, but thats how i would do it:
- You maybe have to change the color of Destination: {00FF00}

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY


WHILE TRUE
    WAIT 0
    IF
    0B61:  samp is_local_player_spawned
    THEN
        IF
        8B4C: not samp is_dialog_active -1
        THEN
            0AC8: 0@ = allocate_memory_size 260
            0AC8: 1@ = allocate_memory_size 260
            0B75: samp get_chat_string 99 text_to 0@ prefix_to 33@ color_to 33@ prefix_color_to 33@
            
            IF
            0AD4: 33@ = scan_string 0@ format "Destination: {00FF00}" // 21 chars in this string
            THEN
                0C17: 2@ = strlen 0@
                2@ -= 21 // remove 21 chars
                0AB1: @COPY_STRING 4 text 0@ start 21 end 2@ to_buffer 1@
                wait 1000
                say "/do Terlihat seseorang telah memasuki Taxi milik Ace."
                wait 1000
                say "Tujuan kemana?"
                wait 2000
                say "/do Penumpang: %s" 1@
                wait 1000
                say "Oke, berangkat kita."
                wait 200
    
            END
            
            
            0AC9: free_allocated_memory 0@
            0AC9: free_allocated_memory 1@
        END
    END
END




: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
 

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
Im not sure if it works, but thats how i would do it:
- You maybe have to change the color of Destination: {00FF00}

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY


WHILE TRUE
    WAIT 0
    IF
    0B61:  samp is_local_player_spawned
    THEN
        IF
        8B4C: not samp is_dialog_active -1
        THEN
            0AC8: 0@ = allocate_memory_size 260
            0AC8: 1@ = allocate_memory_size 260
            0B75: samp get_chat_string 99 text_to 0@ prefix_to 33@ color_to 33@ prefix_color_to 33@
           
            IF
            0AD4: 33@ = scan_string 0@ format "Destination: {00FF00}" // 21 chars in this string
            THEN
                0C17: 2@ = strlen 0@
                2@ -= 21 // remove 21 chars
                0AB1: @COPY_STRING 4 text 0@ start 21 end 2@ to_buffer 1@
                wait 1000
                say "/do Terlihat seseorang telah memasuki Taxi milik Ace."
                wait 1000
                say "Tujuan kemana?"
                wait 2000
                say "/do Penumpang: %s" 1@
                wait 1000
                say "Oke, berangkat kita."
                wait 200
   
            END
           
           
            0AC9: free_allocated_memory 0@
            0AC9: free_allocated_memory 1@
        END
    END
END




: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
Still not work bro. Nothing happen when i try at the Game.
 

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
i've replace the scan_string like this, it still not work. help me please?
Code:
0AD4: $NOT_USED = scan_string 0@ format "Destination: {33AA33}%s {33AA33}%s" 5@v 6@v
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
maybe try using format like this: "Destination: {%*[^}]}%[^\n]"

It works well with sscanf here: https://www.onlinegdb.com/online_c_compiler
C:
#include <stdio.h>

int main()
{
    char *chatline = "Destination: {33AA33}The Strip";
    
    char parsed[100] = {0};
    sscanf(chatline, "Destination: {%*[^}]}%[^\n]", parsed);
    printf(parsed);
    return 0;
}
This should work with any color, just try that with your original code
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,115
Solutions
5
Reaction score
879
Location
Lithuania
maybe try using format like this: "Destination: {%*[^}]}%[^\n]"

It works well with sscanf here: https://www.onlinegdb.com/online_c_compiler
C:
#include <stdio.h>

int main()
{
    char *chatline = "Destination: {33AA33}The Strip";
 
    char parsed[100] = {0};
    sscanf(chatline, "Destination: {%*[^}]}%[^\n]", parsed);
    printf(parsed);
    return 0;
}
This should work with any color, just try that with your original code
Wow you again made awesome format , very useful, thanks

If i not doing wrong
PHP:
{$CLEO .cs}

0000: NOP

repeat
wait 0
until 0AFA: SAMP_IS_READY

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
    0AD4: $NOT_USED = scan_string 0@ format "Destination: {%*[^}]}%[^\n]" $NOT_USED 4@ //IF and SET
    then
        0AD1: show_formatted_text_highpriority "%s" time 1337 4@
    end
end

end
 
Last edited:

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
the function of * character in the format is to ignore that expression, meaning that you extract only one expression instead of 2, so only 1 output parameter is required (so $NOT_USED could be deleted)

Code:
if 0AD4: $NOT_USED = scan_string 0@ format "Destination: {%*[^}]}%[^\n]" 4@

Or:
Code:
0A8C: write_memory 4@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AA5: call 0x8220AD num_params 3 pop 3 4@ "Destination: {%*[^}]}%[^\n]" 0@
0A8D: 5@ = read_memory 4@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 5@ > 0
then
// the format was found
end

If you remove the * character then you can also supply another parameter to get the color of the text to reuse it later (as a string, unless you convert it or change the expression into %x). Here's example:
Code:
#include <stdio.h>

int main()
{
    char *chatline = "Destination: {33AA33}The Strip";
    
    char parsed_text[100] = {0};
    char parsed_color_str[100] = {0};
    int parsed_color_int;
    sscanf(chatline, "Destination: {%[^}]}%[^\n]", parsed_color_str, parsed_text);
    
    sscanf(chatline, "Destination: {%x}%[^\n]", &parsed_color_int, parsed_text);
    
    printf("Parsed text = %s\nParsed color (string) = %s\nParsed color (int, hex) = %X", parsed_text, parsed_color_str, parsed_color_int);
    
    return 0;
}
It prints out:
Parsed text = The Strip
Parsed color (string) = 33AA33
Parsed color (int, hex) = 33AA33

Btw keep in mind to use `alloc 4@ 200` at the begining of the code
 
Last edited:

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
Like this?
Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
if
0AD4: $NOT_USED = scan_string 0@ format "Destination: {%[^}]}%[^\n]" 5@
else_jump @EasyTaxi_27
wait 1000
say "Destination Detected: %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
the "*" is not there which means that the color will also be extracted and overwrite 5@, the desired text will try to overwrite the next address on the stack (which should be provided and wasn't)

so either use:
0AD4: $NOT_USED = scan_string 0@ format "Destination: {%*[^}]}%[^\n]" 5@

or:
-add alloc 6@
-add free 6@
-use: 0AD4: $NOT_USED = scan_string 0@ format "Destination: {%[^}]}%[^\n]" 6@ 5@
//6@ will contain the color, 5@ will contain the text

If you pick one of these methods and it still won't work then try using the following:
Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
0A8C: write_memory 5@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AA5: call 0x8220AD num_params 3 pop 3 5@ "Destination: {%*[^}]}%[^\n]" 0@
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 7@ > 0
else_jump @EasyTaxi_27
wait 1000
say "Destination Detected: %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27
just make sure that 7@ does not interfere with other parts of the code (if it's used in other places)

Btw why are you using "98" instead of "99" in SAMP.GetChatString?
 

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
the "*" is not there which means that the color will also be extracted and overwrite 5@, the desired text will try to overwrite the next address on the stack (which should be provided and wasn't)

so either use:
0AD4: $NOT_USED = scan_string 0@ format "Destination: {%*[^}]}%[^\n]" 5@

or:
-add alloc 6@
-add free 6@
-use: 0AD4: $NOT_USED = scan_string 0@ format "Destination: {%[^}]}%[^\n]" 6@ 5@
//6@ will contain the color, 5@ will contain the text

If you pick one of these methods and it still won't work then try using the following:
Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
0A8C: write_memory 5@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AA5: call 0x8220AD num_params 3 pop 3 5@ "Destination: {%*[^}]}%[^\n]" 0@
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 7@ > 0
else_jump @EasyTaxi_27
wait 1000
say "Destination Detected: %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27
just make sure that 7@ does not interfere with other parts of the code (if it's used in other places)

Btw why are you using "98" instead of "99" in SAMP.GetChatString?

Why me using "98" instead of "99" in SAMP.GetChatString? Because when I type /starttaxi at the server, it will be like this.So i use 98.
 

Attachments

  • Screenshot_267.png
    Screenshot_267.png
    46 KB · Views: 8

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
the "*" is not there which means that the color will also be extracted and overwrite 5@, the desired text will try to overwrite the next address on the stack (which should be provided and wasn't)

so either use:
0AD4: $NOT_USED = scan_string 0@ format "Destination: {%*[^}]}%[^\n]" 5@

or:
-add alloc 6@
-add free 6@
-use: 0AD4: $NOT_USED = scan_string 0@ format "Destination: {%[^}]}%[^\n]" 6@ 5@
//6@ will contain the color, 5@ will contain the text

If you pick one of these methods and it still won't work then try using the following:
Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
0A8C: write_memory 5@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AA5: call 0x8220AD num_params 3 pop 3 5@ "Destination: {%*[^}]}%[^\n]" 0@
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 7@ > 0
else_jump @EasyTaxi_27
wait 1000
say "Destination Detected: %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27
just make sure that 7@ does not interfere with other parts of the code (if it's used in other places)

Btw why are you using "98" instead of "99" in SAMP.GetChatString?

Can i add something like "." or "Sir" at /say "Destination Detected: %s"/?

Example:
say "I want to go %s, sir." 5@
 

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
It work, but not fully working. Idk why, you can see the picture.

This is the code:

Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
0A8C: write_memory 5@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AA5: call 0x8220AD num_params 3 pop 3 5@ "Destination: {%*[^}]}%[^\n]" 0@
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 7@ > 0
else_jump @EasyTaxi_27
wait 1000   
say "/do Terlihat seseorang telah memasuki Taxi milik Ace."
wait 1100
say "Tujuan kemana?"
wait 1100
say "/do Penumpang: Ke %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27
 

Attachments

  • Screenshot_268.png
    Screenshot_268.png
    77.5 KB · Views: 17
  • Screenshot_269.png
    Screenshot_269.png
    84.1 KB · Views: 18

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
It looks like the problem is that it stops on "\" and "n" instead of stopping on newline byte, I'll check it out with different function and I'll let you know
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
this one should work
Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
0A8C: write_memory 5@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AC6: 8@ = label @format offset
0AA5: call 0x8220AD num_params 3 pop 3 5@ 8@ 0@
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 7@ > 0
else_jump @EasyTaxi_27
wait 1000   
say "/do Terlihat seseorang telah memasuki Taxi milik Ace."
wait 1100
say "Tujuan kemana?"
wait 1100
say "/do Penumpang: Ke %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27

:format
hex
"Destination: {%*[^}]}%[^" 0A "]" 00
end
 

ha.sh

Active member
Joined
Nov 14, 2018
Messages
66
Reaction score
0
this one should work
Code:
:EasyTaxi_27
wait 0
if and
   SAMP.IsLocalPlayerSpawned
   not SAMP.IsDialogActive(-1)
else_jump @EasyTaxi_27
alloc 0@ 160
alloc 5@ 200
SAMP.GetChatString(98, 0@, $NOT_USED, $NOT_USED, $NOT_USED)
0A8C: write_memory 5@ size 1 value 0 virtual_protect 0 // just to make sure that it's empty
0AC6: 8@ = label @format offset
0AA5: call 0x8220AD num_params 3 pop 3 5@ 8@ 0@
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0 // read first byte to check if it was overwritten
if 7@ > 0
else_jump @EasyTaxi_27
wait 1000  
say "/do Terlihat seseorang telah memasuki Taxi milik Ace."
wait 1100
say "Tujuan kemana?"
wait 1100
say "/do Penumpang: Ke %s" 5@
wait 200
free 0@
free 5@
jump @EasyTaxi_27

:format
hex
"Destination: {%*[^}]}%[^" 0A "]" 00
end
Thanks man, it work.
 
Status
Not open for further replies.
Top