标题: 无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:. S; j9 L) q5 [! @8 ~/ Q9 f) Y
Code:$ b5 X. ?# H: X: F9 h
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'"); + x* |- w; S- \7 decho 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:4 @% K( \, H: g- R7 w
Code: 0 h! I3 A, h9 L$ g( R0 ^$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");' ~# g9 B! {4 p/ u H& {
echo mssql_num_rows($mssql); 3 y" K% V }" [$ S. d ) `$ y6 O- F4 r1 z3 p2 M6 i