飞飞世界论坛

标题: 无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:
; w  n) h5 o2 L" }5 s' `Code:3 c3 m* N. o+ e# v6 T0 D' ^1 t
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");
9 a. H2 b* h6 f5 O* Lecho 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:
3 c# V  M+ p8 L2 r9 ?Code:
& w+ {4 Z2 H" ^9 v2 f$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");
. T  n! h) E9 ]1 i- }( Eecho mssql_num_rows($mssql);$ U2 C7 s5 Q6 @! b* C( n
0 Q9 m- D  p6 z3 O9 v* A4 a5 h% C





欢迎光临 飞飞世界论坛 (http://www.ffwold.com/) Powered by Discuz! X3.2