飞飞世界论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 9409|回复: 0
打印 上一主题 下一主题

无bug在线人数代码

[复制链接]

197

主题

203

帖子

1054

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1054
QQ
跳转到指定楼层
楼主
发表于 2016-1-10 03:42:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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:* h- ~1 s" }: I# i& q2 Y$ y
Code:
7 V. Q: l" P& D$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");8 ?! q* V. U; e: @0 y1 ~; N  q" q% v
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 b" Y( T; W+ k2 A! NCode:
! H# Y4 u# l2 {! A2 Y5 ]2 ?& H6 V7 y$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer='1'");
/ u+ `3 o6 O/ [- t) {echo mssql_num_rows($mssql);
" [) h+ |0 R, L9 B( r' F2 ^' X# n* L) b0 y3 O" V6 T
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|飞飞世界技术论坛  

GMT+8, 2024-12-22 20:56 , Processed in 0.061532 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表