mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-04 22:54:54 +00:00
1.2.6e
- Finally? fixed sqladmins
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
|
|
||||||
@@ -250,18 +249,6 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
string sql = "DELETE FROM sa_admins WHERE player_steamid = @PlayerSteamID";
|
string sql = "DELETE FROM sa_admins WHERE player_steamid = @PlayerSteamID";
|
||||||
await connection.ExecuteAsync(sql, new { PlayerSteamID = playerSteamId });
|
await connection.ExecuteAsync(sql, new { PlayerSteamID = playerSteamId });
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(playerSteamId) && SteamID.TryParse(playerSteamId, out var steamId) && steamId != null)
|
|
||||||
{
|
|
||||||
if (_adminCacheSet.Contains(steamId))
|
|
||||||
{
|
|
||||||
_adminCacheSet.Remove(steamId);
|
|
||||||
_adminCacheTimestamps.Remove(steamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
AdminManager.ClearPlayerPermissions(steamId);
|
|
||||||
AdminManager.RemovePlayerAdminData(steamId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddAdminBySteamId(string playerSteamId, string playerName, string flags, int immunity = 0, int time = 0)
|
public async Task AddAdminBySteamId(string playerSteamId, string playerName, string flags, int immunity = 0, int time = 0)
|
||||||
@@ -293,8 +280,6 @@ namespace CS2_SimpleAdmin
|
|||||||
created = now,
|
created = now,
|
||||||
serverid = CS2_SimpleAdmin.ServerId
|
serverid = CS2_SimpleAdmin.ServerId
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = GiveAllFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteOldAdmins()
|
public async Task DeleteOldAdmins()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using CounterStrikeSharp.API.Modules.Admin;
|
|||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Commands.Targeting;
|
using CounterStrikeSharp.API.Modules.Commands.Targeting;
|
||||||
using CounterStrikeSharp.API.Modules.Cvars;
|
using CounterStrikeSharp.API.Modules.Cvars;
|
||||||
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
@@ -34,7 +35,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public override string ModuleName => "CS2-SimpleAdmin";
|
public override string ModuleName => "CS2-SimpleAdmin";
|
||||||
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
||||||
public override string ModuleAuthor => "daffyy";
|
public override string ModuleAuthor => "daffyy";
|
||||||
public override string ModuleVersion => "1.2.6d";
|
public override string ModuleVersion => "1.2.6e";
|
||||||
|
|
||||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||||
|
|
||||||
@@ -215,9 +216,47 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
AdminSQLManager _adminManager = new(dbConnectionString);
|
AdminSQLManager _adminManager = new(dbConnectionString);
|
||||||
_ = _adminManager.DeleteAdminBySteamId(steamid);
|
_ = _adminManager.DeleteAdminBySteamId(steamid);
|
||||||
|
|
||||||
|
AddTimer(2, () =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(steamid) && SteamID.TryParse(steamid, out var steamId) && steamId != null)
|
||||||
|
{
|
||||||
|
if (AdminSQLManager._adminCacheSet.Contains(steamId))
|
||||||
|
{
|
||||||
|
AdminSQLManager._adminCacheSet.Remove(steamId);
|
||||||
|
AdminSQLManager._adminCacheTimestamps.Remove(steamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminManager.ClearPlayerPermissions(steamId);
|
||||||
|
AdminManager.RemovePlayerAdminData(steamId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
command.ReplyToCommand($"Removed flags from '{steamid}'");
|
command.ReplyToCommand($"Removed flags from '{steamid}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConsoleCommand("css_reladmin")]
|
||||||
|
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
|
[RequiresPermissions("@css/root")]
|
||||||
|
public void OnRelAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
|
{
|
||||||
|
foreach (SteamID steamId in AdminSQLManager._adminCacheSet)
|
||||||
|
{
|
||||||
|
if (AdminSQLManager._adminCacheSet.Contains(steamId))
|
||||||
|
{
|
||||||
|
AdminSQLManager._adminCacheSet.Remove(steamId);
|
||||||
|
AdminSQLManager._adminCacheTimestamps.Remove(steamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminManager.ClearPlayerPermissions(steamId);
|
||||||
|
AdminManager.RemovePlayerAdminData(steamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminSQLManager _adminManager = new(dbConnectionString);
|
||||||
|
_ = _adminManager.GiveAllFlags();
|
||||||
|
|
||||||
|
command.ReplyToCommand($"Reloaded sql admins");
|
||||||
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_who")]
|
[ConsoleCommand("css_who")]
|
||||||
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
[RequiresPermissions("@css/generic")]
|
[RequiresPermissions("@css/generic")]
|
||||||
@@ -417,7 +456,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (TagsDetected)
|
if (TagsDetected)
|
||||||
NativeAPI.IssueServerCommand($"css_tag_mute {player!.Index.ToString()}");
|
NativeAPI.IssueServerCommand($"css_tag_mute {player!.Index}");
|
||||||
|
|
||||||
if (!gaggedPlayers.Contains((int)player!.Index))
|
if (!gaggedPlayers.Contains((int)player!.Index))
|
||||||
gaggedPlayers.Add((int)player.Index);
|
gaggedPlayers.Add((int)player.Index);
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ namespace CS2_SimpleAdmin
|
|||||||
CS2_SimpleAdmin.gaggedPlayers.Add((int)player.Index);
|
CS2_SimpleAdmin.gaggedPlayers.Add((int)player.Index);
|
||||||
|
|
||||||
if (CS2_SimpleAdmin.TagsDetected)
|
if (CS2_SimpleAdmin.TagsDetected)
|
||||||
NativeAPI.IssueServerCommand($"css_tag_mute {player!.Index.ToString()}");
|
NativeAPI.IssueServerCommand($"css_tag_mute {player!.Index}");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CCSPlayerController currentPlayer = player;
|
CCSPlayerController currentPlayer = player;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Manage your Counter-Strike 2 server by simple commands :)
|
|||||||
```js
|
```js
|
||||||
- css_addadmin <steamid> <name> <flags/groups> <immunity> [time in minutes] - Add admin by steamid // @css/root
|
- css_addadmin <steamid> <name> <flags/groups> <immunity> [time in minutes] - Add admin by steamid // @css/root
|
||||||
- css_deladmin <steamid> - Delete admin by steamid // @css/root
|
- css_deladmin <steamid> - Delete admin by steamid // @css/root
|
||||||
|
- css_reladmin - Reload sql admins // @css/root
|
||||||
- css_admin - Display all admin commands // @css/generic
|
- css_admin - Display all admin commands // @css/generic
|
||||||
- css_who <#userid or name> - Display informations about player // @css/generic
|
- css_who <#userid or name> - Display informations about player // @css/generic
|
||||||
- css_players - Display player list // @css/generic
|
- css_players - Display player list // @css/generic
|
||||||
@@ -53,7 +54,7 @@ Manage your Counter-Strike 2 server by simple commands :)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Requirments
|
### Requirments
|
||||||
- [CounterStrikeSharp](https://github.com/roflmuffin/CounterStrikeSharp/) **tested on v142**
|
- [CounterStrikeSharp](https://github.com/roflmuffin/CounterStrikeSharp/) **tested on v144**
|
||||||
- MySQL **tested on MySQL (MariaDB) Server version: 10.11.4-MariaDB-1~deb12u1 Debian 12**
|
- MySQL **tested on MySQL (MariaDB) Server version: 10.11.4-MariaDB-1~deb12u1 Debian 12**
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user