1.6.4a
- New give command - Added `@css/permmute` flag to allow perm penalties - Fixed mute when player silenced - Added CleanModule - allow to clean weapons on ground
This commit is contained in:
parent
d30ac80a36
commit
5a9367ae89
17 changed files with 193 additions and 27 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System.Globalization;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Translations;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
|
|
@ -15,9 +14,11 @@ using Microsoft.Extensions.Logging;
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||
using CS2_SimpleAdmin.Managers;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
|
|
@ -625,4 +626,47 @@ public static class Time
|
|||
return utcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class WeaponHelper
|
||||
{
|
||||
private static readonly Lazy<Dictionary<string, CsItem>> WeaponsEnumCache = new(BuildEnumMemberMap);
|
||||
|
||||
private static Dictionary<string, CsItem> BuildEnumMemberMap()
|
||||
{
|
||||
var dictionary = new Dictionary<string, CsItem>();
|
||||
|
||||
foreach (var field in typeof(CsItem).GetFields(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
var attribute = field.GetCustomAttribute<EnumMemberAttribute>();
|
||||
if (attribute?.Value == null) continue;
|
||||
if (field.GetValue(null) is not CsItem csItem)
|
||||
continue;
|
||||
var enumValue = field.GetValue(null);
|
||||
|
||||
dictionary.TryAdd(attribute.Value, csItem);
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public static CsItem? GetEnumFromWeaponName(string weaponName)
|
||||
{
|
||||
if (WeaponsEnumCache.Value.TryGetValue(weaponName, out var csItem))
|
||||
{
|
||||
return csItem;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<(string EnumMemberValue, CsItem EnumValue)> GetWeaponsByPartialName(string input)
|
||||
{
|
||||
var matchingWeapons = WeaponsEnumCache.Value
|
||||
.Where(kvp => kvp.Key.Contains(input))
|
||||
.Select(kvp => (kvp.Key, kvp.Value))
|
||||
.ToList();
|
||||
|
||||
return matchingWeapons;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue