66using CounterStrikeSharp . API . Modules . Commands ;
77using CounterStrikeSharp . API . Modules . Cvars ;
88using CounterStrikeSharp . API . Core . Attributes ;
9+ using CounterStrikeSharp . API . Modules . Utils ;
10+ using CounterStrikeSharp . API . Modules . Admin ;
911
1012namespace NeedSystem ;
1113
@@ -17,7 +19,7 @@ public class NeedSystemBase : BasePlugin, IPluginConfig<BaseConfigs>
1719 private Translator _translator ;
1820
1921 public override string ModuleName => "NeedSystem" ;
20- public override string ModuleVersion => "1.1.5 " ;
22+ public override string ModuleVersion => "1.1.6 " ;
2123 public override string ModuleAuthor => "luca.uy" ;
2224 public override string ModuleDescription => "Allows players to send a message to discord requesting players." ;
2325
@@ -146,7 +148,25 @@ private bool CheckCommandCooldown(out int secondsRemaining)
146148 public int GetNumberOfPlayers ( )
147149 {
148150 var players = Utilities . GetPlayers ( ) ;
149- return players . Count ( p => ! p . IsBot && ! p . IsHLTV ) ;
151+ return players . Where ( p => ! p . IsBot && ! p . IsHLTV && ShouldShowPlayerInList ( p ) ) . Count ( ) ;
152+ }
153+
154+ private bool ShouldShowPlayerInList ( CCSPlayerController player )
155+ {
156+ if ( ! Config . DontCountAdmins || string . IsNullOrEmpty ( Config . AdminBypassFlag ) )
157+ return true ;
158+
159+ try
160+ {
161+ if ( ! AdminManager . PlayerHasPermissions ( player , Config . AdminBypassFlag ) )
162+ return true ;
163+
164+ return player . Team == CsTeam . Terrorist || player . Team == CsTeam . CounterTerrorist ;
165+ }
166+ catch
167+ {
168+ return true ;
169+ }
150170 }
151171
152172 private int ConvertHexToColor ( string hex )
@@ -172,6 +192,7 @@ public void NeedCommand(CCSPlayerController? caller, string clientName)
172192 {
173193 var players = Utilities . GetPlayers ( )
174194 . Where ( p => ! p . IsBot && ! p . IsHLTV && p . Connected == PlayerConnectedState . PlayerConnected )
195+ . Where ( ShouldShowPlayerInList )
175196 . Select ( p => new { p . PlayerName , p . SteamID } )
176197 . ToList ( ) ;
177198
@@ -294,7 +315,7 @@ private async Task SendEmbedToDiscord(object embed)
294315
295316 var payload = new
296317 {
297- content = content ,
318+ content ,
298319 embeds = new [ ] { embed }
299320 } ;
300321
0 commit comments