Quote:
Originally Posted by drekes
I use this:
PHP Code:
fnColorPrint(id, const szMsg[], {Float, Sql, Result,_}:...)
{
static iMsgSayText, iMaxPlayers;
if(!iMsgSayText)
iMsgSayText = get_user_msgid("SayText");
if(!iMaxPlayers)
iMaxPlayers = get_maxplayers();
static Buffer[190], Buffer2[192], iPlayer
formatex(Buffer2, charsmax(Buffer2), "^x04[%s] ^x01%s", g_szPrefix, szMsg);
vformat(Buffer, charsmax(Buffer), Buffer2, 3);
if(!iPlayer)
{
while(iPlayer <= iMaxPlayers)
{
if(is_user_connected(++iPlayer))
break;
}
}
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_ALL, iMsgSayText, _, iPlayer);
write_byte(iPlayer);
write_string(Buffer);
message_end();
}
|
That could produce false results when printing to 1 player for the first time it is called.
For all the times after the first call, it could cause an error where the player is not connected.
Code:
fnColorPrint(id, const szMsg[], {Float, Sql, Result,_}:...)
{
static iMsgSayText, iMaxPlayers;
if(!iMsgSayText)
iMsgSayText = get_user_msgid("SayText");
if(!iMaxPlayers)
iMaxPlayers = get_maxplayers();
static Buffer[190], Buffer2[192]
formatex(Buffer2, charsmax(Buffer2), "^x04[%s] ^x01%s", g_szPrefix, szMsg);
vformat(Buffer, charsmax(Buffer), Buffer2, 3);
new iPlayer = id;
if(!iPlayer)
{
while(iPlayer <= iMaxPlayers)
{
if(is_user_connected(++iPlayer))
break;
}
}
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_ALL, iMsgSayText, _, iPlayer);
write_byte(iPlayer);
write_string(Buffer);
message_end();
}
__________________