标题: 无bug在线人数代码 [打印本页] 作者: admin 时间: 2016-1-10 03:42 标题: 无bug在线人数代码 In the past I've seen various ways of checking the current number of online players, but all that I've seen have a fatal flaw. Depending on how the server was turned off (or more specifically, if it crashes) the player count gets messed up. Here's the one I'm talking about:8 q1 \2 m& J4 ]/ l( G9 q: o
Code: 9 F8 M; A& C& O. t, ]$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'"); P$ I& j; R. o4 p6 T/ k: w+ [8 p
echo mssql_num_rows($mssql);Here's a more proper code, which will automatically reset the current online count whenever the world server program is opened:. A% x3 M( F$ j9 }7 [7 G% e
Code: ' [) q: k* {. Z9 j! ]$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'"); & }1 G c8 N7 D; aecho mssql_num_rows($mssql);1 p/ h1 U8 c$ `* z