mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-10-18 12:57:04 +02:00
Merge branch 'main' of https://github.com/Cruze03/CS2-SimpleAdmin
This commit is contained in:
commit
a3dccbaa1e
19 changed files with 235 additions and 33 deletions
|
|
@ -237,7 +237,7 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
if (caller == null) return true;
|
||||
|
||||
bool canPermBan = AdminManager.PlayerHasPermissions(caller, "@css/permban");
|
||||
var canPermBan = AdminManager.PlayerHasPermissions(caller, "@css/permban");
|
||||
|
||||
if (duration <= 0 && canPermBan == false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Core.Translations;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Core.Translations;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
|
|
@ -497,13 +496,13 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
if (_localizer == null || caller == null) return;
|
||||
|
||||
var disconnectedMenu = MenuApi?.NewMenu(_localizer["sa_menu_disconnected_title"]);
|
||||
var disconnectedMenu = Helper.CreateMenu(_localizer["sa_menu_disconnected_title"]);
|
||||
|
||||
DisconnectedPlayers.ForEach(player =>
|
||||
{
|
||||
disconnectedMenu?.AddMenuOption(player.Name, (_, _) =>
|
||||
{
|
||||
var disconnectedMenuAction = MenuApi?.NewMenu(_localizer["sa_menu_disconnected_action_title"]);
|
||||
var disconnectedMenuAction = Helper.CreateMenu(_localizer["sa_menu_disconnected_action_title"]);
|
||||
disconnectedMenuAction?.AddMenuOption(_localizer["sa_ban"], (_, _) =>
|
||||
{
|
||||
DurationMenu.OpenMenu(caller, _localizer["sa_ban"], player, (_, _, duration) =>
|
||||
|
|
@ -567,7 +566,7 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
var userId = player.UserId.Value;
|
||||
|
||||
IMenu? warnsMenu = MenuApi?.NewMenu(_localizer["sa_admin_warns_menu_title", player.PlayerName]);
|
||||
IMenu? warnsMenu = Helper.CreateMenu(_localizer["sa_admin_warns_menu_title", player.PlayerName]);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CS2_SimpleAdmin.Managers;
|
||||
|
|
@ -50,6 +49,7 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
if (Database == null || !player.IsValid || !player.UserId.HasValue) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
if (!CheckValidMute(caller, time)) return;
|
||||
|
||||
// Set default caller name if not provided
|
||||
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
|
||||
|
|
@ -126,6 +126,7 @@ public partial class CS2_SimpleAdmin
|
|||
: (_localizer?["sa_unknown"] ?? "Unknown");
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
if (!CheckValidMute(caller, time)) return;
|
||||
|
||||
// Get player and admin info
|
||||
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
|
||||
|
|
@ -264,6 +265,7 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
if (Database == null || !player.IsValid || !player.UserId.HasValue) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
if (!CheckValidMute(caller, time)) return;
|
||||
|
||||
// Set default caller name if not provided
|
||||
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
|
||||
|
|
@ -344,6 +346,7 @@ public partial class CS2_SimpleAdmin
|
|||
: (_localizer?["sa_unknown"] ?? "Unknown");
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
if (!CheckValidMute(caller, time)) return;
|
||||
|
||||
// Get player and admin info
|
||||
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
|
||||
|
|
@ -486,6 +489,7 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
if (Database == null || !player.IsValid || !player.UserId.HasValue) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
if (!CheckValidMute(caller, time)) return;
|
||||
|
||||
// Set default caller name if not provided
|
||||
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
|
||||
|
|
@ -506,6 +510,7 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
// Add penalty to the player's penalty manager
|
||||
PlayerPenaltyManager.AddPenalty(player.Slot, PenaltyType.Silence, Time.ActualDateTime().AddMinutes(time), time);
|
||||
player.VoiceFlags = VoiceFlags.Muted;
|
||||
|
||||
// Determine message keys and arguments based on silence time (permanent or timed)
|
||||
var (messageKey, activityMessageKey, playerArgs, adminActivityArgs) = time == 0
|
||||
|
|
@ -566,6 +571,7 @@ public partial class CS2_SimpleAdmin
|
|||
: (_localizer?["sa_unknown"] ?? "Unknown");
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
if (!CheckValidMute(caller, time)) return;
|
||||
|
||||
// Get player and admin info
|
||||
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
|
||||
|
|
@ -672,4 +678,22 @@ public partial class CS2_SimpleAdmin
|
|||
command.ReplyToCommand($"Unsilenced offline player with pattern {pattern}.");
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckValidMute(CCSPlayerController? caller, int duration)
|
||||
{
|
||||
if (caller == null) return true;
|
||||
|
||||
var canPermMute = AdminManager.PlayerHasPermissions(caller, "@css/permmute");
|
||||
|
||||
if (duration <= 0 && canPermMute == false)
|
||||
{
|
||||
caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_perm_restricted"]}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (duration <= Config.OtherSettings.MaxMuteDuration || canPermMute) return true;
|
||||
|
||||
caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_max_duration_exceeded", Config.OtherSettings.MaxMuteDuration]}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Core.Translations;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
|
|
@ -34,7 +33,7 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
using (new WithTemporaryCulture(player.GetLanguage()))
|
||||
{
|
||||
IMenu? voteMenu = MenuApi?.NewMenu(_localizer["sa_admin_vote_menu_title", question]);
|
||||
IMenu? voteMenu = Helper.CreateMenu(_localizer["sa_admin_vote_menu_title", question]);
|
||||
if (voteMenu == null)
|
||||
return;
|
||||
//ChatMenu voteMenu = new(_localizer!["sa_admin_vote_menu_title", question]);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,18 +67,11 @@ public partial class CS2_SimpleAdmin
|
|||
var weaponName = command.GetArg(2);
|
||||
|
||||
// check if item is typed
|
||||
if (weaponName.Length < 5)
|
||||
{
|
||||
command.ReplyToCommand($"No weapon typed.");
|
||||
return;
|
||||
}
|
||||
|
||||
// check if item is valid
|
||||
if (!weaponName.Contains("weapon_") && !weaponName.Contains("item_"))
|
||||
{
|
||||
command.ReplyToCommand($"{weaponName} is not a valid item.");
|
||||
return;
|
||||
}
|
||||
// if (weaponName.Length < 2)
|
||||
// {
|
||||
// command.ReplyToCommand($"No weapon typed.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// check if weapon is knife
|
||||
if (weaponName.Contains("_knife") || weaponName.Contains("bayonet"))
|
||||
|
|
@ -105,9 +98,22 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
// Set default caller name if not provided
|
||||
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
|
||||
var weapons = WeaponHelper.GetWeaponsByPartialName(weaponName);
|
||||
|
||||
switch (weapons.Count)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case > 1:
|
||||
{
|
||||
var weaponList = string.Join(", ", weapons.Select(w => w.EnumMemberValue));
|
||||
command?.ReplyToCommand($"Found weapons with a similar name: {weaponList}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Give weapon to the player
|
||||
player.GiveNamedItem(weaponName);
|
||||
player.GiveNamedItem(weapons.First().EnumValue);
|
||||
|
||||
// Log the command
|
||||
if (command == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue