File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
SwiftlyS2.Core/Modules/Helpers
SwiftlyS2.Shared/Modules/Helpers Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ namespace SwiftlyS2.Core.Services;
77
88internal class HelpersService : IHelpers
99{
10- private static readonly Dictionary < string , int > WeaponItemDefinitionIndices = new ( )
10+ public static readonly Dictionary < string , int > WeaponItemDefinitionIndices = new ( )
1111 {
1212 // Pistols
1313 { "weapon_deagle" , 1 } ,
@@ -105,4 +105,25 @@ internal class HelpersService : IHelpers
105105 return GetWeaponCSDataFromKey ( - 1 , itemDefinitionIndex . ToString ( ) ) ;
106106 }
107107
108+ public string ? GetClassnameByDefinitionIndex ( int itemDefinitionIndex )
109+ {
110+ foreach ( var kvp in WeaponItemDefinitionIndices )
111+ {
112+ if ( kvp . Value == itemDefinitionIndex )
113+ {
114+ return kvp . Key ;
115+ }
116+ }
117+ return null ;
118+ }
119+
120+ public int ? GetDefinitionIndexByClassname ( string classname )
121+ {
122+ if ( WeaponItemDefinitionIndices . TryGetValue ( classname , out int index ) )
123+ {
124+ return index ;
125+ }
126+ return null ;
127+ }
128+
108129}
Original file line number Diff line number Diff line change @@ -102,5 +102,18 @@ public interface IHelpers
102102 /// <returns>The weapon vdata.</returns>
103103 public CCSWeaponBaseVData ? GetWeaponCSDataFromKey ( int itemDefinitionIndex ) ;
104104
105+ /// <summary>
106+ /// Get weapon classname from item definition index.
107+ /// </summary>
108+ /// <param name="itemDefinitionIndex">The item definition index of the weapon.</param>
109+ /// <returns>The weapon classname (e.g., "weapon_awp") or null if not found.</returns>
110+ public string ? GetClassnameByDefinitionIndex ( int itemDefinitionIndex ) ;
111+
112+ /// <summary>
113+ /// Get item definition index from weapon classname.
114+ /// </summary>
115+ /// <param name="classname">The weapon classname (e.g., "weapon_awp").</param>
116+ /// <returns>The item definition index or null if not found.</returns>
117+ public int ? GetDefinitionIndexByClassname ( string classname ) ;
105118
106119}
You can’t perform that action at this time.
0 commit comments