mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-10 00:22:31 +00:00
Fun commands done
This commit is contained in:
@@ -9,6 +9,7 @@ using CounterStrikeSharp.API.Modules.Memory;
|
|||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin
|
namespace CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
@@ -108,7 +109,23 @@ namespace CS2_SimpleAdmin
|
|||||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GiveWeapon(caller, player, weaponName, callerName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, CsItem weapon, string callerName = null)
|
||||||
|
{
|
||||||
|
player.GiveNamedItem(weapon);
|
||||||
|
SubGiveWeapon(caller, player, weapon.ToString(), callerName);
|
||||||
|
}
|
||||||
|
public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string callerName = null)
|
||||||
|
{
|
||||||
player.GiveNamedItem(weaponName);
|
player.GiveNamedItem(weaponName);
|
||||||
|
SubGiveWeapon(caller, player, weaponName, callerName);
|
||||||
|
}
|
||||||
|
public void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string callerName = null)
|
||||||
|
{
|
||||||
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
@@ -122,7 +139,6 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_strip")]
|
[ConsoleCommand("css_strip")]
|
||||||
|
|||||||
@@ -1,11 +1,32 @@
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Admin;
|
||||||
|
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin.Menus
|
namespace CS2_SimpleAdmin.Menus
|
||||||
{
|
{
|
||||||
public static class FunActionsMenu
|
public static class FunActionsMenu
|
||||||
{
|
{
|
||||||
|
private static Dictionary<int, CsItem> _weaponsCache = null;
|
||||||
|
private static Dictionary<int, CsItem> GetWeaponsCache
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_weaponsCache == null)
|
||||||
|
{
|
||||||
|
Array weaponsArray = Enum.GetValues(typeof(CsItem));
|
||||||
|
|
||||||
|
// avoid duplicates in the menu
|
||||||
|
_weaponsCache = new();
|
||||||
|
foreach (CsItem item in weaponsArray)
|
||||||
|
{
|
||||||
|
_weaponsCache[(int)item] = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _weaponsCache;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void OpenMenu(CCSPlayerController admin)
|
public static void OpenMenu(CCSPlayerController admin)
|
||||||
{
|
{
|
||||||
if (admin == null || admin.IsValid == false)
|
if (admin == null || admin.IsValid == false)
|
||||||
@@ -71,7 +92,21 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
|
|
||||||
private static void GiveWeaponMenu(CCSPlayerController admin, CCSPlayerController player)
|
private static void GiveWeaponMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||||
{
|
{
|
||||||
// TODO: show weapon menu
|
BaseMenu menu = AdminMenu.CreateMenu("Give Weapon");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (KeyValuePair<int, CsItem> weapon in GetWeaponsCache)
|
||||||
|
{
|
||||||
|
menu.AddMenuOption(weapon.Value.ToString(), (_, _) => { GiveWeapon(admin, player, weapon.Value); });
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminMenu.OpenMenu(admin, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GiveWeapon(CCSPlayerController admin, CCSPlayerController player, CsItem weaponValue)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.GiveWeapon(admin, player, weaponValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void StripWeapons(CCSPlayerController admin, CCSPlayerController player)
|
private static void StripWeapons(CCSPlayerController admin, CCSPlayerController player)
|
||||||
@@ -128,7 +163,7 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
new Tuple<string, float>("1", 1),
|
new Tuple<string, float>("1", 1),
|
||||||
new Tuple<string, float>("2", 2),
|
new Tuple<string, float>("2", 2),
|
||||||
new Tuple<string, float>("3", 3),
|
new Tuple<string, float>("3", 3),
|
||||||
new Tuple<string, float>("4", 4),
|
new Tuple<string, float>("4", 4)
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseMenu menu = AdminMenu.CreateMenu("Set Speed");
|
BaseMenu menu = AdminMenu.CreateMenu("Set Speed");
|
||||||
|
|||||||
Reference in New Issue
Block a user