CLEO Help Weird String Error

CLEO related
Status
Not open for further replies.

IbraJ

Member
Joined
May 14, 2020
Messages
13
Reaction score
1
Location
None
Code:
:test
wait 0
if
  8B4C: -1
jf @test
alloc 9@ 260          
SAMP.GetChatString(99, 9@, 10@, 11@, 12@)
if
  0AD4: $USELESS = scan_string 9@ format "* %s %s has frisked %s %s." 13@v 14@v 15@v 16@v //IF and SET
jf @test
printf "%s %s" 3000 15@v 16@v
jump @test

Instead of printing correct full name of the frisked person, it is giving it in a very odd sequence:
 

Attachments

  • 22.PNG
    22.PNG
    70.9 KB · Views: 21

IbraJ

Member
Joined
May 14, 2020
Messages
13
Reaction score
1
Location
None
Explain what it's supposed to say and what it says instead
HZ:RP

When you /frisk someone, it detects the message "Player1 has frisked Player2.". Now, I want to take the name of "Player2" (the person I've frisked) and show it in 0AD1 but it is not showing it properly. Like, their sequence is very odd, the first name is attached to the last name and string is messed up. See the attachment image, the person I've frisked... its name is "Floki Vilgerdason" but see how it is showing the frisked person's name
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Ok so.. u dont put %s %s as 13@v and 14@v, u simply put "%s" 14@v. For each name. You do that for the player2 name too. No need for 2 variables.
 

IbraJ

Member
Joined
May 14, 2020
Messages
13
Reaction score
1
Location
None
Ok so.. u dont put %s %s as 13@v and 14@v, u simply put "%s" 14@v. For each name. You do that for the player2 name too. No need for 2 variables.
There is no underscore so both are separate strings. Also, I tried your method and it didn't work. See my above attachment ^^
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
@v vars take up the next 4 vars so 14@v = 14@, 15@, 16@, 17@ so most likely your variables are interacting with each other and affecting the text. Just use normal vars with allocated memory.
 

IbraJ

Member
Joined
May 14, 2020
Messages
13
Reaction score
1
Location
None
@v vars take up the next 4 vars so 14@v = 14@, 15@, 16@, 17@ so most likely your variables are interacting with each other and affecting the text. Just use normal vars with allocated memory.
I tried but it doesn't work. Instead, it starts giving warning messages. Could you make a code for it so I can understand it more perfectly?
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
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 1024
    0AC8: 1@ = allocate_memory_size 1024
    for 31@ = 97 to 99
        0B75: samp get_chat_string 31@ text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
        0AC8: 4@ = allocate_memory_size 260
        0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 4@ 
        if
        0C29: $NOT_USED = stristr string1 4@ string2 "has frisked"
        then
            if
            0AD4: $NOT_USED = scan_string 4@ format "* %s has frisked %s." 5@ 6@
            then
                chatmsg "%s %s" -1 5@ 6@
            end
        end
    end
end

end      

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end
 
        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END
 
        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0
 

IbraJ

Member
Joined
May 14, 2020
Messages
13
Reaction score
1
Location
None
@Parazitas - It is not even triggering the text of the chat. Here, I modified it but it becomes like I had but crashes again:


Code:
{$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 1024
    0AC8: 1@ = allocate_memory_size 1024
    for 31@ = 97 to 99
        0B75: samp get_chat_string 31@ text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
        0AC8: 4@ = allocate_memory_size 260
        0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 4@
        if or
        0C29: $NOT_USED = stristr string1 4@ string2 "has frisked"
        0C18: $NOT_USED = strstr string1 4@ string2 "has frisked"
        then
            if
            0AD4: $NOT_USED = scan_string 4@ format "*%s %s has frisked %s %s." 5@ 6@ 7@ 8@
            then
                chatmsg "%s %s %s %s" -1 5@ 6@ 7@ 8@
            end
        end
    end
end

end    

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end

        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END

        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0

It crashes. 5@ 6@ 7@ 8@ has to be allocated I guess but still, it crashes. (Remember: There is no underscore between first and surname)
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
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 1024
    0AC8: 1@ = allocate_memory_size 1024
    for 31@ = 97 to 99
        0B75: samp get_chat_string 31@ text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
        0AC8: 4@ = allocate_memory_size 260
        0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 4@
        if 
        0C29: 5@ = stristr string1 4@ string2 "has frisked"
        then
            chatmsg "Text was Found!!!" -1 
        end
    end
end

end    

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end

        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END

        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0
 

IbraJ

Member
Joined
May 14, 2020
Messages
13
Reaction score
1
Location
None
@Parazitas - I mean I want to get "Ali Baba" from frisked roleplay line and store it into a variable. The script you created detects only. Thank you for your help but I need to get "Ali Baba" from frisked roleplay line (remember, it cannot be Ali Baba every time as I have to frisk many people)
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
Impatient...
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 1024
    0AC8: 1@ = allocate_memory_size 1024
    for 31@ = 97 to 99
        0B75: samp get_chat_string 31@ text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
        0AC8: 4@ = allocate_memory_size 260
        0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 4@
        if 
        0C29: 5@ = stristr string1 4@ string2 "has frisked"
        then
            5@ += 11
            0C17: 6@ = strlen 5@
            6@ -= 1
            0C24: strncpy destination 5@ source 5@ size 6@
            chatmsg "%s" -1 5@
        end
    end
end

end    

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end

        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END

        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0
 
Status
Not open for further replies.
Top