请教server_print的问题
public client_disconnect(id)
{
if(!id || is_user_bot(id) || !(CAF_DISCONNECT & get_pcvar_num(g_cvarMode)))
return
new szUserName;
get_user_name(id, szUserName, 31);
new iPlayers, iNum, i;
get_players(iPlayers, iNum, "c"); // skip_bots
new bool:bSound = get_pcvar_num(g_cvarSound) == 1
new x
new szMessage
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行``
回复: 请教server_print的问题
你把 server_print 放在 for(i=0; i<iNum; i++) 循环中,当然会打出很多个啦回复: 请教server_print的问题
哇 疏忽了!!忘了server_print是给控制台的消息,我还当给每个客户端一个呢...感谢提醒啊!!! 我猪头了 哈哈
另外那个帖子也很感谢你的回答~~~~
页:
[1]