mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
Reworked the database layer to support both MySQL and SQLite via new provider classes and migration scripts for each backend. Updated the build workflow to support building and packaging additional modules, including StealthModule and BanSoundModule, and improved artifact handling. Refactored command registration to allow dynamic registration/unregistration and improved API event handling. Updated dependencies, project structure, and configuration checks for better reliability and extensibility. Added new language files, updated versioning, and removed obsolete files.
**⚠️ Warning: SQLite support is currently experimental.
Using this version requires reconfiguration of your database settings!
Plugin now uses UTC time. Please adjust your configurations accordingly!
**
51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using CounterStrikeSharp.API;
|
|
using CounterStrikeSharp.API.Core;
|
|
using CounterStrikeSharp.API.Core.Capabilities;
|
|
using CounterStrikeSharp.API.Modules.Utils;
|
|
using CS2_SimpleAdminApi;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace CS2_SimpleAdmin_BanSoundModule;
|
|
|
|
public class CS2_SimpleAdmin_BanSoundModule: BasePlugin
|
|
{
|
|
public override string ModuleName => "[CS2-SimpleAdmin] BanSound Module";
|
|
public override string ModuleVersion => "v1.0.0";
|
|
public override string ModuleAuthor => "daffyy";
|
|
|
|
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;
|
|
}
|
|
|
|
RegisterListener<Listeners.OnServerPrecacheResources>(OnServerPrecacheResources);
|
|
|
|
_sharedApi.OnPlayerPenaltied += OnPlayerPenaltied;
|
|
}
|
|
|
|
private void OnServerPrecacheResources(ResourceManifest manifest)
|
|
{
|
|
manifest.AddResource("soundevents/soundevents_addon.vsndevts");
|
|
}
|
|
|
|
private void OnPlayerPenaltied(PlayerInfo playerInfo, PlayerInfo? admin, PenaltyType penaltyType,
|
|
string reason, int duration, int? penaltyId, int? serverId)
|
|
{
|
|
if (penaltyType != PenaltyType.Ban || admin == null)
|
|
return;
|
|
|
|
foreach (var player in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot))
|
|
{
|
|
var filter = new RecipientFilter(player);
|
|
player?.EmitSound("bansound", volume: 0.9f, recipients: filter);
|
|
}
|
|
}
|
|
} |