AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [color chat] (https://forums.alliedmods.net/showthread.php?t=110637)

K.K.Lv 12-01-2009 10:40

[color chat]
 
Hi everyone, I just make another code can show color chat, I test it ,and work well, so I post it and hope some one can point out the bug if there is(are) bug(s), or if you think this code is so bad, please give me some good code than this ! because I don't think this topic and this topic is so good !

Note that: I come here for learning , so don't say anything hurt some one ! you can post your opinion here !

Thx all !!!:mrgreen:

PHP Code:

/*
*
* @param  id -- set 0 to all player on server, else to one player who index equal id.
* @param  cid -- get the color index, don't set it equal 0.
* @param  color -- set the color (0 -- don't change; 1 -- Red color; 2 -- Blue color; 3 -- Grey color)
* @param  message -- cons message.
*
*/
public print_color(idcidcolor, const message[], any:...)
{
 new 
msg[192]
 
vformat(msgcharsmax(msg), message5)
 
/*      //if you want to use ML, enable
 replace_all(msg, charsmax(msg), "!g", "^x04")
 replace_all(msg, charsmax(msg), "!n", "^x01")
 replace_all(msg, charsmax(msg), "!t", "^x03")*/
 
new param
 
if (!cid) return
 else 
param cid
 
new team[32]
 
get_user_team(paramteam31)
 switch (
color)
 {
  case 
0msg_teaminfo(paramteam)
  case 
1msg_teaminfo(param"TERRORIST")
  case 
2msg_teaminfo(param"CT")
  case 
3msg_teaminfo(param"SPECTATOR")
 }
 if (
idmsg_saytext(idparammsg)
 else 
msg_saytext(0parammsg)
 if (
color != 0msg_teaminfo(paramteam)
}
msg_saytext(idcidmsg[])
{
 
message_begin(id?MSG_ONE:MSG_ALLget_user_msgid("SayText"), {0,0,0}, id)
 
write_byte(cid)
 
write_string(msg)
 
message_end()
}
msg_teaminfo(idteam[])
{
 
message_begin(MSG_ONEget_user_msgid("TeamInfo"), {0,0,0}, id)
 
write_byte(id)
 
write_string(team)
 
message_end()


color settings:

0 -- Don't change
1 -- Red color
2 -- Blue color
3 -- Grey color

Exolent[jNr] 12-01-2009 11:11

Re: [color chat]
 
Why did you not add green or current-team-color support?

Cuchii 12-01-2009 12:00

Re: [color chat]
 
Quote:

Originally Posted by K.K.Lv (Post 1004016)
Hi everyone, I just make another code can show color chat, I test it ,and work well, so I post it and hope some one can point out the bug if there is(are) bug(s), or if you think this code is so bad, please give me some good code than this ! because I don't think this topic and this topic is so good !

Note that: I come here for learning , so don't say anything hurt some one ! you can post your opinion here !

Thx all !!!:mrgreen:

PHP Code:

public print_color(idcidcolormessage[])
{
 new 
team[32]
 
get_user_team(cidteam31)
 switch (
color)
 {
  case 
0msg_teaminfo(cidteam)
  case 
1msg_teaminfo(cid"TERRORIST")
  case 
2msg_teaminfo(cid"CT")
  case 
3msg_teaminfo(cid"SPECTATOR")
 }
 if (
idmsg_saytext(idcidmessage)
 else 
msg_saytext(0cidmessage)
 if (
color != 0msg_teaminfo(cidteam)
}
msg_saytext(idcidmsg[])
{
 
message_begin(id?MSG_ONE:MSG_ALLget_user_msgid("SayText"), {0,0,0}, id)
 
write_byte(cid)
 
write_string(msg)
 
message_end()
}
msg_teaminfo(idteam[])
{
 
message_begin(MSG_ONEget_user_msgid("TeamInfo"), {0,0,0}, id)
 
write_byte(id)
 
write_string(team)
 
message_end()


color settings:

0 -- Don't change
1 -- Red color
2 -- Blue color
3 -- Grey color

PHP Code:

stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
replace_all(msg190"!team2""^0"// Team2 Color
    
    
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();
            }
        }
    }


This was done by kiske...

I just brought it to this thread :D

K.K.Lv 12-02-2009 00:02

Re: [color chat]
 
@Exolent[jNr]
needn't add green and teamcolor,
try this
PHP Code:

print_color(idid0"^x04green ^x01normal ^x03teamcolor"

will show "green normal teamcolor or teamcolor or teamcolor "

@Cuchii
I ask you a question,
can you send a grey(red or blue) color for all player ?
I have seen your code, I think the answer is not !

and thx all !
the code has updated !

PHP Code:

print_color(idcidcolor, const msg[], any:...) 


matsi 12-02-2009 10:46

Re: [color chat]
 
Quote:

Originally Posted by Cuchii (Post 1004085)
PHP Code:

stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
replace_all(msg190"!team2""^0"// Team2 Color
    
    
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();
            }
        }
    }


This was done by kiske...

I just brought it to this thread :D

Firs time i saw that stock was in this post. :grrr:

Alucard^ 12-02-2009 23:43

Re: [color chat]
 
Quote:

Originally Posted by K.K.Lv (Post 1004687)
@Exolent[jNr]
needn't add green and teamcolor,
try this
PHP Code:

print_color(idid0"^x04green ^x01normal ^x03teamcolor"

will show "green normal teamcolor or teamcolor or teamcolor "

@Cuchii
I ask you a question,
can you send a grey(red or blue) color for all player ?
I have seen your code, I think the answer is not !

and thx all !
the code has updated !

PHP Code:

print_color(idcidcolor, const msg[], any:...) 


Kiske didn't created that stock, he only posted it.

vivek 12-18-2009 12:51

Re: [color chat]
 
for grey color wht should i do

K.K.Lv 12-18-2009 22:15

Re: [color chat]
 
@vivek
PHP Code:

print_color(idid3"^x03grey" 


will print grey

worldspawn 12-19-2009 05:05

Re: [color chat]
 
can you add green color?
and default of course

Arkshine 12-19-2009 09:03

Re: [color chat]
 
Read the first post.


All times are GMT -4. The time now is 09:42.

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