Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
4 changed files with 6 additions and 31 deletions
|
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
Reports live match state to [simpleadmin-web](../../go/simpleadmin-web) over RCON: the hostname,
|
Reports live match state to [simpleadmin-web](../../go/simpleadmin-web) over RCON: the hostname,
|
||||||
map, team scores, warmup state, and each connected player's userid, name, SteamID64, team,
|
map, team scores, warmup state, and each connected player's userid, name, SteamID64, team,
|
||||||
kills, deaths and ping. Admins hidden with CS2-SimpleAdmin's `css_hide` are left out entirely, as if
|
kills, deaths and ping. It changes nothing in the game.
|
||||||
they weren't connected, so the panel never lists or counts them. It changes nothing in the game.
|
|
||||||
|
|
||||||
Built for CounterStrikeSharp **1.0.376** (`net10.0`) on Metamod:Source 2.0.0.1469. It uses
|
Built for CounterStrikeSharp **1.0.375** (`net10.0`) on Metamod:Source 2.0.0.1469. No other
|
||||||
CS2-SimpleAdmin's shared API (`CS2-SimpleAdminApi`) to spot hidden admins. `lib/CS2-SimpleAdminApi.dll`
|
dependencies.
|
||||||
is a compile-time copy of the server's `shared/` one and isn't shipped. Without SimpleAdmin loaded,
|
|
||||||
everyone is listed.
|
|
||||||
|
|
||||||
## The command
|
## The command
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,19 @@ using System.Text.Json.Serialization;
|
||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||||
using CounterStrikeSharp.API.Core.Capabilities;
|
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Cvars;
|
using CounterStrikeSharp.API.Modules.Cvars;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using CS2_SimpleAdminApi;
|
|
||||||
|
|
||||||
namespace WebPanelBridge;
|
namespace WebPanelBridge;
|
||||||
|
|
||||||
// Reports live match state to simpleadmin-web over RCON. The server console command prints one
|
// Reports live match state to simpleadmin-web over RCON. The server console command prints one
|
||||||
// JSON object per line, each prefixed with "wpb ", so the web panel can pick them out of whatever
|
// JSON object per line, each prefixed with "wpb ", so the web panel can pick them out of whatever
|
||||||
// else lands in the RCON response. Admins hidden with CS2-SimpleAdmin's css_hide are left out, as if
|
// else lands in the RCON response. Nothing here changes game state.
|
||||||
// they weren't connected. Nothing here changes game state.
|
|
||||||
public class WebPanelBridge : BasePlugin
|
public class WebPanelBridge : BasePlugin
|
||||||
{
|
{
|
||||||
public override string ModuleName => "WebPanelBridge";
|
public override string ModuleName => "WebPanelBridge";
|
||||||
public override string ModuleVersion => "0.2.0";
|
public override string ModuleVersion => "0.1.0";
|
||||||
public override string ModuleAuthor => "astra";
|
public override string ModuleAuthor => "astra";
|
||||||
public override string ModuleDescription => "Live server status for simpleadmin-web, over RCON";
|
public override string ModuleDescription => "Live server status for simpleadmin-web, over RCON";
|
||||||
|
|
||||||
|
|
@ -30,8 +27,6 @@ public class WebPanelBridge : BasePlugin
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly PluginCapability<ICS2_SimpleAdminApi> SimpleAdminCapability = new("simpleadmin:api");
|
|
||||||
|
|
||||||
private record ServerLine(int V, string Hostname, string Map, int MaxPlayers, int ScoreT, int ScoreCt, bool Warmup);
|
private record ServerLine(int V, string Hostname, string Map, int MaxPlayers, int ScoreT, int ScoreCt, bool Warmup);
|
||||||
|
|
||||||
private record PlayerLine(int Userid, string Name, string Steamid, int Team, int Kills, int Deaths, uint Ping, bool Bot);
|
private record PlayerLine(int Userid, string Name, string Steamid, int Team, int Kills, int Deaths, uint Ping, bool Bot);
|
||||||
|
|
@ -61,22 +56,10 @@ public class WebPanelBridge : BasePlugin
|
||||||
scoreT, scoreCt, warmup);
|
scoreT, scoreCt, warmup);
|
||||||
command.ReplyToCommand(Prefix + JsonSerializer.Serialize(server, JsonOptions));
|
command.ReplyToCommand(Prefix + JsonSerializer.Serialize(server, JsonOptions));
|
||||||
|
|
||||||
// Fetched on every call, so reloading SimpleAdmin doesn't leave a stale instance here.
|
|
||||||
ICS2_SimpleAdminApi? simpleAdmin = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
simpleAdmin = SimpleAdminCapability.Get();
|
|
||||||
}
|
|
||||||
catch (KeyNotFoundException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var player in Utilities.GetPlayers())
|
foreach (var player in Utilities.GetPlayers())
|
||||||
{
|
{
|
||||||
if (player is not { IsValid: true, IsHLTV: false } || player.Connected != PlayerConnectedState.Connected)
|
if (player is not { IsValid: true, IsHLTV: false } || player.Connected != PlayerConnectedState.Connected)
|
||||||
continue;
|
continue;
|
||||||
if (!player.IsBot && simpleAdmin?.IsAdminSilent(player) == true)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var stats = player.ActionTrackingServices?.MatchStats;
|
var stats = player.ActionTrackingServices?.MatchStats;
|
||||||
var line = new PlayerLine(
|
var line = new PlayerLine(
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,10 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Compile-time only: the server already has CounterStrikeSharp.API.dll -->
|
<!-- Compile-time only: the server already has CounterStrikeSharp.API.dll -->
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.376">
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.375">
|
||||||
<PrivateAssets>none</PrivateAssets>
|
<PrivateAssets>none</PrivateAssets>
|
||||||
<ExcludeAssets>runtime</ExcludeAssets>
|
<ExcludeAssets>runtime</ExcludeAssets>
|
||||||
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<!-- Compile-time only: CS2-SimpleAdmin installs it in shared/, copied from the server's copy -->
|
|
||||||
<Reference Include="CS2-SimpleAdminApi">
|
|
||||||
<HintPath>lib/CS2-SimpleAdminApi.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue