AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved client_print_color | It does not work properly (https://forums.alliedmods.net/showthread.php?t=316903)

wilianmaique 06-16-2019 16:36

client_print_color | It does not work properly
 
I'm using it this way, but the color is not changed.


PHP Code:

new prefixchat[20

Register:
PHP Code:

myvar create_cvar("my_prefix""^4[PREFIX]"

Pulling:
PHP Code:

get_pcvar_string(myvarprefixchatcharsmax(prefixchat))
client_print_color(0print_team_default"%s"prefixchat

If I change the color inside the game does not work.

Except if I use this stock

PHP Code:

stock xClientPrintColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4")
    
replace_all(msg190"!y""^1")
    
replace_all(msg190"!t""^3")
    
replace_all(msg190"!t2""^0")
    
    if (
idplayers[0] = id; else get_players(playerscount"ch")

    for (new 
0counti++)
    {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
            
write_byte(players[i])
            
write_string(msg)
            
message_end()
        }
    }


Instead of: ^1 ^2 ^3 etc
Use: !g !t !y

<VeCo> 06-16-2019 16:53

Re: client_print_color | It does not work properly
 
^ is a control character, it's not a literal "^4" but an ASCII character with byte code of 4.
It would be pretty inconvenient for the user to write  into a CVAR.

thEsp 06-16-2019 17:24

Re: client_print_color | It does not work properly
 
PHP Code:

#pragma ctrlchar '\' // Changes escape character 

Or
Quote:

Originally Posted by fysiks (Post 1440905)
You need to escape the escape character.

"^^"


wilianmaique 06-16-2019 17:38

Re: client_print_color | It does not work properly
 
Quote:

Originally Posted by <VeCo> (Post 2655726)
^ is a control character, it's not a literal "^4" but an ASCII character with byte code of 4.
It would be pretty inconvenient for the user to write  into a CVAR.

How do I make the color prefix work by using: client_print_color?

Quote:

Originally Posted by thEsp (Post 2655727)
PHP Code:

#pragma ctrlchar '\' // Changes escape character 

Or

Did not work

<VeCo> 06-17-2019 10:03

Re: client_print_color | It does not work properly
 
Quote:

Originally Posted by wilianmaique (Post 2655728)
How do I make the color prefix work by using: client_print_color

The same way as the stock you've used.
Replace "^^4" with "^4" in prefixchat. That way you can write "^4" in the CVAR and it will be treated as the special character.

Black Rose 06-17-2019 14:00

Re: client_print_color | It does not work properly
 
Or keep it out of the cvar, that is if you always want that color and only want to change the text of the prefix.

PHP Code:

myvar create_cvar("my_prefix""[PREFIX]"

PHP Code:

get_pcvar_string(myvarprefixchatcharsmax(prefixchat))
client_print_color(0print_team_default"^4%s"prefixchat


wilianmaique 06-17-2019 17:46

Re: client_print_color | It does not work properly
 
Quote:

Originally Posted by <VeCo> (Post 2655789)
The same way as the stock you've used.
Replace "^^4" with "^4" in prefixchat. That way you can write "^4" in the CVAR and it will be treated as the special character.

Thanks :) :wink:


All times are GMT -4. The time now is 08:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.