标题: 无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:3 J4 v5 K* Z' x4 |( w4 a
Code: ; {4 X/ R) [' @9 w! m! g; e$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");, o* [" Z/ f$ y0 U. r5 K
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: ) R$ S) b* f j0 n& l) v0 uCode:4 m2 @* U. l6 a$ ?0 k0 q% C0 l/ z
$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");# Z. \1 ]# I! P) T+ z8 @
echo mssql_num_rows($mssql); b+ m! G4 }8 ]/ U- D. Y( F F2 A. D7 ]. Q- ?& y6 f# ^& v