[LUA] Getting chat line full colours

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Hello people, what I am trying to do is get a literal copy of a line in the chat and it's not working. What I mean by "it's not working" is that it doesn't get all the colour. Let's say you have multiple colours from the server in one chat line, the line will not get copied accordingly. An example can be seen below:
1672334356674.png
The first line is the original server line and the second line is what I tried to copy.
I tried using
text, prefix, color, pcolor = sampGetChatString(99) but I also tried using the function onReceiveRpc(id, bs). Neither of those worked. What should I do?
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
use samp events function OnServerMessage
1672339123540.png
That still doesn't work. This is what I did:

local events = require("lib.samp.events")
function events.onServerMessage(color, text)
sampAddChatMessage(text, -1)
end

I even tried instead of -1 to put color but it shows pink
1672339216553.png
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
456
Solutions
9
Reaction score
166
Location
Poland
Press 1 - random text generator
Press 2 - get text color to ini
PHP:
{$CLEO .cs}
{$USE bitwise}
0000:

WHILE TRUE
WAIT 0

IF 0ADC:   test_cheat "1" 
THEN
    // RANDOM TEXT GENERATOR
    0209: 0@ = random_int_in_ranges 0 3
    IF 0@ == 0
    THEN
        0AC8: 1@ = allocate_memory_size 1024
        0AD3: 1@ = format "{FFFFFF}Ad by GeorgeGTG[HA][605] {00FF00}(phone: 98639): {00FF00}Vand Buffalo {FFFFFF}VIP, 110 d 235 km 2x hidd. (1/3)"     
        0AB1: @Chatmsg 3 SampVersionID 3 text 1@ color -1
    ELSE
        IF 0@ == 1
        THEN
            0AC8: 2@ = allocate_memory_size 1024
            0AD3: 2@ = format "{00FF00}Ad by GeorgeGTG[HA][605] (phone: 98639){FFFFFF}: {00FF00}Vand Buffalo VIP, {FFFFFF}110 d 235 {00FF00}km 2x hidd. (2/3)" 
            0AB1: @Chatmsg 3 SampVersionID 3 text 2@ color -1
        ELSE
            IF 0@ == 2
            THEN
                0AC8: 3@ = allocate_memory_size 1024
                0AD3: 3@ = format "{FFFFFF}Ad by GeorgeGTG[HA][605] (phone: 98639): Vand Buffalo {00FF00}VIP, 110 d 235 km 2x hidd. (3/3)" 
                0AB1: @Chatmsg 3 SampVersionID 3 text 3@ color -1
            END
        END
    END
END

IF 0ADC:   test_cheat "2"
THEN
    // GET TEXT COLOR TO INI
    0AC8: 4@ = allocate_memory_size 1024
    0AC8: 5@ = allocate_memory_size 1024
    0AB1: @getChatString 2 SampVersionID 3 ChatID 99 _Returned: Text 4@ PrefixText 5@ Color 6@ PrefixColor 7@    
    0AD1: "%s" 1000 4@
    IF 0AAB:   does_file_exist "Script.ini"
    THEN
        8A9A: 20@ = openfile "CLEO\Script.ini" mode "at" // IF and SET    
        0AD9: write_text "%s %c" in_file 20@ 4@ 0xA // 0xA - NEW LINE
        0AD9: write_text "%c" in_file 20@ 0xA // 0xA - NEW LINE         
        0A9B: closefile 20@
    END                   
END

END
0A93: terminate_this_custom_script
 

Attachments

  • Script.zip
    8.7 KB · Views: 4

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Press 1 - random text generator
Press 2 - get text color to ini
PHP:
{$CLEO .cs}
{$USE bitwise}
0000:

WHILE TRUE
WAIT 0

IF 0ADC:   test_cheat "1"
THEN
    // RANDOM TEXT GENERATOR
    0209: 0@ = random_int_in_ranges 0 3
    IF 0@ == 0
    THEN
        0AC8: 1@ = allocate_memory_size 1024
        0AD3: 1@ = format "{FFFFFF}Ad by GeorgeGTG[HA][605] {00FF00}(phone: 98639): {00FF00}Vand Buffalo {FFFFFF}VIP, 110 d 235 km 2x hidd. (1/3)"    
        0AB1: @Chatmsg 3 SampVersionID 3 text 1@ color -1
    ELSE
        IF 0@ == 1
        THEN
            0AC8: 2@ = allocate_memory_size 1024
            0AD3: 2@ = format "{00FF00}Ad by GeorgeGTG[HA][605] (phone: 98639){FFFFFF}: {00FF00}Vand Buffalo VIP, {FFFFFF}110 d 235 {00FF00}km 2x hidd. (2/3)"
            0AB1: @Chatmsg 3 SampVersionID 3 text 2@ color -1
        ELSE
            IF 0@ == 2
            THEN
                0AC8: 3@ = allocate_memory_size 1024
                0AD3: 3@ = format "{FFFFFF}Ad by GeorgeGTG[HA][605] (phone: 98639): Vand Buffalo {00FF00}VIP, 110 d 235 km 2x hidd. (3/3)"
                0AB1: @Chatmsg 3 SampVersionID 3 text 3@ color -1
            END
        END
    END
END

IF 0ADC:   test_cheat "2"
THEN
    // GET TEXT COLOR TO INI
    0AC8: 4@ = allocate_memory_size 1024
    0AC8: 5@ = allocate_memory_size 1024
    0AB1: @getChatString 2 SampVersionID 3 ChatID 99 _Returned: Text 4@ PrefixText 5@ Color 6@ PrefixColor 7@   
    0AD1: "%s" 1000 4@
    IF 0AAB:   does_file_exist "Script.ini"
    THEN
        8A9A: 20@ = openfile "CLEO\Script.ini" mode "at" // IF and SET   
        0AD9: write_text "%s %c" in_file 20@ 4@ 0xA // 0xA - NEW LINE
        0AD9: write_text "%c" in_file 20@ 0xA // 0xA - NEW LINE        
        0A9B: closefile 20@
    END                  
END

END
0A93: terminate_this_custom_script
Well thank you for the effort but that's not what I asked. I know how to get the color but the rest of the string color doesn't get copied.
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
Well thank you for the effort but that's not what I asked. I know how to get the color but the rest of the string color doesn't get copied.
Each chat text can have different colours from one word to another.

Text colour format is:
{00FF00}
This kind formats you will find when you going to get chat string using memory reading or in chatlog.txt etc..

If you looking a way to get these colours formats from chat someone can help you.
 
Top