mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-09-27 20:17:04 +02:00
Respecting immunity and css_team command
This commit is contained in:
parent
dcc85b21c3
commit
fdbf1b1a5c
5 changed files with 148 additions and 33 deletions
|
|
@ -22,7 +22,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
public override string ModuleName => "CS2-SimpleAdmin";
|
||||
public override string ModuleDescription => "";
|
||||
public override string ModuleAuthor => "daffyy";
|
||||
public override string ModuleVersion => "1.0.4c";
|
||||
public override string ModuleVersion => "1.0.5";
|
||||
|
||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||
|
||||
|
|
@ -126,9 +126,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[CommandHelper(minArgs: 1, usage: "<#userid or name> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnKickCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
if (!GetTarget(command, out var player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
player!.Pawn.Value!.Freeze();
|
||||
string reason = "Unknown";
|
||||
|
||||
|
|
@ -153,10 +159,14 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnGagCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
if (!GetTarget(command, out var player) || player == null || !player.IsValid)
|
||||
return;
|
||||
if (command.ArgCount < 2)
|
||||
|
||||
if (!caller!.CanTarget(player) || command.ArgCount < 2)
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
|
|
@ -252,14 +262,18 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 0);
|
||||
|
||||
List<CCSPlayerController> matches = Helper.GetPlayerFromSteamid64(steamid);
|
||||
if (matches.Count == 1)
|
||||
{
|
||||
CCSPlayerController? player = matches.FirstOrDefault();
|
||||
if (player != null)
|
||||
{
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
player!.PrintToCenter($"{Config.Messages.PlayerGagMessagePerm}".Replace("{REASON}", reason).Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName));
|
||||
|
|
@ -291,6 +305,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
gaggedPlayers.Add((int)player.Index);
|
||||
}
|
||||
}
|
||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 0);
|
||||
command.ReplyToCommand($"Gagged player with steamid {steamid}.");
|
||||
}
|
||||
|
||||
|
|
@ -381,11 +396,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnBanCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
if (!GetTarget(command, out var player) || command.ArgCount < 2)
|
||||
return;
|
||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
||||
if (command.ArgCount < 2)
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
|
|
@ -465,11 +484,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
await _banManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
List<CCSPlayerController> matches = Helper.GetPlayerFromSteamid64(steamid);
|
||||
if (matches.Count == 1)
|
||||
|
|
@ -477,6 +491,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
CCSPlayerController? player = matches.FirstOrDefault();
|
||||
if (player != null)
|
||||
{
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
player!.Pawn.Value!.Freeze();
|
||||
|
||||
if (time == 0)
|
||||
|
|
@ -490,6 +510,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminBanMessageTime}".Replace("{REASON}", reason).Replace("{TIME}", time.ToString()).Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
await _banManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!));
|
||||
}
|
||||
}
|
||||
|
|
@ -523,12 +549,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
await _banManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
int.TryParse(command.GetArg(2), out time);
|
||||
|
||||
if (command.ArgCount >= 3)
|
||||
|
|
@ -540,6 +560,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
CCSPlayerController? player = matches.FirstOrDefault();
|
||||
if (player != null)
|
||||
{
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
player!.Pawn.Value!.Freeze();
|
||||
|
||||
if (time == 0)
|
||||
|
|
@ -553,6 +579,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminBanMessageTime}".Replace("{REASON}", reason).Replace("{TIME}", time.ToString()).Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
await _banManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, "Banned"));
|
||||
}
|
||||
}
|
||||
|
|
@ -584,8 +616,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnSlayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out CCSPlayerController? player))
|
||||
if (!GetTarget(command, out CCSPlayerController? player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player!.PawnIsAlive)
|
||||
return;
|
||||
|
||||
|
|
@ -599,8 +638,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[CommandHelper(minArgs: 1, usage: "<#userid or name> [damage]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnSlapCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out CCSPlayerController? player))
|
||||
if (!GetTarget(command, out CCSPlayerController? player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player!.PawnIsAlive)
|
||||
return;
|
||||
|
||||
|
|
@ -616,6 +662,53 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminSlapMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_team")]
|
||||
[RequiresPermissions("@css/kick")]
|
||||
[CommandHelper(minArgs: 2, usage: "<#userid or name> [<ct/tt/spec>]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnTeamCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out CCSPlayerController? player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
string teamName = command.GetArg(2).ToLower();
|
||||
CsTeam teamNum = CsTeam.Spectator;
|
||||
|
||||
switch (teamName)
|
||||
{
|
||||
case "ct":
|
||||
case "counterterrorist":
|
||||
teamNum = CsTeam.CounterTerrorist;
|
||||
break;
|
||||
case "t":
|
||||
case "tt":
|
||||
case "terrorist":
|
||||
teamNum = CsTeam.Terrorist;
|
||||
break;
|
||||
default:
|
||||
teamNum = CsTeam.Spectator;
|
||||
break;
|
||||
}
|
||||
|
||||
if (player.TeamNum == ((byte)teamNum))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is already in selected team!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.PawnIsAlive && teamNum != CsTeam.Spectator)
|
||||
player.SwitchTeam(teamNum);
|
||||
else
|
||||
player.ChangeTeam(teamNum);
|
||||
|
||||
command.ReplyToCommand($"Successfully changed team for {player.PlayerName}");
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_map")]
|
||||
[RequiresPermissions("@css/changemap")]
|
||||
[CommandHelper(minArgs: 1, usage: "<mapname>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
|
|
@ -703,9 +796,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[RequiresPermissions("@css/cheats")]
|
||||
public void OnNoclipCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
if (!GetTarget(command, out var player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
player!.Pawn.Value!.ToggleNoclip();
|
||||
|
||||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminNoclipMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
|
|
@ -716,9 +815,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[RequiresPermissions("@css/slay")]
|
||||
public void OnFreezeCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
if (!GetTarget(command, out var player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
int time = 0;
|
||||
int.TryParse(command.GetArg(2), out time);
|
||||
|
||||
|
|
@ -748,9 +853,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||
[RequiresPermissions("@css/cheats")]
|
||||
public void OnRespawnCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
if (!GetTarget(command, out var player) || player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player))
|
||||
{
|
||||
command.ReplyToCommand($"{player.PlayerName} is more powerful than you!");
|
||||
return;
|
||||
}
|
||||
|
||||
player!.Respawn();
|
||||
|
||||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminRespawnMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ namespace CS2_SimpleAdmin
|
|||
|
||||
CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||
|
||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null)
|
||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)
|
||||
return;
|
||||
|
||||
if (player.AuthorizedSteamID == null)
|
||||
{
|
||||
AddTimer(3.0f, () =>
|
||||
{
|
||||
|
|
@ -60,7 +63,7 @@ namespace CS2_SimpleAdmin
|
|||
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
||||
|
||||
MuteManager _muteManager = new(dbConnectionString);
|
||||
List<dynamic> activeMutes = await _muteManager.IsPlayerMuted(playerInfo.SteamId);
|
||||
List<dynamic> activeMutes = await _muteManager.IsPlayerMuted(playerInfo.SteamId!);
|
||||
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CS2_SimpleAdmin
|
||||
namespace CS2_SimpleAdmin
|
||||
{
|
||||
public class PlayerInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
|
|
@ -10,6 +11,11 @@ public static class PlayerUtils
|
|||
PerformSlap(pawn, damage);
|
||||
}
|
||||
|
||||
public static bool CanTarget(this CCSPlayerController controller, CCSPlayerController target)
|
||||
{
|
||||
return AdminManager.CanPlayerTarget(controller, target);
|
||||
}
|
||||
|
||||
public static void Bury(this CBasePlayerPawn pawn, float depth = 10f)
|
||||
{
|
||||
var newPos = new Vector(pawn.AbsOrigin!.X, pawn.AbsOrigin.Y,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ It's only plugin base, I don't have much time for more extensive development, so
|
|||
- css_unmute <steamid or name> <type [gag/mute] - Unmute player // @css/chat
|
||||
- css_slay <#userid or name> - Kill player // @css/slay
|
||||
- css_slap <#userid or name> [damage] - Slap player // @css/slay
|
||||
- css_team <#userid or name> [<ct/tt/spec>] - Change player team // @css/kick
|
||||
- css_map <mapname> - Change map // @css/changemap
|
||||
- css_wsmap <name or id> - Change workshop map // @css/changemap
|
||||
- css_say <message> - Say message as admin in chat // @css/chat
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue