mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-06-10 08:07:34 +00:00
Add files via upload
This commit is contained in:
BIN
MODULES/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdminApi.dll
Normal file
BIN
MODULES/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdminApi.dll
Normal file
Binary file not shown.
@@ -0,0 +1,176 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Core.Capabilities;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CS2_SimpleAdminApi;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CS2_SimpleAdmin_ExampleModule;
|
||||
|
||||
public class CS2_SimpleAdmin_ExampleModule: BasePlugin
|
||||
{
|
||||
public override string ModuleName => "[CS2-SimpleAdmin] Example module";
|
||||
public override string ModuleVersion => "v1.0.1";
|
||||
public override string ModuleAuthor => "daffyy";
|
||||
|
||||
private int? _serverId;
|
||||
private string _dbConnectionString = string.Empty;
|
||||
|
||||
private static ICS2_SimpleAdminApi? _sharedApi;
|
||||
private readonly PluginCapability<ICS2_SimpleAdminApi> _pluginCapability = new("simpleadmin:api");
|
||||
|
||||
public override void OnAllPluginsLoaded(bool hotReload)
|
||||
{
|
||||
_sharedApi = _pluginCapability.Get();
|
||||
|
||||
if (_sharedApi == null)
|
||||
{
|
||||
Logger.LogError("CS2-SimpleAdmin SharedApi not found");
|
||||
Unload(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_serverId = _sharedApi.GetServerId();
|
||||
_dbConnectionString = _sharedApi.GetConnectionString();
|
||||
Logger.LogInformation($"{ModuleName} started with serverId {_serverId}");
|
||||
|
||||
_sharedApi.OnPlayerPenaltied += OnPlayerPenaltied;
|
||||
_sharedApi.OnPlayerPenaltiedAdded += OnPlayerPenaltiedAdded;
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_kickme")]
|
||||
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||
public void KickMeCommand(CCSPlayerController? caller, CommandInfo commandInfo)
|
||||
{
|
||||
if (caller == null) return;
|
||||
|
||||
_sharedApi?.IssuePenalty(caller, null, PenaltyType.Kick, "test");
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_serverAddress")]
|
||||
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||
public void ServerAddressCommand(CCSPlayerController? caller, CommandInfo commandInfo)
|
||||
{
|
||||
commandInfo.ReplyToCommand($"Our server IP: {_sharedApi?.GetServerAddress()}");
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_getMyInfo")]
|
||||
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||
public void GetMyInfoCommand(CCSPlayerController? caller, CommandInfo commandInfo)
|
||||
{
|
||||
if (caller == null) return;
|
||||
|
||||
var playerInfo = _sharedApi?.GetPlayerInfo(caller);
|
||||
commandInfo.ReplyToCommand($"Your total bans: {playerInfo?.TotalBans}");
|
||||
commandInfo.ReplyToCommand($"Your total gags: {playerInfo?.TotalGags}");
|
||||
commandInfo.ReplyToCommand($"Your total mutes: {playerInfo?.TotalMutes}");
|
||||
commandInfo.ReplyToCommand($"Your total silences: {playerInfo?.SteamId}");
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_testaddban")]
|
||||
[CommandHelper(whoCanExecute: CommandUsage.SERVER_ONLY)]
|
||||
public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo commandInfo)
|
||||
{
|
||||
_sharedApi?.IssuePenalty(new SteamID(76561197960287930), null, PenaltyType.Ban, "My super reason", 10);
|
||||
}
|
||||
|
||||
private void OnPlayerPenaltied(PlayerInfo player, PlayerInfo? admin, PenaltyType penaltyType,
|
||||
string reason, int duration, int? penaltyId, int? serverId)
|
||||
{
|
||||
if (penaltyType == PenaltyType.Ban)
|
||||
{
|
||||
Server.PrintToChatAll($"{player.Name} is a dog");
|
||||
}
|
||||
|
||||
switch (penaltyType)
|
||||
{
|
||||
case PenaltyType.Ban:
|
||||
{
|
||||
Logger.LogInformation("Ban issued");
|
||||
Logger.LogInformation($"Id = {penaltyId}");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Kick:
|
||||
{
|
||||
Logger.LogInformation("Kick issued");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Gag:
|
||||
{
|
||||
Logger.LogInformation("Gag issued");
|
||||
Logger.LogInformation($"Id = {penaltyId}");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Mute:
|
||||
{
|
||||
Logger.LogInformation("Mute issued");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Silence:
|
||||
{
|
||||
Logger.LogInformation("Silence issued");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Warn:
|
||||
{
|
||||
Logger.LogInformation("Warn issued");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(penaltyType), penaltyType, null);
|
||||
}
|
||||
|
||||
Console.WriteLine(player.Name);
|
||||
Console.WriteLine(admin?.Name ?? "Console");
|
||||
Console.WriteLine(player.SteamId.ToString());
|
||||
Console.WriteLine(reason);
|
||||
}
|
||||
|
||||
private void OnPlayerPenaltiedAdded(SteamID steamId, PlayerInfo? admin, PenaltyType penaltyType,
|
||||
string reason, int duration, int? penaltyId, int? serverId)
|
||||
{
|
||||
switch (penaltyType)
|
||||
{
|
||||
case PenaltyType.Ban:
|
||||
{
|
||||
Logger.LogInformation("Ban added");
|
||||
Logger.LogInformation($"Id = {penaltyId}");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Kick:
|
||||
{
|
||||
Logger.LogInformation("Kick added");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Gag:
|
||||
{
|
||||
Logger.LogInformation("Gag added");
|
||||
Logger.LogInformation($"Id = {penaltyId}");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Mute:
|
||||
{
|
||||
Logger.LogInformation("Mute added");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Silence:
|
||||
{
|
||||
Logger.LogInformation("Silence added");
|
||||
break;
|
||||
}
|
||||
case PenaltyType.Warn:
|
||||
{
|
||||
Logger.LogInformation("Warn added");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(penaltyType), penaltyType, null);
|
||||
}
|
||||
|
||||
Console.WriteLine(admin?.Name ?? "Console");
|
||||
Console.WriteLine(steamId.ToString());
|
||||
Console.WriteLine(reason);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>CS2_SimpleAdmin_ExampleModule</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.266" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="CS2-SimpleAdminApi">
|
||||
<HintPath>CS2-SimpleAdminApi.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS2-SimpleAdmin_ExampleModule", "CS2-SimpleAdmin_ExampleModule.csproj", "{D940F3E9-0E3F-467A-B336-149E3A624FB6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D940F3E9-0E3F-467A-B336-149E3A624FB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D940F3E9-0E3F-467A-B336-149E3A624FB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D940F3E9-0E3F-467A-B336-149E3A624FB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D940F3E9-0E3F-467A-B336-149E3A624FB6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AICS2_005FSimpleAdminApi_002Ecs_002Fl_003AC_0021_003FUsers_003Fxdaff_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0fc75e00ad8d4b7ea6a0bc4c161a3ba12200_003F3c_003F988e5f2a_003FICS2_005FSimpleAdminApi_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||
Reference in New Issue
Block a user