|
在过去,我已经看到了各种方法检查当前在线玩家人数,但我见过有一个致命的缺陷。根据服务器被关闭(或更确切地说,如果它崩溃)播放器的计数被搞砸了。下面是我在谈论一个: ! d9 F9 j$ a' V2 v% O5 W
代码:8 g$ o' @" W0 {2 x4 G3 {
2 |) v6 N" y! _# C+ S) m; K
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");
' q+ `! k( M" y0 Lecho mssql_num_rows($mssql);
$ I0 G7 N! `- w0 P2 W这里有一个更正确的代码,它会自动复位计数,每当世界上的服务器程序打开当前在线:
: G/ n, c" v; s6 {* {- K
6 d }5 C F8 \, l& R代码:
4 a5 E2 ~! q4 f/ j- p$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer!=0");
3 m3 x3 e7 N0 h: z! Cecho mssql_num_rows($mssql);Credits to Sedrika for changing MultiServer=1 to Multiserver!=0
+ P! m7 j+ z+ T6 ]+ g; E' e: n D9 I' _3 }% v B5 I% S
Spikensbror的更快的方法: ; s3 `, [# z, b6 p, H3 q
邮编:
1 ^( f" x7 E, w/ Z7 Q
( V% ?$ ~3 e+ {6 r$query = mssql_query('SELECT COUNT(*) as [CCU] FROM [CHARACTER_01_DBF].[dbo].[CHARACTER_TBL] WHERE [MultiServer] != 0;');! ]% z% T. I) y
$ccu = mssql_fetch_assoc($query);
5 r7 N9 w: I7 j6 k$ccu = $ccu['CCU'];0 Z7 ~3 }9 ?, w8 i: z9 }6 a0 _; H
: q P6 A# [' P8 s2 B7 Q: m3 j/ H
0 l) i. ~, v' z4 I x* ~* L& k& ~# G! ?, I1 N0 c
" g) `7 ]/ L8 S& t& _' Q
|
|