File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,13 +72,14 @@ private bool CanRun(AutoCommand command)
7272 }
7373 case Trigger . PlayerCount :
7474
75- if ( command . Compare == GreaterThan )
76- {
77- return MySession . Static ? . Players . GetOnlinePlayerCount ( ) > command . TriggerCount ;
78- }
79- else if ( command . Compare == LessThan )
75+ switch ( command . Compare )
8076 {
81- return MySession . Static ? . Players . GetOnlinePlayerCount ( ) < command . TriggerCount ;
77+ case GreaterThan :
78+ return Utilities . GetOnlinePlayerCount ( ) > command . TriggerCount ;
79+ case LessThan :
80+ return Utilities . GetOnlinePlayerCount ( ) < command . TriggerCount ;
81+ case Equal :
82+ return Math . Abs ( Utilities . GetOnlinePlayerCount ( ) - command . TriggerCount ) < 1 ;
8283 }
8384 break ;
8485
Original file line number Diff line number Diff line change @@ -261,7 +261,7 @@ private IEnumerable VoteCountdown(TimeSpan time)
261261 }
262262 else
263263 {
264- double vr = ( double ) _voteReg . Count / MySession . Static . Players . GetOnlinePlayerCount ( ) ;
264+ double vr = ( double ) _voteReg . Count / Utilities . GetOnlinePlayerCount ( ) ;
265265 if ( vr >= _command . TriggerRatio )
266266 {
267267 Context . Torch . CurrentSession . Managers . GetManager < IChatManagerClient > ( )
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using System . Text ;
5- using System . Threading . Tasks ;
64using Sandbox . Game . Entities ;
75using Sandbox . Game . World ;
86using Sandbox . ModAPI ;
9- using Torch ;
107using VRage . Game . ModAPI ;
118using VRage . ModAPI ;
129using VRage . Utils ;
@@ -99,6 +96,23 @@ public static IMyPlayer GetPlayerByNameOrId(string nameOrPlayerId)
9996 return null ;
10097 }
10198
99+ public static int GetOnlinePlayerCount ( )
100+ {
101+ var result = 0 ;
102+
103+ result = MySession . Static . Players . GetOnlinePlayers ( )
104+ . Count ( x => x . IsRealPlayer && ! string . IsNullOrEmpty ( x . DisplayName ) ) ;
105+
106+ return result ;
107+ }
108+
109+ public static List < MyPlayer > GetOnlinePlayers ( )
110+ {
111+ var result = new List < MyPlayer > ( MySession . Static . Players . GetOnlinePlayers ( )
112+ . Where ( x => x . IsRealPlayer && ! string . IsNullOrEmpty ( x . DisplayName ) ) ) ;
113+ return result ;
114+ }
115+
102116 public static string FormatDataSize ( double size )
103117 {
104118 string p = MyUtils . FormatByteSizePrefix ( ref size ) ;
You can’t perform that action at this time.
0 commit comments