mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
1.2.5a
-Minor changes - Fixed `css_speed`
This commit is contained in:
@@ -6,13 +6,15 @@ namespace CS2_SimpleAdmin
|
||||
internal class AdminSQLManager
|
||||
{
|
||||
private readonly MySqlConnection _dbConnection;
|
||||
public static readonly Dictionary<string, List<string>> _adminCache = new Dictionary<string, List<string>>();
|
||||
// Unused for now
|
||||
//public static readonly ConcurrentDictionary<string, ConcurrentBag<string>> _adminCache = new ConcurrentDictionary<string, ConcurrentBag<string>>();
|
||||
|
||||
public AdminSQLManager(string connectionString)
|
||||
{
|
||||
_dbConnection = new MySqlConnection(connectionString);
|
||||
}
|
||||
|
||||
/*
|
||||
public async Task<List<dynamic>> GetAdminFlags(string steamId)
|
||||
{
|
||||
if (_adminCache.ContainsKey(steamId))
|
||||
@@ -26,7 +28,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
string sql = "SELECT flags FROM sa_admins WHERE player_steamid = @PlayerSteamID AND (ends IS NULL OR ends > @CurrentTime)";
|
||||
string sql = "SELECT flags, ends FROM sa_admins WHERE player_steamid = @PlayerSteamID AND (ends IS NULL OR ends > @CurrentTime)";
|
||||
List<dynamic> activeFlags = (await connection.QueryAsync(sql, new { PlayerSteamID = steamId, CurrentTime = now })).ToList();
|
||||
|
||||
_adminCache[steamId] = new List<string>();
|
||||
@@ -39,13 +41,91 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
return _adminCache[steamId].Select(flag => (dynamic)flag).ToList();
|
||||
}
|
||||
*/
|
||||
|
||||
public async Task<List<object>> GetAdminFlags(string steamId)
|
||||
{
|
||||
/* Unused for now
|
||||
if (_adminCache.TryGetValue(steamId, out ConcurrentBag<string>? cachedFlags))
|
||||
{
|
||||
return cachedFlags.ToList<object>();
|
||||
}
|
||||
*/
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
await using var connection = _dbConnection;
|
||||
await connection.OpenAsync();
|
||||
|
||||
string sql = "SELECT flags, ends FROM sa_admins WHERE player_steamid = @PlayerSteamID AND (ends IS NULL OR ends > @CurrentTime)";
|
||||
List<dynamic>? activeFlags = (await connection.QueryAsync(sql, new { PlayerSteamID = steamId, CurrentTime = now }))?.ToList();
|
||||
|
||||
if (activeFlags == null)
|
||||
{
|
||||
return new List<object>();
|
||||
}
|
||||
|
||||
List<string> filteredFlags = new List<string>();
|
||||
|
||||
foreach (var flags in activeFlags)
|
||||
{
|
||||
if (flags == null) continue;
|
||||
|
||||
string flag = flags.flags.ToString();
|
||||
if (flag != null)
|
||||
{
|
||||
filteredFlags.Add(flag);
|
||||
}
|
||||
}
|
||||
|
||||
/* Unused for now
|
||||
bool shouldCache = activeFlags.Any(flags =>
|
||||
{
|
||||
if (flags?.ends == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (flags.ends is DateTime endsTime)
|
||||
{
|
||||
return (endsTime - now).TotalHours > 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (shouldCache)
|
||||
{
|
||||
List<string> flagsToCache = new List<string>();
|
||||
|
||||
foreach (var flags in activeFlags)
|
||||
{
|
||||
if (flags.ends == null || (DateTime.Now - (DateTime)flags.ends).TotalHours > 6)
|
||||
{
|
||||
if (flags == null) continue;
|
||||
flagsToCache.Add(flags.flags.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
_adminCache.AddOrUpdate(steamId, new ConcurrentBag<string>(flagsToCache), (_, existingBag) =>
|
||||
{
|
||||
foreach (var flag in flagsToCache)
|
||||
{
|
||||
existingBag.Add(flag);
|
||||
}
|
||||
return existingBag;
|
||||
});
|
||||
return flagsToCache.Cast<object>().ToList();
|
||||
}
|
||||
*/
|
||||
|
||||
return filteredFlags.Cast<object>().ToList();
|
||||
}
|
||||
|
||||
public async Task DeleteAdminBySteamId(string playerSteamId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(playerSteamId)) return;
|
||||
|
||||
if (_adminCache.ContainsKey(playerSteamId))
|
||||
_adminCache.Remove(playerSteamId);
|
||||
//_adminCache.TryRemove(playerSteamId, out _);
|
||||
|
||||
await using var connection = _dbConnection;
|
||||
await connection.OpenAsync();
|
||||
@@ -93,4 +173,4 @@ namespace CS2_SimpleAdmin
|
||||
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
_dbConnection = new MySqlConnection(connectionString);
|
||||
}
|
||||
|
||||
public async Task BanPlayer(PlayerInfo player, PlayerInfo issuer, string reason, int time = 0)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
@@ -152,4 +153,4 @@ namespace CS2_SimpleAdmin
|
||||
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@ using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
[MinimumApiVersion(124)]
|
||||
|
||||
[MinimumApiVersion(142)]
|
||||
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
||||
{
|
||||
public static IStringLocalizer? _localizer;
|
||||
@@ -31,7 +32,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
public override string ModuleName => "CS2-SimpleAdmin";
|
||||
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
||||
public override string ModuleAuthor => "daffyy";
|
||||
public override string ModuleVersion => "1.2.4b";
|
||||
public override string ModuleVersion => "1.2.5a";
|
||||
|
||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||
|
||||
@@ -125,7 +126,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
Logger.LogError("Unable to connect to database!");
|
||||
Logger.LogDebug(ex.Message);
|
||||
throw new Exception("[CS2-SimpleAdmin] Unable to connect to Database!" + ex.Message);
|
||||
throw new Exception("[CS2-SimpleAdmin] Unable to connect to Database!");
|
||||
}
|
||||
|
||||
Config = config;
|
||||
@@ -283,7 +284,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && !player.IsBot && !player.IsHLTV).ToList();
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.Connected == PlayerConnectedState.PlayerConnected && !player.IsHLTV).ToList();
|
||||
|
||||
if (caller != null)
|
||||
{
|
||||
@@ -302,7 +302,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
caller!.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.AuthorizedSteamID?.SteamId64}\")");
|
||||
|
||||
});
|
||||
caller!.PrintToConsole($"--------- END PLAYER LIST ---------");
|
||||
}
|
||||
@@ -312,7 +311,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
Server.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.AuthorizedSteamID?.SteamId64}\")");
|
||||
|
||||
});
|
||||
Server.PrintToConsole($"--------- END PLAYER LIST ---------");
|
||||
}
|
||||
@@ -1020,7 +1018,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
|
||||
List<CCSPlayerController> matches = Helper.GetPlayerFromSteamid64(steamid);
|
||||
if (matches.Count == 1)
|
||||
{
|
||||
@@ -1237,7 +1234,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[ConsoleCommand("css_hp")]
|
||||
[RequiresPermissions("@css/slay")]
|
||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> <health>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
@@ -1274,8 +1270,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
/*
|
||||
player.Speed = (float)speed;
|
||||
player.PlayerPawn.Value!.Speed = (float)speed;
|
||||
*/
|
||||
player.SetSpeed((float)speed);
|
||||
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||
@@ -1350,15 +1349,18 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
teamNum = CsTeam.CounterTerrorist;
|
||||
_teamName = "CT";
|
||||
break;
|
||||
|
||||
case "t":
|
||||
case "tt":
|
||||
case "terrorist":
|
||||
teamNum = CsTeam.Terrorist;
|
||||
_teamName = "TT";
|
||||
break;
|
||||
|
||||
case "swap":
|
||||
_teamName = "SWAP";
|
||||
break;
|
||||
|
||||
default:
|
||||
teamNum = CsTeam.Spectator;
|
||||
_teamName = "SPEC";
|
||||
@@ -1396,7 +1398,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[ConsoleCommand("css_vote")]
|
||||
[RequiresPermissions("@css/generic")]
|
||||
[CommandHelper(minArgs: 2, usage: "<question> [... options ...]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
@@ -1445,7 +1446,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
}
|
||||
voteAnswers.Clear();
|
||||
voteInProgress = false;
|
||||
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
|
||||
return;
|
||||
@@ -1502,8 +1502,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
if (caller == null || !caller.IsValid || command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return;
|
||||
|
||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||
|
||||
StringBuilder sb = new();
|
||||
sb.Append(_localizer!["sa_adminchat_template_admin", caller == null ? "Console" : caller.PlayerName, command.GetCommandString[command.GetCommandString.IndexOf(' ')..]]);
|
||||
sb.Append(_localizer!["sa_adminchat_template_admin", caller == null ? "Console" : caller.PlayerName, utf8String]);
|
||||
|
||||
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat")))
|
||||
{
|
||||
@@ -1516,8 +1519,13 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
[RequiresPermissions("@css/chat")]
|
||||
public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return;
|
||||
|
||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||
|
||||
StringBuilder sb = new();
|
||||
sb.Append(_localizer!["sa_adminsay_prefix", command.GetCommandString[command.GetCommandString.IndexOf(' ')..]]);
|
||||
sb.Append(_localizer!["sa_adminsay_prefix", utf8String]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
|
||||
@@ -1533,9 +1541,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
int range = command.GetArg(0).Length + command.GetArg(1).Length + 2;
|
||||
string message = command.GetCommandString[range..];
|
||||
|
||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(message);
|
||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
player.PrintToChat(Helper.ReplaceTags($"({caller!.PlayerName}) {message}"));
|
||||
player.PrintToChat(Helper.ReplaceTags($"({caller!.PlayerName}) {utf8String}"));
|
||||
});
|
||||
|
||||
command.ReplyToCommand(Helper.ReplaceTags($" Private message sent!"));
|
||||
@@ -1546,7 +1557,10 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
[RequiresPermissions("@css/chat")]
|
||||
public void OnAdminCenterSayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
Helper.PrintToCenterAll(Helper.ReplaceTags(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]));
|
||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||
|
||||
Helper.PrintToCenterAll(Helper.ReplaceTags(utf8String));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_hsay", "Say to all players (in hud).")]
|
||||
@@ -1554,9 +1568,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
[RequiresPermissions("@css/chat")]
|
||||
public void OnAdminHudSayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||
|
||||
VirtualFunctions.ClientPrintAll(
|
||||
HudDestination.Alert,
|
||||
Helper.ReplaceTags(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]),
|
||||
Helper.ReplaceTags(utf8String),
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1701,6 +1718,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
case TargetResult.None:
|
||||
command.ReplyToCommand($"Target {command.GetArg(1)} not found.");
|
||||
return false;
|
||||
|
||||
case TargetResult.Multiple:
|
||||
command.ReplyToCommand($"Multiple targets found for \"{command.GetArg(1)}\".");
|
||||
return false;
|
||||
@@ -1709,5 +1727,4 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.124" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.142" />
|
||||
<PackageReference Include="Dapper" Version="*" />
|
||||
<PackageReference Include="MySqlConnector" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
[JsonPropertyName("KickTime")]
|
||||
public int KickTime { get; set; } = 10;
|
||||
|
||||
[JsonPropertyName("DisableDangerousCommands")]
|
||||
public bool DisableDangerousCommands { get; set; } = true;
|
||||
}
|
||||
|
||||
77
Events.cs
77
Events.cs
@@ -7,11 +7,13 @@ using System.Text;
|
||||
using static CounterStrikeSharp.API.Core.Listeners;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
|
||||
public partial class CS2_SimpleAdmin
|
||||
{
|
||||
private void registerEvents()
|
||||
{
|
||||
RegisterListener<OnClientAuthorized>(OnClientAuthorized);
|
||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerFullConnect);
|
||||
RegisterListener<OnClientDisconnect>(OnClientDisconnect);
|
||||
RegisterListener<OnMapStart>(OnMapStart);
|
||||
RegisterEventHandler<EventPlayerHurt>(OnPlayerHurt);
|
||||
@@ -21,6 +23,32 @@ public partial class CS2_SimpleAdmin
|
||||
AddCommandListener("callvote", OnCommandCallVote);
|
||||
}
|
||||
|
||||
/*private HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player == null || player.IsBot || player.IsHLTV) return HookResult.Continue;
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
if (player == null) return;
|
||||
});
|
||||
});
|
||||
return HookResult.Continue;
|
||||
}
|
||||
*/
|
||||
|
||||
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
||||
{
|
||||
GodPlayers.Clear();
|
||||
@@ -100,15 +128,6 @@ public partial class CS2_SimpleAdmin
|
||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)
|
||||
return;
|
||||
|
||||
if (player.AuthorizedSteamID == null)
|
||||
{
|
||||
AddTimer(3.0f, () =>
|
||||
{
|
||||
OnClientAuthorized(playerSlot, steamID);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
@@ -120,7 +139,6 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
||||
|
||||
@@ -178,7 +196,6 @@ public partial class CS2_SimpleAdmin
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CCSPlayerController currentPlayer = player;
|
||||
|
||||
@@ -222,33 +239,7 @@ public partial class CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
|
||||
if (AdminSQLManager._adminCache.ContainsKey(playerInfo.SteamId!))
|
||||
{
|
||||
AddTimer(10, () =>
|
||||
{
|
||||
foreach (var flagsValue in AdminSQLManager._adminCache[playerInfo.SteamId!])
|
||||
{
|
||||
if (!string.IsNullOrEmpty(flagsValue))
|
||||
{
|
||||
string[] _flags = flagsValue.Split(',');
|
||||
|
||||
if (player == null) return;
|
||||
foreach (var _flag in _flags)
|
||||
{
|
||||
if (_flag.StartsWith("@"))
|
||||
{
|
||||
AdminManager.AddPlayerPermissions(player, _flag);
|
||||
}
|
||||
if (_flag.StartsWith("#"))
|
||||
{
|
||||
AdminManager.AddPlayerToGroup(player, _flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AddTimer(14, () => Helper.GivePlayerFlags(player, activeFlags));
|
||||
|
||||
/*
|
||||
|
||||
@@ -315,10 +306,10 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
if (player.AuthorizedSteamID != null)
|
||||
{
|
||||
if (AdminSQLManager._adminCache.ContainsKey(player.AuthorizedSteamID.SteamId64.ToString()))
|
||||
{
|
||||
AdminSQLManager._adminCache.Remove(player.AuthorizedSteamID.SteamId64.ToString());
|
||||
}
|
||||
//string steamIdString = player.AuthorizedSteamID.SteamId64.ToString();
|
||||
|
||||
//AdminSQLManager._adminCache.TryRemove(steamIdString, out _);
|
||||
AdminManager.RemovePlayerPermissions(player);
|
||||
}
|
||||
|
||||
if (TagsDetected)
|
||||
@@ -359,4 +350,4 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Helper.cs
39
Helper.cs
@@ -1,9 +1,10 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
|
||||
namespace CS2_SimpleAdmin
|
||||
{
|
||||
@@ -46,6 +47,35 @@ namespace CS2_SimpleAdmin
|
||||
return Regex.IsMatch(input, pattern);
|
||||
}
|
||||
|
||||
public static void GivePlayerFlags(CCSPlayerController player, dynamic flags)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
foreach (var flagsValue in flags)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(flagsValue))
|
||||
{
|
||||
string[] _flags = flagsValue.Split(',');
|
||||
Console.WriteLine(flagsValue);
|
||||
|
||||
foreach (var _flag in _flags)
|
||||
{
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
if (_flag.StartsWith("@"))
|
||||
{
|
||||
AdminManager.AddPlayerPermissions(player, _flag);
|
||||
}
|
||||
if (_flag.StartsWith("#"))
|
||||
{
|
||||
AdminManager.AddPlayerToGroup(player, _flag);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static TargetResult GetTarget(string target, out CCSPlayerController? player)
|
||||
{
|
||||
@@ -105,6 +135,5 @@ namespace CS2_SimpleAdmin
|
||||
if (CS2_SimpleAdmin.voteInProgress)
|
||||
CS2_SimpleAdmin.voteAnswers[option.Text]++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using Dapper;
|
||||
using MySqlConnector;
|
||||
using System.Data;
|
||||
@@ -188,7 +187,5 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@
|
||||
public string? Name { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using System.Text;
|
||||
|
||||
@@ -12,6 +11,7 @@ public static class PlayerUtils
|
||||
{
|
||||
PerformSlap(pawn, damage);
|
||||
}
|
||||
|
||||
public static void Print(this CCSPlayerController controller, string message = "")
|
||||
{
|
||||
StringBuilder _message = new(CS2_SimpleAdmin._localizer!["sa_prefix"]);
|
||||
@@ -25,6 +25,14 @@ public static class PlayerUtils
|
||||
return AdminManager.CanPlayerTarget(controller, target);
|
||||
}
|
||||
|
||||
public static void SetSpeed(this CCSPlayerController controller, float speed)
|
||||
{
|
||||
CCSPlayerPawn? playerPawnValue = controller.PlayerPawn.Value;
|
||||
if (playerPawnValue == null) return;
|
||||
|
||||
playerPawnValue.VelocityModifier = speed;
|
||||
}
|
||||
|
||||
public static void SetHp(this CCSPlayerController controller, int health = 100)
|
||||
{
|
||||
if (health <= 0 || !controller.PawnIsAlive || controller.PlayerPawn.Value == null) return;
|
||||
|
||||
@@ -53,7 +53,7 @@ Manage your Counter-Strike 2 server by simple commands :)
|
||||
```
|
||||
|
||||
### Requirments
|
||||
[CounterStrikeSharp](https://github.com/roflmuffin/CounterStrikeSharp/) **tested on v90**
|
||||
[CounterStrikeSharp](https://github.com/roflmuffin/CounterStrikeSharp/) **tested on v142**
|
||||
|
||||
### Configuration
|
||||
After first launch, u need to configure plugin in addons/counterstrikesharp/configs/plugins/CS2-SimpleAdmin/CS2-SimpleAdmin.json
|
||||
|
||||
@@ -35,4 +35,4 @@
|
||||
"sa_adminsay_prefix": "{RED}ADMINS: {lightred}{0}{default}",
|
||||
"sa_adminchat_template_admin": "{LIME}(ADMINS) {lightred}{0}{default}: {lightred}{1}{default}",
|
||||
"sa_adminchat_template_player": "{SILVER}(SPĒLĒTĀJS) {lightred}{0}{default}: {lightred}{1}{default}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user