飞飞世界论坛

标题: 无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:  O% y6 \1 z! x, K
Code:
( W0 ~* o! }! i, l* e' p, v$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");
' {, V% C2 Y% V% c  uecho 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:0 |9 K3 L- I+ P. u% d) l4 l
Code:. u3 T9 r) G" c0 V
$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");# W1 X. \# k; _* h% L8 p( V8 A
echo mssql_num_rows($mssql);# B; ~3 f2 o  P9 u& R4 P! N+ b

* {* l+ v/ A: [# U: y, z! P




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