mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-12 17:16:29 +00:00
Update Commands.cs
This commit is contained in:
222
Commands.cs
222
Commands.cs
@@ -1,6 +1,8 @@
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
@@ -129,18 +131,44 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!Config.Additional.KnifeEnabled || !g_bCommandsAllowed) return;
|
if (!Config.Additional.KnifeEnabled || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
var knivesOnly = weaponList
|
var knivesOnly = GetKnivesOnly();
|
||||||
|
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
||||||
|
|
||||||
|
AddMenuOptions(giveItemMenu, knivesOnly);
|
||||||
|
AddCommandToOpenKnifeMenu(giveItemMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, string> GetKnivesOnly()
|
||||||
|
{
|
||||||
|
return weaponList
|
||||||
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
private void AddMenuOptions(ChatMenu giveItemMenu, Dictionary<string, string> knivesOnly)
|
||||||
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
{
|
||||||
|
foreach (var knifePair in knivesOnly)
|
||||||
|
{
|
||||||
|
giveItemMenu.AddMenuOption(knifePair.Value, (player, option) => HandleGiveOption(player, option, knivesOnly));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleGiveOption(CCSPlayerController player, ChatMenuOption option, Dictionary<string, string> knivesOnly)
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
var knifeName = option.Text;
|
var knifeName = option.Text;
|
||||||
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(knifeKey))
|
if (!string.IsNullOrEmpty(knifeKey))
|
||||||
|
{
|
||||||
|
PrintMessages(player, knifeName);
|
||||||
|
SetPlayerKnife(player, knifeKey);
|
||||||
|
SyncKnifeToDatabase(player, knifeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrintMessages(CCSPlayerController player, string knifeName)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
||||||
{
|
{
|
||||||
@@ -151,8 +179,25 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_knife_menu_kill"]);
|
player!.Print(Localizer["wp_knife_menu_kill"]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
private void SetPlayerKnife(CCSPlayerController player, string knifeKey)
|
||||||
|
{
|
||||||
|
g_playersKnife[player.Slot] = knifeKey;
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
RefreshWeapons(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SyncKnifeToDatabase(CCSPlayerController player, string knifeKey)
|
||||||
|
{
|
||||||
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(GetPlayerInfo(player), knifeKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlayerInfo GetPlayerInfo(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
return new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Slot = player.Slot,
|
Slot = player.Slot,
|
||||||
@@ -161,29 +206,17 @@ namespace WeaponPaints
|
|||||||
Name = player.PlayerName,
|
Name = player.PlayerName,
|
||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
g_playersKnife[player.Slot] = knifeKey;
|
|
||||||
|
|
||||||
|
|
||||||
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
|
||||||
RefreshWeapons(player);
|
|
||||||
|
|
||||||
if (weaponSync != null)
|
|
||||||
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
foreach (var knifePair in knivesOnly)
|
private void AddCommandToOpenKnifeMenu(ChatMenu giveItemMenu)
|
||||||
{
|
{
|
||||||
giveItemMenu.AddMenuOption(knifePair.Value, handleGive);
|
|
||||||
}
|
|
||||||
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
if (player == null || player.UserId == null) return;
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
if (IsCommandAllowed(player))
|
||||||
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
|
||||||
{
|
{
|
||||||
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
giveItemMenu.PostSelectAction = PostSelectAction.Close;
|
giveItemMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
@@ -197,13 +230,32 @@ namespace WeaponPaints
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsCommandAllowed(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (!commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return DateTime.UtcNow >= cooldownEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
private void SetupSkinsMenu()
|
private void SetupSkinsMenu()
|
||||||
{
|
{
|
||||||
var classNamesByWeapon = weaponList.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
var classNamesByWeapon = weaponList.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
||||||
var weaponSelectionMenu = new ChatMenu(Localizer["wp_skin_menu_weapon_title"]);
|
var weaponSelectionMenu = new ChatMenu(Localizer["wp_skin_menu_weapon_title"]);
|
||||||
|
|
||||||
// Function to handle skin selection for a specific weapon
|
// Add weapon options to the weapon selection menu
|
||||||
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
foreach (var weaponClass in weaponList.Keys)
|
||||||
|
{
|
||||||
|
string weaponName = weaponList[weaponClass];
|
||||||
|
weaponSelectionMenu.AddMenuOption(weaponName, (player, option) => HandleWeaponSelection(player, option, classNamesByWeapon));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command to open the weapon selection menu for players
|
||||||
|
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) => OpenWeaponSelectionMenu(player, weaponSelectionMenu));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleWeaponSelection(CCSPlayerController? player, ChatMenuOption option, Dictionary<string, string> classNamesByWeapon)
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
@@ -220,14 +272,35 @@ namespace WeaponPaints
|
|||||||
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||||
skinSubMenu.PostSelectAction = PostSelectAction.Close;
|
skinSubMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
// Function to handle skin selection for the chosen weapon
|
// Add skin options to the submenu for the selected weapon
|
||||||
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
|
if (skinsForSelectedWeapon != null)
|
||||||
|
{
|
||||||
|
foreach (var skin in skinsForSelectedWeapon.Where(s => s != null))
|
||||||
|
{
|
||||||
|
if (skin.TryGetValue("paint_name", out var paintNameObj) && skin.TryGetValue("paint", out var paintObj))
|
||||||
|
{
|
||||||
|
var paintName = paintNameObj?.ToString();
|
||||||
|
var paint = paintObj?.ToString();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(paintName) && !string.IsNullOrEmpty(paint))
|
||||||
|
{
|
||||||
|
var optionText = new StringBuilder(paintName).Append(" (").Append(paint).Append(")").ToString();
|
||||||
|
skinSubMenu.AddMenuOption(optionText, (p, opt) => HandleSkinSelection(p, opt, selectedWeaponClassname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (player != null && Utility.IsPlayerValid(player))
|
||||||
|
MenuManager.OpenChatMenu(player, skinSubMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleSkinSelection(CCSPlayerController p, ChatMenuOption opt, string selectedWeaponClassname)
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(p)) return;
|
if (!Utility.IsPlayerValid(p)) return;
|
||||||
|
|
||||||
|
|
||||||
string steamId = p.SteamID.ToString();
|
string steamId = p.SteamID.ToString();
|
||||||
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
var firstSkin = skinsList?.Find(skin =>
|
||||||
{
|
{
|
||||||
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
||||||
{
|
{
|
||||||
@@ -244,6 +317,14 @@ namespace WeaponPaints
|
|||||||
weaponDefIndexObj != null &&
|
weaponDefIndexObj != null &&
|
||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
|
{
|
||||||
|
HandleSkinImage(p, weaponDefIndex, paintID);
|
||||||
|
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
UpdatePlayerWeaponInfo(p, weaponDefIndex, paintID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleSkinImage(CCSPlayerController p, int weaponDefIndex, int paintID)
|
||||||
{
|
{
|
||||||
if (Config.Additional.ShowSkinImage && skinsList != null)
|
if (Config.Additional.ShowSkinImage && skinsList != null)
|
||||||
{
|
{
|
||||||
@@ -256,9 +337,10 @@ namespace WeaponPaints
|
|||||||
PlayerWeaponImage[p.Slot] = image;
|
PlayerWeaponImage[p.Slot] = image;
|
||||||
AddTimer(2.0f, () => PlayerWeaponImage.Remove(p.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
AddTimer(2.0f, () => PlayerWeaponImage.Remove(p.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
private void UpdatePlayerWeaponInfo(CCSPlayerController p, int weaponDefIndex, int paintID)
|
||||||
|
{
|
||||||
if (!gPlayerWeaponsInfo[p.Slot].ContainsKey(weaponDefIndex))
|
if (!gPlayerWeaponsInfo[p.Slot].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex] = new WeaponInfo();
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex] = new WeaponInfo();
|
||||||
@@ -268,52 +350,13 @@ namespace WeaponPaints
|
|||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Wear = 0.00f;
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Wear = 0.00f;
|
||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Seed = 0;
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Seed = 0;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = p.UserId,
|
|
||||||
Index = (int)p.Index,
|
|
||||||
SteamId = p.SteamID.ToString(),
|
|
||||||
Name = p.PlayerName,
|
|
||||||
IpAddress = p.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
{
|
{
|
||||||
RefreshWeapons(player);
|
RefreshWeapons(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// Add skin options to the submenu for the selected weapon
|
private void OpenWeaponSelectionMenu(CCSPlayerController? player, ChatMenu weaponSelectionMenu)
|
||||||
if (skinsForSelectedWeapon != null)
|
|
||||||
{
|
|
||||||
foreach (var skin in skinsForSelectedWeapon.Where(s => s != null))
|
|
||||||
{
|
|
||||||
if (skin.TryGetValue("paint_name", out var paintNameObj) && skin.TryGetValue("paint", out var paintObj))
|
|
||||||
{
|
|
||||||
var paintName = paintNameObj?.ToString();
|
|
||||||
var paint = paintObj?.ToString();
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(paintName) && !string.IsNullOrEmpty(paint))
|
|
||||||
{
|
|
||||||
skinSubMenu.AddMenuOption($"{paintName} ({paint})", handleSkinSelection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player != null && Utility.IsPlayerValid(player))
|
|
||||||
MenuManager.OpenChatMenu(player, skinSubMenu);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add weapon options to the weapon selection menu
|
|
||||||
foreach (var weaponClass in weaponList.Keys)
|
|
||||||
{
|
|
||||||
string weaponName = weaponList[weaponClass];
|
|
||||||
weaponSelectionMenu.AddMenuOption(weaponName, handleWeaponSelection);
|
|
||||||
}
|
|
||||||
// Command to open the weapon selection menu for players
|
|
||||||
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
@@ -330,9 +373,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_command_cooldown"]);
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupGlovesMenu()
|
private void SetupGlovesMenu()
|
||||||
{
|
{
|
||||||
var glovesSelectionMenu = new ChatMenu(Localizer["wp_glove_menu_title"]);
|
var glovesSelectionMenu = new ChatMenu(Localizer["wp_glove_menu_title"]);
|
||||||
@@ -343,17 +384,24 @@ namespace WeaponPaints
|
|||||||
if (!Utility.IsPlayerValid(player) || player is null) return;
|
if (!Utility.IsPlayerValid(player) || player is null) return;
|
||||||
|
|
||||||
string selectedPaintName = option.Text;
|
string selectedPaintName = option.Text;
|
||||||
|
|
||||||
var selectedGlove = glovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
|
var selectedGlove = glovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
|
||||||
if (selectedGlove != null)
|
if (selectedGlove != null)
|
||||||
{
|
{
|
||||||
if (
|
HandleSelectedGlove(player, selectedGlove, selectedPaintName);
|
||||||
selectedGlove != null &&
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AddGloveOptionsToMenu(glovesSelectionMenu, handleGloveSelection);
|
||||||
|
AddCommandToOpenGloveSelectionMenu(glovesSelectionMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleSelectedGlove(CCSPlayerController? player, JObject selectedGlove, string selectedPaintName)
|
||||||
|
{
|
||||||
|
if (selectedGlove != null &&
|
||||||
selectedGlove.ContainsKey("weapon_defindex") &&
|
selectedGlove.ContainsKey("weapon_defindex") &&
|
||||||
selectedGlove.ContainsKey("paint") &&
|
selectedGlove.ContainsKey("paint") &&
|
||||||
int.TryParse(selectedGlove["weapon_defindex"]?.ToString(), out int weaponDefindex) &&
|
int.TryParse(selectedGlove["weapon_defindex"]?.ToString(), out int weaponDefindex) &&
|
||||||
int.TryParse(selectedGlove["paint"]?.ToString(), out int paint)
|
int.TryParse(selectedGlove["paint"]?.ToString(), out int paint))
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Config.Additional.ShowSkinImage)
|
if (Config.Additional.ShowSkinImage)
|
||||||
{
|
{
|
||||||
@@ -376,7 +424,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
g_playersGlove[player.Slot] = (ushort)weaponDefindex;
|
g_playersGlove[player.Slot] = (ushort)weaponDefindex;
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefindex))
|
if (!gPlayerWeaponsInfo[player.Slot].TryGetValue(weaponDefindex, out _))
|
||||||
{
|
{
|
||||||
WeaponInfo weaponInfo = new();
|
WeaponInfo weaponInfo = new();
|
||||||
weaponInfo.Paint = paint;
|
weaponInfo.Paint = paint;
|
||||||
@@ -393,30 +441,30 @@ namespace WeaponPaints
|
|||||||
player!.Print(Localizer["wp_glove_menu_select", selectedPaintName]);
|
player!.Print(Localizer["wp_glove_menu_select", selectedPaintName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await weaponSync.SyncGloveToDatabase(playerInfo, weaponDefindex);
|
await weaponSync.SyncGloveToDatabase(playerInfo, weaponDefindex);
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[playerInfo.Slot].ContainsKey(weaponDefindex))
|
if (!gPlayerWeaponsInfo[playerInfo.Slot].TryGetValue(weaponDefindex, out var weaponInfo))
|
||||||
{
|
{
|
||||||
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex] = new WeaponInfo();
|
weaponInfo = new WeaponInfo();
|
||||||
|
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex] = weaponInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Paint = paint;
|
weaponInfo.Paint = paint;
|
||||||
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Wear = 0.00f;
|
weaponInfo.Wear = 0.00f;
|
||||||
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Seed = 0;
|
weaponInfo.Seed = 0;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RefreshGloves(player);
|
RefreshGloves(player);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// Add weapon options to the weapon selection menu
|
private void AddGloveOptionsToMenu(ChatMenu glovesSelectionMenu, Action<CCSPlayerController?, ChatMenuOption> handleGloveSelection)
|
||||||
|
{
|
||||||
foreach (var gloveObject in glovesList)
|
foreach (var gloveObject in glovesList)
|
||||||
{
|
{
|
||||||
string paintName = gloveObject["paint_name"]?.ToString() ?? "";
|
string paintName = gloveObject["paint_name"]?.ToString() ?? "";
|
||||||
@@ -424,8 +472,10 @@ namespace WeaponPaints
|
|||||||
if (paintName.Length > 0)
|
if (paintName.Length > 0)
|
||||||
glovesSelectionMenu.AddMenuOption(paintName, handleGloveSelection);
|
glovesSelectionMenu.AddMenuOption(paintName, handleGloveSelection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Command to open the weapon selection menu for players
|
private void AddCommandToOpenGloveSelectionMenu(ChatMenu glovesSelectionMenu)
|
||||||
|
{
|
||||||
AddCommand($"css_{Config.Additional.CommandGlove}", "Gloves selection menu", (player, info) =>
|
AddCommand($"css_{Config.Additional.CommandGlove}", "Gloves selection menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user