标题: 无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: ^/ k6 W# N# S2 c1 {# w
Code: 1 I# U, w" b* ?$ ~$ |, c$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");' K3 w. y8 l" j( {6 C1 E
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: 1 E8 M- s* r0 O4 ~* P& K0 X1 j1 |. U! }Code:+ g9 X) g2 F4 @
$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'"); . B1 d; Y3 i( H4 l) Recho mssql_num_rows($mssql); ( U# p4 \& @! g % u F& q" n5 S