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

CS Color Chat Function Updated:[01/26/2007]


Post New Thread Reply   
 
Thread Tools Display Modes
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 01-25-2007 , 05:08   Re: CS Color Chat Function
Reply With Quote #21

Thnx for this tut. But I coudnt get the correct color to work with
Quote:
message_begin(MSG_ALL, TeamInfo)
but after changing to
Quote:
message_begin(MSG_ONE, TeamInfo, _, id)
It worked. But I didnt try it with the id = 0 though.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 01-25-2007 at 13:35.
Cheap_Suit is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-25-2007 , 13:21   Re: CS Color Chat Function
Reply With Quote #22

Let me see your code.

Are you doing it like this? To send a message to all clients?

Code:
message_begin(MSG_ALL, TeamInfo); write_byte(0); write_string("^x04Message"); message_end
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 01-25-2007 at 13:24.
teame06 is offline
Send a message via AIM to teame06
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 01-25-2007 , 13:33   Re: CS Color Chat Function
Reply With Quote #23

I just took out the part where it sends to all players.

Code:
enum Color {     YELLOW = 1,     GREEN,              TEAM_COLOR,          GREY,        RED,        BLUE, } new TERRORIST[] = "TERRORIST" new CT[]     = "CT" new NOTHING[]     = "" new SPEC[]     = "SPECTATOR" public color_chat(id, Color:type, const msg[], {Float, Sql, Result, _}:...) {     static message[STR_L]     switch(type)     {         case YELLOW:     message[0] = 0x01         case GREEN:    message[0] = 0x04         default:     message[0] = 0x03     }     vformat(message[1], (STR_L-1), msg, 4)     message[192] = '^0'     new team, did     if(id)     {         team = get_user_team(id)         did = color_selection(id, type)         show_message(id, message)         if(did) TeamSelection(id, team)     } } show_message(id, message[]) {     message_begin(MSG_ONE, g_msg_saytext, _, id)     write_byte(id)     write_string(message)     message_end() } Team_Info(id, team[]) {     message_begin(MSG_ONE, g_msg_teaminfo, _, id)     write_byte(id)     write_string(team)     message_end()     return 1 } color_selection(index, Color:Type) {     switch(Type)     {         case RED:     return Team_Info(index, TERRORIST)         case BLUE:     return Team_Info(index, CT)         case GREY:     return Team_Info(index, NOTHING)     }     return 0 } TeamSelection(index, team) {     switch(team)     {         case 0:     Team_Info(index, NOTHING)         case 1:     Team_Info(index, TERRORIST)         case 2:     Team_Info(index, CT)         case 3:     Team_Info(index, SPEC)     } }
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-25-2007 , 14:10   Re: CS Color Chat Function
Reply With Quote #24

Your code is fine if your only going to send it to one player. I thought you were trying to send it to all clients and it wasn't working
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 01-25-2007 , 20:01   Re: CS Color Chat Function
Reply With Quote #25

I see. You might want to update your code because it will only work if the id is 0.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Ryu2877
Member
Join Date: Sep 2006
Location: China
Old 01-26-2007 , 03:01   Re: CS Color Chat Function
Reply With Quote #26

This is interesting & I had made a "stock" for show chat message in almost all my plugins before. Of course, the "stock" only show color through manage "^x03" flag yet & if has not any ct or te it will show gray color replace the team-color.

Code:
////////////////////////////// color_saytext ////////////////////////////////////////////
/*
color_by_team = 1  use TE's team-color(red)
color_by_team = 2  use CT's team-color(blue)
color_by_team = 3  use SPEC's team-color(gray)
color_by_team = 4  use everyone's team-color(TE use red, CT use blue, SPECTATOR use gray)
through this, you can define red|blue|gray color for ^x03(team-color define)
this is crube method & if has not any ct or te it will show gray replace the team-color
example:
fromat(message, 31, "^x01There are 5 ^x03CT ^x04alive!" 
1th mode:
color_saytext(message, MSG_ALL)
or:color_saytext(message, MSG_ALL, _, 3)
will print:[yellow]There are 5 [gray]CT [green]alive!
2th mode:
color_saytext(message, MSG_ALL, id)//let's say id is a te
or:color_saytext(message, MSG_ALL, _, 1)
will print:[yellow]There are 5 [red]CT [green]alive!
3th mode:
color_saytext(message, MSG_ALL, _, 3)
or:color_saytext(message, MSG_ALL, id)//let's say id is a spectator
will print:[yellow]There are 5 [gray]CT [green]alive!
4th mode:
color_saytext(message, MSG_ALL, id)//let's say id is a ct
or:color_saytext(message, MSG_ALL, _, 2)
will print:[yellow]There are 5 [blue]CT [green]alive!
5th mode:
color_saytext(message, MSG_ONE, id, 2)//id is te or ct...
will print:[yellow]There are 5 [blue]CT [green]alive!
....etc
 
new iSayTextMsgID
public_init()
{
 ......
 iSayTextMsgID = get_user_msgid("SayText")
}
*/
stock color_saytext(message[], dest, id = 0, color_by_team = 0 )
{
 if ( (dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE ) && !id )
  return 0
 new pList[32],pNum,i,color
 if ( color_by_team > 3 )//by current definiens, affirm MSG_ALL
 {
  get_players(pList, pNum)
  for ( i=0; i<pNum; i++ )
  {
   color = pList[i]
   message_begin(MSG_ONE, iSayTextMsgID, {0,0,0}, color)
   write_byte(color)
   write_string(message)
   message_end()
  }
  return 1
 }
 if ( color_by_team && color_by_team < 3 )//if use te or ct's team-color
 {
  new param
  get_players(pList, pNum)
  for ( i=0; i<pNum; i++ )
  {
   param = pList[i]
   if ( get_user_team(param) == color_by_team )
   {
    color = param
    break
   }
  }
 }
 if ( !color )//if cannot find any player by team or not const id, use gray color
  color = (color_by_team == 3 || !id )?33:id
 message_begin(dest, iSayTextMsgID, {0,0,0}, (dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE)?id: 0)
 write_byte(color)
 write_string(message)
 return message_end()
}
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	1146
Size:	23.9 KB
ID:	13484   Click image for larger version

Name:	2.jpg
Views:	1252
Size:	76.9 KB
ID:	13485  

Last edited by Ryu2877; 01-26-2007 at 03:12.
Ryu2877 is offline
jopmako
Senior Member
Join Date: Jul 2006
Location: QQ:331537639
Old 01-26-2007 , 05:10   Re: CS Color Chat Function
Reply With Quote #27

Hi, Ryu2877
Have you try use your code send to all player (30 online players)
Code:
 if ( color_by_team > 3 )//by current definiens, affirm MSG_ALL
 {
  get_players(pList, pNum)
  for ( i=0; i<pNum; i++ )
  {
   color = pList[i]
   message_begin(MSG_ONE, iSayTextMsgID, {0,0,0}, color)
   write_byte(color)
   write_string(message)
   message_end()
  }
  return 1
 }
See what happen?

And something you are right,
color = any not team(ct/t) number can be gray color text.
__________________
QQ31537639
jopmako is offline
Send a message via MSN to jopmako
Ryu2877
Member
Join Date: Sep 2006
Location: China
Old 01-26-2007 , 08:01   Re: CS Color Chat Function
Reply With Quote #28

glad to see you, jokmako!

I knows huge text message will crash server, and the above "stock" had passed the test with 32 bots in my plugins's testing server before. But I hasn't test it in true net-server with full 32 players. I thinks it must been the same between "bots" & "players" in this case. Maybe I mistake, and I will test it with full "real players" in any chance. Thank you for the advise.
Ryu2877 is offline
jopmako
Senior Member
Join Date: Jul 2006
Location: QQ:331537639
Old 01-26-2007 , 08:58   Re: CS Color Chat Function
Reply With Quote #29

Not the huge text msg got the problem, it is MSG_ALL and MSG_ONE.
The text msg is not import, so use MSG_ONE_UNRELIABLE and MSG_BROADCAST instead it.

Any MSG was sent using MSG_ALL or MSG_ONE
to (10+) players at the same time - drop player or crash server.
But HL engine should not, any ideal?
__________________
QQ31537639
jopmako is offline
Send a message via MSN to jopmako
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-26-2007 , 12:44   Re: CS Color Chat Function
Reply With Quote #30

@ jopmako & Ryu2877

Long Text Message will cause the server too crash. The limit is 191 characters. Anything over that will crash the server. The will crash happen but it won't shut it won't exit or shutdown the program itself. No one can enter your server at all.

If you don't manually restart with what program you have or don't have an auto restart program. Then your server won't start up again.


@ jopmako

I sent messages to clients (20 players) using MSG_ONE at the same time. I have had no problems with it.


@ Cheap_Suit

The color was working fine except for red/grey/blue/teamcolor for id != 0. I just uploaded a fix for it. It need the TeamInfo to send it as MSG_ONE when it a single client and MSG_ALL when sending it to everybody.
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 01-26-2007 at 12:49.
teame06 is offline
Send a message via AIM to teame06
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 16:54.


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