CLEO Help SA-MP: Get Nickname from the last line chat.

CLEO related

Escalasion

Member
Joined
Sep 20, 2024
Messages
20
Reaction score
0
Can someone please help me with a script? How can I make the script copy the name of a person who appears in the chat from a message of the type "NR" and store it in a variable? Example: "NR [PW]Escalasion: ad.", where it should take my name or that of any other person when such text appears on the last line (99) of the chat. What am I doing wrong, because this simply does not work for me in any way...
 

Attachments

  • Get Nickname from last line chat type NR.txt
    675 bytes · Views: 2

GoodMan

Active member
Joined
Jun 4, 2014
Messages
152
Reaction score
0
PHP:
i don't know how to get the full name of the player if it contains above 16 characters.... because 2@s is for 8 by strings and 2@v is for 16 byte strings, therefore i use 2@v to store the nickname, however if it contains above 16 chars these will be cut out of the string.

{$CLEO .CS}

0000: NOP



CONST

    MAX_PLAYERS = 1000

END



0AC8: 0@ = allocate_memory_size 261   



WHILE TRUE

    WAIT 0

    0B75: samp get_chat_string 99 text_to 0@ prefix_to -1 color_to -1 prefix_color_to -1

    0C17: 4@ = strlen 0@

    IF 0019: 4@ > 0 // check if string is empty

    THEN

        IF 0AD4: 1@ = scan_string 0@ format "NR %s:" 2@v

        THEN

           FOR 3@ = 0 TO MAX_PLAYERS STEP 1

               0B36: samp 2@ = get_player_nickname 0@

               IF 0C14: strcmp string1 2@ string2 2@v

               THEN

                    // do something to the player who sent the message

               END

           END

           printf "%s" 4000 2@v

        END

    END

END

004E: end_thread
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,320
Solutions
7
Reaction score
938
Location
Lithuania
Can someone please help me with a script? How can I make the script copy the name of a person who appears in the chat from a message of the type "NR" and store it in a variable? Example: "NR [PW]Escalasion: ad.", where it should take my name or that of any other person when such text appears on the last line (99) of the chat. What am I doing wrong, because this simply does not work for me in any way...
NOTE:
This code was made using google search engine and NOTEPAD++
I do not have any cleo related stuff.
By adding digits you can specify how long name or surname you wanna extract!

Example 1, suranem will be 3 letters long:
PHP:
0AD4: $NOT_USED = 2@v "%[^_]_%3[^_]" 10@v 20@v  //10@v = first name, 20@v = last name

Example 2, name will be 4 letters long:
PHP:
0AD4: $NOT_USED = 2@v "%4[^_]_%[^_]" 10@v 20@v  //10@v = first name, 20@v = last name

Also i would recommend lowercase all text because there's no human which always write text in uppercase...

Code:

PHP:
{$CLEO .CS}

0000: NOP

REPEAT
WAIT 0
UNTIL 0AFA: SAMP_IS_READY

0A8C: write_memory 0x8A5A80 size 4 value 0x7FFFFFFF virtual_protect 1 // Increase the stream memory limit

WHILE TRUE
    WAIT 0
  
IF 0B61: samp is_local_player_spawned
THEN
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 2@ = allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
  
    0C17: 4@ = strlen 0@

    IF 0019: 4@ > 0 // check if string is empty
    THEN
        IF 0AD4: $NOT_USED = scan_string 0@ format "NR %s:" 2@v
        THEN
            0AD4: $NOT_USED = 2@v "%[^_]_%[^_]" 10@v 20@v  //10@v = first name, 20@v = last name
            printf "Received Name: %s Surname: %s" 5000 10@v 20@v
            // do something to the player who sent the message
        END
    END
    0AC9: free_allocated_memory 0@
    0AC9: free_allocated_memory 1@
END

END
 

Escalasion

Member
Joined
Sep 20, 2024
Messages
20
Reaction score
0
NOTE:
This code was made using google search engine and NOTEPAD++
I do not have any cleo related stuff.
By adding digits you can specify how long name or surname you wanna extract!

Example 1, suranem will be 3 letters long:
PHP:
0AD4: $NOT_USED = 2@v "%[^_]_%3[^_]" 10@v 20@v  //10@v = first name, 20@v = last name

Example 2, name will be 4 letters long:
PHP:
0AD4: $NOT_USED = 2@v "%4[^_]_%[^_]" 10@v 20@v  //10@v = first name, 20@v = last name

Also i would recommend lowercase all text because there's no human which always write text in uppercase...

Code:

PHP:
{$CLEO .CS}

0000: NOP

REPEAT
WAIT 0
UNTIL 0AFA: SAMP_IS_READY

0A8C: write_memory 0x8A5A80 size 4 value 0x7FFFFFFF virtual_protect 1 // Increase the stream memory limit

WHILE TRUE
    WAIT 0
 
IF 0B61: samp is_local_player_spawned
THEN
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 2@ = allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
 
    0C17: 4@ = strlen 0@

    IF 0019: 4@ > 0 // check if string is empty
    THEN
        IF 0AD4: $NOT_USED = scan_string 0@ format "NR %s:" 2@v
        THEN
            0AD4: $NOT_USED = 2@v "%[^_]_%[^_]" 10@v 20@v  //10@v = first name, 20@v = last name
            printf "Received Name: %s Surname: %s" 5000 10@v 20@v
            // do something to the player who sent the message
        END
    END
    0AC9: free_allocated_memory 0@
    0AC9: free_allocated_memory 1@
END

END
It works, but how can I make it save the correct and complete name? As "v" variables hold up to 16 characters, and I need it to hold up to 24 characters in total for any type of long name.
 
Top