AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Question about colorchat (https://forums.alliedmods.net/showthread.php?t=282401)

pillowCloud 05-05-2016 22:02

Question about colorchat
 
A nooby question:

I'm using this colorchat stock:
PHP Code:

stock ColorChat( const client, const string[], any:... )
{
    new 
msg191 ], players32 ], count 1;
    static 
lenlen formatexmsgcharsmaxmsg ), "^4[^1 MyClan ^4]^1 " );
    
vformatmsglen ], charsmaxmsg ) - lenstring);
    
    if( 
client )  players] = client;
    else    
get_playersplayers,count,"ch" );
    
    for ( new 
0counti++ )
    {
        if( 
is_user_connectedplayers] ) )
        {
            
message_beginMSG_ONE_UNRELIABLEget_user_msgid"SayText" ), _players] );
            
write_byteplayers] );
            
write_stringmsg );
            
message_end( );
        }
    }
    return 
PLUGIN_HANDLED;


and when I type something like this:
PHP Code:

ColorChat(0"^4%s blablabla"Example); 

The connection of: ^4%s is making a long space between the prefix and the mentioned variable.

How can I prevent it?

Thanks in advance :wink:

EFFx 05-05-2016 22:33

Re: Question about colorchat
 
Try this format:

PHP Code:

stock ChatColor(const id, const input[], any:...) 
{
    new 
count 1players32 ]
    static 
msg191 ]
    
vformatmsg190input)
    
format(msg,charsmax(msg),"^4[^1 MyClan ^4]^1: %s",msg)
   
    
replace_allmsg190"!g""^4" )
    
replace_allmsg190"!y""^1" )
    
replace_allmsg190"!t""^3" )

   
    if(
idplayers] = id; else get_playersplayerscount"ch" )
    {
        for(new 
0counti++)
        {
            if( 
is_user_connectedplayers] ) )
            {
                
message_beginMSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players] )  
                
write_byteplayers] )
                
write_stringmsg )
                
message_end( )
            }
        }
    }


^4, ^3 and ^1 too i dont know, add a space i think with E, A and others characters but i dont remember now...
This new stock is the same of your but i recommend to use him, i like :D

OciXCrom 05-06-2016 08:28

Re: Question about colorchat
 
PHP Code:

static lenlen formatexmsgcharsmaxmsg ), "^4[^1 MyClan ^4]^1 " ); 

Simply remove the space between ^1 and ".

pillowCloud 05-06-2016 09:34

Re: Question about colorchat
 
Quote:

Originally Posted by EFFx (Post 2417068)
Try this format:

PHP Code:

stock ChatColor(const id, const input[], any:...) 
{
    new 
count 1players32 ]
    static 
msg191 ]
    
vformatmsg190input)
    
format(msg,charsmax(msg),"^4[^1 MyClan ^4]^1: %s",msg)
   
    
replace_allmsg190"!g""^4" )
    
replace_allmsg190"!y""^1" )
    
replace_allmsg190"!t""^3" )

   
    if(
idplayers] = id; else get_playersplayerscount"ch" )
    {
        for(new 
0counti++)
        {
            if( 
is_user_connectedplayers] ) )
            {
                
message_beginMSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players] )  
                
write_byteplayers] )
                
write_stringmsg )
                
message_end( )
            }
        }
    }


^4, ^3 and ^1 too i dont know, add a space i think with E, A and others characters but i dont remember now...
This new stock is the same of your but i recommend to use him, i like :D

Thank you very much!!

Quote:

Originally Posted by OciXCrom (Post 2417134)
PHP Code:

static lenlen formatexmsgcharsmaxmsg ), "^4[^1 MyClan ^4]^1 " ); 

Simply remove the space between ^1 and ".

omg.. this shows me how dumb I am :oops:
Thanks alot!


All times are GMT -4. The time now is 18:32.

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