|
public client_disconnect(id)
{
if(!id || is_user_bot(id) || !(CAF_DISCONNECT & get_pcvar_num(g_cvarMode)))
return
new szUserName[32];
get_user_name(id, szUserName, 31);
new iPlayers[32], iNum, i;
get_players(iPlayers, iNum, "c"); // skip_bots
new bool:bSound = get_pcvar_num(g_cvarSound) == 1
new x
new szMessage[164]
for(i=0; i<iNum; i++)
{
x = iPlayers;
if(!is_user_connected(x)) continue;
if(bSound)
client_cmd(x, "spk %s", g_szSoundFile);
formatex(szMessage, 163, "^x04%s disconnected", szUserName);
console_print(x, szMessage)//Sends a message to a player's console
server_print(szMessage)//Prints a message to the server console
message_begin(MSG_ONE, g_iMsgSayText, _, x);
write_byte(id);
write_string(szMessage);
message_end();
}
} 为什么玩家disconnect的时候控制台会这样打印:
xx disconnected
xx disconnected
xx disconnected
xx disconnected
xx disconnected
xx disconnected
xx disconnected
xx disconnected
xx disconnected
也就是说一个人退出的时候在控制台打出了很多次而不是我期待的1行`` |
|