|
|
在过去,我已经看到了各种方法检查当前在线玩家人数,但我见过有一个致命的缺陷。根据服务器被关闭(或更确切地说,如果它崩溃)播放器的计数被搞砸了。下面是我在谈论一个: 7 c* {, t: w+ Z
代码:
1 O+ |" {5 B% r. g! |5 f. ^6 _% e' Z4 T) q& B% ] q
$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");6 K# w2 z; }3 S2 g% I
echo mssql_num_rows($mssql);1 d* p# |( Z& m6 @: l U1 @* T. T3 M D
这里有一个更正确的代码,它会自动复位计数,每当世界上的服务器程序打开当前在线:
4 n) `: f3 B+ g1 d% u* V
" L* ~ z5 k8 M2 M3 a5 L代码:
6 m8 T) N$ a3 _8 V( a* W& ~$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer!=0");: A) O n0 y6 M& T' c
echo mssql_num_rows($mssql);Credits to Sedrika for changing MultiServer=1 to Multiserver!=0
+ L+ l. X1 N2 Y! y; {! A1 H" O( ]; [0 W: N/ ]
Spikensbror的更快的方法:
0 d9 G+ M6 U5 X4 n% M邮编:
6 M5 e2 f7 v3 u7 \1 u6 A1 Z
; h4 ]3 O4 k0 r+ \0 m$query = mssql_query('SELECT COUNT(*) as [CCU] FROM [CHARACTER_01_DBF].[dbo].[CHARACTER_TBL] WHERE [MultiServer] != 0;');' Q2 z7 M7 @5 d$ a/ E* y
$ccu = mssql_fetch_assoc($query);
% a0 V( @" z( c! I5 u7 d( ~" h$ccu = $ccu['CCU'];) r& C8 h/ B. [3 e3 R5 b
+ K. x, r9 H& G% H' I2 D
6 x s" L: w# ?. @3 q) h, I$ [' U# D- S8 A9 f
- b! Q- l1 S: Q
|
|