mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
1.6.6a
```diff + Reapply gravity/speed with timer + Added shake effect for slap + Fixed css_gravity and css_speed command + Fixed css_give command, for example weapon_knife returns weapon_knife instead of weapon_knife and weapon_knife_t + Small code improvements ```
This commit is contained in:
@@ -690,11 +690,30 @@ public static class WeaponHelper
|
||||
|
||||
public static List<(string EnumMemberValue, CsItem EnumValue)> GetWeaponsByPartialName(string input)
|
||||
{
|
||||
// Normalize input for case-insensitive comparison
|
||||
var normalizedInput = input.ToLowerInvariant();
|
||||
|
||||
// Find all matching weapons based on the input
|
||||
var matchingWeapons = WeaponsEnumCache.Value
|
||||
.Where(kvp => kvp.Key.Contains(input))
|
||||
.Select(kvp => (kvp.Key, kvp.Value))
|
||||
.Where(kvp => kvp.Key.Contains(normalizedInput, StringComparison.InvariantCultureIgnoreCase))
|
||||
.Select(kvp => (EnumMemberValue: kvp.Key, EnumValue: kvp.Value))
|
||||
.ToList();
|
||||
|
||||
return matchingWeapons;
|
||||
// Check for an exact match first
|
||||
var exactMatch = matchingWeapons
|
||||
.FirstOrDefault(m => m.EnumMemberValue.Equals(input, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (exactMatch.EnumMemberValue != null)
|
||||
{
|
||||
// Return a list containing only the exact match
|
||||
return [exactMatch];
|
||||
}
|
||||
|
||||
// If no exact match, get all matches that start with the input
|
||||
var filteredWeapons = matchingWeapons
|
||||
.Where(m => m.EnumMemberValue.StartsWith(normalizedInput, StringComparison.InvariantCultureIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
return filteredWeapons; // Return all relevant matches for the partial input
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user