mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-04 14:44:55 +00:00
Fun menu done without guns, need to test
This commit is contained in:
@@ -600,7 +600,7 @@ namespace CS2_SimpleAdmin
|
|||||||
[ConsoleCommand("css_restart")]
|
[ConsoleCommand("css_restart")]
|
||||||
[ConsoleCommand("css_restartgame")]
|
[ConsoleCommand("css_restartgame")]
|
||||||
[RequiresPermissions("@css/generic")]
|
[RequiresPermissions("@css/generic")]
|
||||||
[CommandHelper(minArgs: 1, usage: "", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 0, usage: "", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnRestartCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnRestartCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
RestartGame(caller);
|
RestartGame(caller);
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ namespace CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
NoClip(caller, player, callerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NoClip(CCSPlayerController? caller, CCSPlayerController player, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
player!.Pawn.Value!.ToggleNoclip();
|
player!.Pawn.Value!.ToggleNoclip();
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
@@ -46,8 +54,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_freeze", "Freeze a player.")]
|
[ConsoleCommand("css_freeze", "Freeze a player.")]
|
||||||
[CommandHelper(1, "<#userid or name> [duration]")]
|
[CommandHelper(1, "<#userid or name> [duration]")]
|
||||||
@@ -73,6 +79,15 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
Freeze(caller, player, time, callerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Freeze(CCSPlayerController? caller, CCSPlayerController player, int time, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player!.Pawn.Value!.Freeze();
|
player!.Pawn.Value!.Freeze();
|
||||||
|
|
||||||
if (time > 0)
|
if (time > 0)
|
||||||
@@ -91,8 +106,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_unfreeze", "Unfreeze a player.")]
|
[ConsoleCommand("css_unfreeze", "Unfreeze a player.")]
|
||||||
[CommandHelper(1, "<#userid or name>")]
|
[CommandHelper(1, "<#userid or name>")]
|
||||||
@@ -115,6 +128,14 @@ namespace CS2_SimpleAdmin
|
|||||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Unfreeze(caller, player, callerName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unfreeze(CCSPlayerController? caller, CCSPlayerController player, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player!.Pawn.Value!.Unfreeze();
|
player!.Pawn.Value!.Unfreeze();
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
@@ -129,7 +150,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,15 @@ namespace CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
StripWeapons(caller, player, callerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StripWeapons(CCSPlayerController? caller, CCSPlayerController player, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -164,8 +173,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_hp")]
|
[ConsoleCommand("css_hp")]
|
||||||
[RequiresPermissions("@css/slay")]
|
[RequiresPermissions("@css/slay")]
|
||||||
@@ -190,6 +197,13 @@ namespace CS2_SimpleAdmin
|
|||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
|
{
|
||||||
|
SetHp(caller, player, health, callerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetHp(CCSPlayerController? caller, CCSPlayerController player, int health, string callerName = null)
|
||||||
{
|
{
|
||||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||||
return;
|
return;
|
||||||
@@ -209,8 +223,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_speed")]
|
[ConsoleCommand("css_speed")]
|
||||||
[RequiresPermissions("@css/slay")]
|
[RequiresPermissions("@css/slay")]
|
||||||
@@ -239,12 +251,16 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
/*
|
SetSpeed(caller, player, speed, callerName);
|
||||||
player.Speed = (float)speed;
|
}
|
||||||
player.PlayerPawn.Value!.Speed = (float)speed;
|
});
|
||||||
*/
|
}
|
||||||
player.SetSpeed((float)speed);
|
|
||||||
|
|
||||||
|
public void SetSpeed(CCSPlayerController? caller, CCSPlayerController player, double speed, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
|
player.SetSpeed((float)speed);
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
@@ -259,8 +275,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_god")]
|
[ConsoleCommand("css_god")]
|
||||||
[RequiresPermissions("@css/cheats")]
|
[RequiresPermissions("@css/cheats")]
|
||||||
@@ -286,6 +300,15 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
God(caller, player, callerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void God(CCSPlayerController? caller, CCSPlayerController player, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
if (!godPlayers.Contains(player.Slot))
|
if (!godPlayers.Contains(player.Slot))
|
||||||
@@ -312,8 +335,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_slap")]
|
[ConsoleCommand("css_slap")]
|
||||||
[RequiresPermissions("@css/slay")]
|
[RequiresPermissions("@css/slay")]
|
||||||
@@ -528,6 +549,15 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
Respawn(caller, player, callerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Respawn(CCSPlayerController? caller, CCSPlayerController player, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (CBasePlayerController_SetPawnFunc == null || player.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
if (CBasePlayerController_SetPawnFunc == null || player.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
||||||
|
|
||||||
var playerPawn = player.PlayerPawn.Value;
|
var playerPawn = player.PlayerPawn.Value;
|
||||||
@@ -549,8 +579,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_tp", "Teleport to a player.")]
|
[ConsoleCommand("css_tp", "Teleport to a player.")]
|
||||||
[ConsoleCommand("css_tpto", "Teleport to a player.")]
|
[ConsoleCommand("css_tpto", "Teleport to a player.")]
|
||||||
|
|||||||
@@ -42,28 +42,14 @@ public static class PlayerExtensions
|
|||||||
{
|
{
|
||||||
if (health <= 0 || !controller.PawnIsAlive || controller.PlayerPawn.Value == null) return;
|
if (health <= 0 || !controller.PawnIsAlive || controller.PlayerPawn.Value == null) return;
|
||||||
|
|
||||||
controller.Health = health;
|
|
||||||
controller.PlayerPawn.Value.Health = health;
|
controller.PlayerPawn.Value.Health = health;
|
||||||
|
|
||||||
if (health > 100)
|
if (health > 100)
|
||||||
{
|
{
|
||||||
controller.MaxHealth = health;
|
|
||||||
controller.PlayerPawn.Value.MaxHealth = health;
|
controller.PlayerPawn.Value.MaxHealth = health;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlayer_WeaponServices? weaponServices = controller.PlayerPawn.Value!.WeaponServices;
|
Utilities.SetStateChanged(controller.PlayerPawn.Value, "CBaseEntity", "m_iHealth");
|
||||||
if (weaponServices == null) return;
|
|
||||||
|
|
||||||
controller.GiveNamedItem("weapon_healthshot");
|
|
||||||
|
|
||||||
foreach (var weapon in weaponServices.MyWeapons)
|
|
||||||
{
|
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value!.DesignerName == "weapon_healthshot")
|
|
||||||
{
|
|
||||||
weapon.Value.Remove();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Bury(this CBasePlayerPawn pawn, float depth = 10f)
|
public static void Bury(this CBasePlayerPawn pawn, float depth = 10f)
|
||||||
|
|||||||
@@ -40,13 +40,10 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
{
|
{
|
||||||
options.Add(new ChatMenuOptionData("Strip All Weapons", () => PlayersMenu.OpenMenu(admin, "Strip All Weapons", StripWeapons)));
|
options.Add(new ChatMenuOptionData("Strip All Weapons", () => PlayersMenu.OpenMenu(admin, "Strip All Weapons", StripWeapons)));
|
||||||
options.Add(new ChatMenuOptionData("Freeze", () => PlayersMenu.OpenMenu(admin, "Freeze", Freeze)));
|
options.Add(new ChatMenuOptionData("Freeze", () => PlayersMenu.OpenMenu(admin, "Freeze", Freeze)));
|
||||||
options.Add(new ChatMenuOptionData("HP", () => PlayersMenu.OpenMenu(admin, "HP", HP)));
|
options.Add(new ChatMenuOptionData("HP", () => PlayersMenu.OpenMenu(admin, "HP", SetHpMenu)));
|
||||||
options.Add(new ChatMenuOptionData("Speed", () => PlayersMenu.OpenMenu(admin, "Speed", Speed)));
|
options.Add(new ChatMenuOptionData("Speed", () => PlayersMenu.OpenMenu(admin, "Speed", SetSpeedMenu)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
options.Add(new ChatMenuOptionData("Restart Game", () => CS2_SimpleAdmin.Instance.RestartGame(admin)));
|
|
||||||
|
|
||||||
foreach (ChatMenuOptionData menuOptionData in options)
|
foreach (ChatMenuOptionData menuOptionData in options)
|
||||||
{
|
{
|
||||||
string menuName = menuOptionData.name;
|
string menuName = menuOptionData.name;
|
||||||
@@ -57,20 +54,97 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void GodMode(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void GodMode(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.God(admin, player);
|
||||||
|
}
|
||||||
|
|
||||||
private static void NoClip(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void NoClip(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.NoClip(admin, player);
|
||||||
|
}
|
||||||
|
|
||||||
private static void Respawn(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void Respawn(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.Respawn(admin, player);
|
||||||
|
}
|
||||||
|
|
||||||
private static void GiveWeaponMenu(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void GiveWeaponMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
// TODO: show weapon menu
|
||||||
|
}
|
||||||
|
|
||||||
private static void StripWeapons(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void StripWeapons(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.StripWeapons(admin, player);
|
||||||
|
}
|
||||||
|
|
||||||
private static void Freeze(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void Freeze(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (player.PlayerPawn.Value.MoveType == MoveType_t.MOVETYPE_OBSOLETE)
|
||||||
|
CS2_SimpleAdmin.Instance.Freeze(admin, player, -1);
|
||||||
|
else
|
||||||
|
CS2_SimpleAdmin.Instance.Unfreeze(admin, player);
|
||||||
|
}
|
||||||
|
|
||||||
private static void HP(CCSPlayerController admin, CCSPlayerController player) { }
|
private static void SetHpMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
Tuple<string, int>[] _hpArray = new[]
|
||||||
|
{
|
||||||
|
new Tuple<string, int>("1", 1),
|
||||||
|
new Tuple<string, int>("10", 10),
|
||||||
|
new Tuple<string, int>("25", 25),
|
||||||
|
new Tuple<string, int>("50", 50),
|
||||||
|
new Tuple<string, int>("100", 100),
|
||||||
|
new Tuple<string, int>("200", 200),
|
||||||
|
new Tuple<string, int>("500", 500),
|
||||||
|
new Tuple<string, int>("999", 999)
|
||||||
|
};
|
||||||
|
|
||||||
private static void Speed(CCSPlayerController admin, CCSPlayerController player) { }
|
BaseMenu menu = AdminMenu.CreateMenu("Set HP");
|
||||||
|
|
||||||
|
foreach (Tuple<string, int> hpTuple in _hpArray)
|
||||||
|
{
|
||||||
|
string optionName = hpTuple.Item1;
|
||||||
|
menu.AddMenuOption(optionName, (_, _) => { SetHP(admin, player, hpTuple.Item2); });
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminMenu.OpenMenu(admin, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetHP(CCSPlayerController admin, CCSPlayerController player, int hp)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.SetHp(admin, player, hp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetSpeedMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
{
|
||||||
|
Tuple<string, float>[] _speedArray = new[]
|
||||||
|
{
|
||||||
|
new Tuple<string, float>("0.1", .1f),
|
||||||
|
new Tuple<string, float>("0.25", .25f),
|
||||||
|
new Tuple<string, float>("0.5", .5f),
|
||||||
|
new Tuple<string, float>("0.75", .75f),
|
||||||
|
new Tuple<string, float>("1", 1),
|
||||||
|
new Tuple<string, float>("2", 2),
|
||||||
|
new Tuple<string, float>("3", 3),
|
||||||
|
new Tuple<string, float>("4", 4),
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseMenu menu = AdminMenu.CreateMenu("Set Speed");
|
||||||
|
|
||||||
|
foreach (Tuple<string, float> speedTuple in _speedArray)
|
||||||
|
{
|
||||||
|
string optionName = speedTuple.Item1;
|
||||||
|
menu.AddMenuOption(optionName, (_, _) => { SetSpeed(admin, player, speedTuple.Item2); });
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminMenu.OpenMenu(admin, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetSpeed(CCSPlayerController admin, CCSPlayerController player, float speed)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.SetSpeed(admin, player, speed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user