标题: 无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:2 q" o2 K0 c4 K% l' _6 ?% h W
Code: : p# s2 P! b% t$ ^$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'"); 6 H7 q4 o- D! m, ?( k1 S" Pecho 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 O7 o' Y& dCode: % G& a' O( |' H' e$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");( u2 D+ W% Z; ?; p' K( }5 Q4 I
echo mssql_num_rows($mssql); 4 \# T5 }# h3 Z7 z6 y2 W$ L) f5 v+ g: J- S