View Single Post
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-14-2017 , 20:57   Re: [INC] CromChat
Reply With Quote #3

With this you can't write just "!g" (without coloring), so you can replace "!!" with "!", but this would break phrases with "!!!", better to use something that is rarely used, like {}, so you can use it as "{g}", "{r}", etc. Or with full color naming "{green}", "{red}", etc.
static szMessage[192] this can lead server crash, if string would have 191 length. You should use 192 - 1 (for write_byte) = 191.
You can reserve TeamInfos for TR, CT and SPECTATOR on high-slots like 33-35 or 61-63 or 49-51, etc.
PHP Code:
            message_begin(MSG_ONE_UNRELIABLECC_MSG_SAYTEXT_iPlayer)
            
write_byte(iPlayer)
            
write_string(szMessage)
            
message_end() 
This is unsafe, if message contains something like "#Spec_Help_Text" it would show localized string, if message contains percents or something like "%s" it can show something strange and "%s0" can crash client. So, the correct way is:
PHP Code:
            message_begin(MSG_ONE_UNRELIABLECC_MSG_SAYTEXT_iPlayer)
            
write_byte(iPlayer)
            
write_string("%s")
            
write_string(szMessage)
            
message_end() 
And szMessage size now should be 192 - 1 (for write_byte) - 3 (for write_string("%s")) = 188.
Also why is it unreliable? And also it doesn't support ML for sending to all players.

See my ChatPrint
__________________

Last edited by PRoSToTeM@; 03-14-2017 at 21:02.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@