Raised This Month: $32 Target: $400
 8% 

Prefix and Colored Chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 11-21-2013 , 07:53   Prefix and Colored Chat
Reply With Quote #1

How to print default color prefix and red text in same line ?

PHP Code:
print_coloridNORMAL"[AMXX]" );
print_coloridRED"I love ALLIEDMODDERS" ); 
PHP Code:
#if defined _colorchat_included
  #endinput
#endif
#define _colorchat_included

enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

print_color(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    if( !
get_playersnum() ) return;
    
    new 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
            return 
i;
    }

    return -
1;

Debesėlis is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 11-21-2013 , 08:14   Re: Prefix and Colored Chat
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=94960
PHP Code:
print_color(idRED"^1[AMXX]^3 I love ALLIEDMODDERS"); 
DWIGHTpN is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 11-21-2013 , 08:18   Re: Prefix and Colored Chat
Reply With Quote #3

Quote:
Originally Posted by DWIGHTpN View Post
https://forums.alliedmods.net/showthread.php?t=94960
PHP Code:
print_color(idRED"^1[AMXX]^3 I love ALLIEDMODDERS"); 

I love ALLIEDMODDERS - will be red for both team?

Last edited by Debesėlis; 11-21-2013 at 08:18.
Debesėlis is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 11-21-2013 , 08:26   Re: Prefix and Colored Chat
Reply With Quote #4

Quote:
I love ALLIEDMODDERS - will be red for both team?
Yes.
DWIGHTpN is offline
LordOfNothing
BANNED
Join Date: Jul 2013
Old 11-22-2013 , 11:10   Re: Prefix and Colored Chat
Reply With Quote #5

Quote:
^4 to display green, ^1 to display normal color (yellow by default), and ^3 to display the specified color (2nd arg).
LordOfNothing is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 11-22-2013 , 11:36   Re: Prefix and Colored Chat
Reply With Quote #6

Quote:
Originally Posted by Debesėlis View Post
How to print default color prefix and red text in same line ?
Debesėlis is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:47.


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