标题: 无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:. Y, y3 I5 T' S( C3 _
Code: F5 j9 H' H/ a" n. i( }
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'"); % E/ f9 T4 s/ u& W0 _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: 8 c5 b6 j. H( J' I7 X3 I3 WCode: . f8 y4 v) ^! r0 ^: {# o/ I& W$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");7 N% O# G# X `: ]8 Q( ?
echo mssql_num_rows($mssql);: Q9 c1 V" \0 ~8 f' Y
0 F' D6 N* m2 X* A