标题: 无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: ' q& m" f- S/ d. Q' ?Code:5 a' ~6 W" Z0 ^/ u. n5 D* e# l) U1 {
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");, e0 l6 c( H2 \* I: \1 v8 D
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:9 U0 s8 G8 N$ o8 }
Code: # o* W: w6 x8 \: J" D# a; x" f! s$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");& D3 O* a" O6 ?# ^
echo mssql_num_rows($mssql); * H8 a% ~2 q. g7 X5 A& m : R3 l$ I: E) r7 F1 I1 Q