标题: 无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: & H+ u) B$ U4 bCode: 6 l& g! _0 q& m5 G/ X$ h; r: U$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");4 l! ^# _& H' y" ?; j3 `% x
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: * D" ^: G. |: g1 p) y& nCode: & }/ r6 y- O9 C) E: G$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");& B3 ^5 X) Y, h* M Q) V2 N* @
echo mssql_num_rows($mssql); 5 [8 F v+ |2 Q. F) L# l% a - p6 U, }" U: ], D