|
在过去,我已经看到了各种方法检查当前在线玩家人数,但我见过有一个致命的缺陷。根据服务器被关闭(或更确切地说,如果它崩溃)播放器的计数被搞砸了。下面是我在谈论一个:
0 Y3 y+ I* C$ K- ^9 |" J代码:
, q5 ^$ p+ h. a: A/ N
) D0 z7 N6 Y- f0 j( r$mssql = mssql_query("SELECT * FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE isuse='J'");
5 x5 i2 m3 L d' ?; ]echo mssql_num_rows($mssql);0 \* l, x. u W3 L3 m; ~1 v; }
这里有一个更正确的代码,它会自动复位计数,每当世界上的服务器程序打开当前在线:
7 s( [1 K3 g7 c; H |5 [
6 v8 y$ F o- X: x6 I) F代码:# I% h( P9 m' ~5 Z, o
$mssql = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[CHARACTER_TBL] WHERE MultiServer!=0");
* ~7 {5 O* U" p9 y6 D# Vecho mssql_num_rows($mssql);Credits to Sedrika for changing MultiServer=1 to Multiserver!=0
% H/ \7 {5 X, N* d, S* @, h. k4 I* m: |" B
Spikensbror的更快的方法:
) E3 g8 F) [+ O5 G: ]* ^ m邮编:( }% |" |: V( E
! J2 _ i* ~1 o7 Y( Q
$query = mssql_query('SELECT COUNT(*) as [CCU] FROM [CHARACTER_01_DBF].[dbo].[CHARACTER_TBL] WHERE [MultiServer] != 0;');
8 k% q2 Y1 H7 w y& T @" ?6 E$ccu = mssql_fetch_assoc($query);
$ b8 d. s6 B. ]1 g1 W9 ?$ccu = $ccu['CCU'];6 r, H6 I, O( h3 I) r, }+ s% H
% x# c$ ^" j$ I; D; M# O3 ` n" ]! k2 v8 T( {# p% Z
2 D! X* ?2 b& C* r9 d
4 Y$ _# X& \; O0 i. p$ X |
|