标题: 无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:* [ s1 ^6 k9 a7 V9 u
Code:' F, E" E& U1 \! d% ~( i! L
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'"); . X; Z" R d! G: O# P3 f: techo 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: " W% g% |$ w" J( C3 u6 ^Code: 6 Y" R" b: t& d4 R, T$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'"); ( \( A, H& R8 M0 }4 r: o8 becho mssql_num_rows($mssql);# j1 F6 S5 u6 j2 n9 K: Z9 q2 W0 w