标题: 无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: # ~& X+ n: P: V6 k; zCode: 4 E4 y1 v( d; X/ f" q7 H- K$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'"); % ~8 X# F# K9 Q9 qecho 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:* h/ |- p% W0 F& K9 a' e# O
Code:" T8 V+ J! I7 ~5 _. | T* O
$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'"); , t$ I* q7 W3 H4 _9 T4 ]0 z0 wecho mssql_num_rows($mssql); , K: Z2 N3 s9 ~$ Z" p9 M D* a7 u! C% J1 _2 T# X