I have a suggestion to make the SayText message more efficient.
Right now it's being sent as:
PHP Code:
UserMessageBegin( filter, "SayText" );
WRITE_STRING( "hlstriker: Hello ^6Colored ^2Text!" ); // Text being sent
WRITE_BYTE( 1 ); // Use color or not? - 0/1/67 (and 67 indicates server-console chat?)
MessageEnd();
Why is this inefficient?
1) There is no reason the players name should be included in the message.
2) The color codes "^1-9" should be replaced with hexadecimals before sending to the client.
3) The current 2nd argument should not even exist if it's only telling the client to use color or not (or is it to indicate player/server console?).
-----------------------------------------
How can it be improved?
1) Instead of including the players name in the string, let's add another WRITE_BYTE() to send the clients index.
Note: If 0 is sent here, don't add any name when displaying the chat.
2) Before sending the message, the color code characters should be replaced with hexadecimals.
Example: ^1 = \x01, ^2 = \x02, etc..
This will also prevent the color codes from showing in the console.
3) Add another WRITE_BYTE() for the type of chat.
Example:
WRITE_BYTE( 0 ) - Team chat unassigned.
WRITE_BYTE( 1 ) - Team chat spec.
WRITE_BYTE( 2 ) - Team chat blue.
WRITE_BYTE( 3 ) - Team chat red.
WRITE_BYTE( 4 ) - Team chat yellow.
WRITE_BYTE( 5 ) - Team chat green.
WRITE_BYTE( 6 ) - Send chat to everyone.
WRITE_BYTE( 7 ) - Sent from server console.
4) Use hexadecimals for players name color if it isn't already.
-----------------------------------------
The final result:
PHP Code:
UserMessageBegin( filter, "SayText" );
WRITE_BYTE( index ); // Players index sending chat
WRITE_BYTE( type ); // Type of chat (Team/All/From server console).
WRITE_STRING( chat ); // What player typed only! (also replaced color codes to hex)
MessageEnd();