├── .github └── workflows │ ├── build.yml │ └── release.yml ├── .idea └── .idea.CSSKin │ └── .idea │ ├── .gitignore │ ├── encodings.xml │ ├── indexLayout.xml │ └── vcs.xml ├── CSSKin.sln ├── CSSKin ├── .gitignore ├── CSSKin.csproj ├── CSSkin.cs ├── Core │ ├── Configs │ │ └── BaseConfig.cs │ ├── Enums │ │ └── DatabaseType.cs │ ├── Services │ │ ├── IServiceRepository.cs │ │ ├── WeaponServerMysqlRepository.cs │ │ └── WeaponServiceCollectionRepository.cs │ └── Utilities │ │ └── ConstantsWeapon.cs ├── Models │ └── WeaponInfo.cs └── SkinBridge │ └── addons │ ├── SkinBridge │ └── SkinBridge.so │ └── metamod │ └── SkinBridge.vdf └── README.md /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | paths-ignore: 7 | - '**/README.md' 8 | - '**/.gitignore' 9 | - '**/LICENSE' 10 | - '.github/**' 11 | pull_request: 12 | branches: [ "master" ] 13 | paths-ignore: 14 | - '**/README.md' 15 | - '**/.gitignore' 16 | - '**/LICENSE' 17 | - '.github/**' 18 | env: 19 | BUILD_NUMBER: ${{ github.run_number }} 20 | PROJECT_PATH: "./CSSKin/CSSKin.csproj" 21 | PROJECT_NAME: "CSSKin" 22 | OUTPUT_PATH: "./CSSKin" 23 | 24 | jobs: 25 | build: 26 | permissions: write-all 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - uses: actions/checkout@v3 31 | - name: Setup .NET 32 | uses: actions/setup-dotnet@v3 33 | with: 34 | dotnet-version: 7.0.x 35 | - name: Restore 36 | run: dotnet restore 37 | - name: Build 38 | run: dotnet build ${{ env.PROJECT_PATH }} -c CSSKin -o ${{ env.OUTPUT_PATH }} 39 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | env: 9 | BUILD_NUMBER: ${{ github.run_number }} 10 | PROJECT_PATH: "./CSSKin/CSSKin.csproj" 11 | PROJECT_NAME: "CSSKin" 12 | OUTPUT_PATH: "./CSSKin" 13 | 14 | jobs: 15 | build: 16 | permissions: write-all 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@v3 21 | - name: Setup .NET 22 | uses: actions/setup-dotnet@v3 23 | with: 24 | dotnet-version: 7.0.x 25 | - name: Restore 26 | run: dotnet restore 27 | - name: Build 28 | run: dotnet build ${{ env.PROJECT_PATH }} -c CSSKin -o ${{ env.OUTPUT_PATH }} 29 | 30 | publish: 31 | permissions: write-all 32 | runs-on: ubuntu-latest 33 | needs: build 34 | steps: 35 | - uses: actions/checkout@v3 36 | with: 37 | fetch-depth: 0 38 | - name: Setup .NET 39 | uses: actions/setup-dotnet@v3 40 | with: 41 | dotnet-version: 7.0.x 42 | - name: Restore 43 | run: dotnet restore 44 | - name: Build 45 | run: dotnet build ${{ env.PROJECT_PATH }} -c CSSKin -o ${{ env.OUTPUT_PATH }} 46 | - name: Clean files 47 | run: | 48 | rm -f \ 49 | ${{ env.OUTPUT_PATH }}/CounterStrikeSharp.API.dll \ 50 | ${{ env.OUTPUT_PATH }}/McMaster.NETCore.Plugins.dll \ 51 | ${{ env.OUTPUT_PATH }}/Microsoft.DotNet.PlatformAbstractions.dll \ 52 | ${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll \ 53 | - name: Zip 54 | uses: thedoctor0/zip-release@0.7.5 55 | with: 56 | type: 'zip' 57 | filename: '${{ env.PROJECT_NAME }}.zip' 58 | path: ${{ env.OUTPUT_PATH }} 59 | - name: Upload Release 60 | uses: ncipollo/release-action@v1.12.0 61 | with: 62 | artifacts: "CSSKin.zip" 63 | token: ${{ secrets.TOKEN }} 64 | -------------------------------------------------------------------------------- /.idea/.idea.CSSKin/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /.idea.CSSKin.iml 6 | /modules.xml 7 | /contentModel.xml 8 | /projectSettingsUpdater.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /.idea/.idea.CSSKin/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.CSSKin/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.CSSKin/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CSSKin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSSKin", "CSSKin\CSSKin.csproj", "{4CD89DBD-81A7-48BC-B1A7-7BDC4FC103B9}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {4CD89DBD-81A7-48BC-B1A7-7BDC4FC103B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {4CD89DBD-81A7-48BC-B1A7-7BDC4FC103B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {4CD89DBD-81A7-48BC-B1A7-7BDC4FC103B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {4CD89DBD-81A7-48BC-B1A7-7BDC4FC103B9}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /CSSKin/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | [Bb]in/ 15 | [Oo]bj/ 16 | 17 | # MSTest test Results 18 | [Tt]est[Rr]esult*/ 19 | [Bb]uild[Ll]og.* 20 | 21 | *_i.c 22 | *_p.c 23 | *_i.h 24 | *.ilk 25 | *.meta 26 | *.obj 27 | *.pch 28 | *.pdb 29 | *.pgc 30 | *.pgd 31 | *.rsp 32 | *.sbr 33 | *.tlb 34 | *.tli 35 | *.tlh 36 | *.tmp 37 | *.tmp_proj 38 | *.log 39 | *.vspscc 40 | *.vssscc 41 | .builds 42 | *.pidb 43 | *.log 44 | *.svclog 45 | *.scc 46 | 47 | # Visual C++ cache files 48 | ipch/ 49 | *.aps 50 | *.ncb 51 | *.opensdf 52 | *.sdf 53 | *.cachefile 54 | 55 | # Visual Studio profiler 56 | *.psess 57 | *.vsp 58 | *.vspx 59 | 60 | # Guidance Automation Toolkit 61 | *.gpState 62 | 63 | # ReSharper is a .NET coding add-in 64 | _ReSharper*/ 65 | *.[Rr]e[Ss]harper 66 | *.DotSettings.user 67 | 68 | # Click-Once directory 69 | publish/ 70 | 71 | # Publish Web Output 72 | *.Publish.xml 73 | *.pubxml 74 | *.azurePubxml 75 | 76 | # NuGet Packages Directory 77 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 78 | packages/ 79 | ## TODO: If the tool you use requires repositories.config, also uncomment the next line 80 | !packages/repositories.config 81 | 82 | # Windows Azure Build Output 83 | csx/ 84 | *.build.csdef 85 | 86 | # Windows Store app package directory 87 | AppPackages/ 88 | 89 | # Others 90 | sql/ 91 | *.Cache 92 | ClientBin/ 93 | [Ss]tyle[Cc]op.* 94 | ![Ss]tyle[Cc]op.targets 95 | ~$* 96 | *~ 97 | *.dbmdl 98 | *.[Pp]ublish.xml 99 | 100 | *.publishsettings 101 | 102 | # RIA/Silverlight projects 103 | Generated_Code/ 104 | 105 | # Backup & report files from converting an old project file to a newer 106 | # Visual Studio version. Backup files are not needed, because we have git ;-) 107 | _UpgradeReport_Files/ 108 | Backup*/ 109 | UpgradeLog*.XML 110 | UpgradeLog*.htm 111 | 112 | # SQL Server files 113 | App_Data/*.mdf 114 | App_Data/*.ldf 115 | 116 | # ========================= 117 | # Windows detritus 118 | # ========================= 119 | 120 | # Windows image file caches 121 | Thumbs.db 122 | ehthumbs.db 123 | 124 | # Folder config file 125 | Desktop.ini 126 | 127 | # Recycle Bin used on file shares 128 | $RECYCLE.BIN/ 129 | 130 | # Mac desktop service store files 131 | .DS_Store 132 | 133 | _NCrunch* -------------------------------------------------------------------------------- /CSSKin/CSSKin.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CSSKin/CSSkin.cs: -------------------------------------------------------------------------------- 1 | using CounterStrikeSharp.API; 2 | using CounterStrikeSharp.API.Core; 3 | using CounterStrikeSharp.API.Core.Attributes.Registration; 4 | using CounterStrikeSharp.API.Modules.Commands; 5 | using CounterStrikeSharp.API.Modules.Memory; 6 | using CSSKin.Core.Configs; 7 | using CSSKin.Core.Enums; 8 | using CSSKin.Core.Services; 9 | using CSSKin.Core.Utilities; 10 | using CSSKin.Models; 11 | using Microsoft.Extensions.Logging; 12 | 13 | namespace CSSKin; 14 | 15 | public class CSSkin : BasePlugin, IPluginConfig 16 | { 17 | public override string ModuleName => "CsSkin"; 18 | public override string ModuleVersion => "1.0.4"; 19 | public BaseConfig Config { get; set; } 20 | private Dictionary> g_PlayersWeapons = new(); 21 | private IServiceRepository _usersService; 22 | 23 | public void OnConfigParsed(BaseConfig config) 24 | { 25 | Config = config; 26 | } 27 | 28 | 29 | public override void Load(bool hotReload) 30 | { 31 | Logger.LogInformation("Plugin loaded"); 32 | 33 | switch (Config.DbType) 34 | { 35 | case nameof(DatabaseType.MYSQL): 36 | _usersService = new WeaponServerMysqlRepository(Config.ConnectionString, Config.MysqlTableName); 37 | break; 38 | case nameof(DatabaseType.MONGODB): 39 | _usersService = 40 | new WeaponServiceCollectionRepository(Config.ConnectionString, Config.MongoDatabaseName); 41 | break; 42 | } 43 | 44 | 45 | RegisterListener((slot) => 46 | { 47 | var player = Utilities.GetPlayerFromSlot(slot); 48 | var skins = _usersService.Get(player.SteamID.ToString()); 49 | if (!g_PlayersWeapons.TryAdd(player.SteamID, 50 | skins != null ? skins.ToList() : new List())) 51 | { 52 | g_PlayersWeapons[player.SteamID] = skins != null ? skins.ToList() : new List(); 53 | } 54 | }); 55 | 56 | RegisterListener(slot => 57 | { 58 | var player = Utilities.GetPlayerFromSlot(slot); 59 | g_PlayersWeapons[player.SteamID] = new List(); 60 | }); 61 | 62 | RegisterListener(entity => { }); 63 | 64 | RegisterListener(entity => 65 | { 66 | CBasePlayerWeapon? pBasePlayerWeapon = new(entity.Handle); 67 | CEconEntity pCEconEntityWeapon = new(entity.Handle); 68 | 69 | Server.NextFrame(() => 70 | { 71 | if (pCEconEntityWeapon != null && pCEconEntityWeapon.DesignerName != null && 72 | pCEconEntityWeapon.DesignerName.StartsWith("weapon_")) 73 | { 74 | string designerName = pCEconEntityWeapon.DesignerName; 75 | bool isKnife = designerName.Contains("knife") || designerName.Contains("bayonet"); 76 | bool isWeapon = designerName.Contains("weapon_") && !isKnife; 77 | 78 | ushort weaponId = pCEconEntityWeapon.AttributeManager.Item.ItemDefinitionIndex; 79 | int weaponOwner = (int)pBasePlayerWeapon.OwnerEntity.Index; 80 | 81 | CBasePlayerPawn pBasePlayerPawn = 82 | new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner)); 83 | 84 | if (!pBasePlayerPawn.IsValid) return; 85 | 86 | var playerIndex = (int)pBasePlayerPawn.Controller.Index; 87 | var player = Utilities.GetPlayerFromIndex(playerIndex); 88 | g_PlayersWeapons.TryGetValue(player.SteamID, out List? weaponsInfo); 89 | var requestWeapon = weaponsInfo?.FirstOrDefault(c => 90 | c.DefIndex == weaponId && !isKnife || 91 | isKnife && ConstantsWeapon.g_KnivesMap.ContainsValue(designerName)); 92 | if (requestWeapon != null) 93 | { 94 | var weaponInfo = weaponsInfo.FirstOrDefault(weapon => 95 | (weaponId == weapon.DefIndex && isWeapon && !isKnife) || 96 | ConstantsWeapon.g_KnivesMap.ContainsKey(weaponId)); 97 | pCEconEntityWeapon.FallbackPaintKit = weaponInfo.Paint; 98 | pCEconEntityWeapon.FallbackSeed = weaponInfo.Seed; 99 | pCEconEntityWeapon.FallbackWear = (float)weaponInfo.Wear; 100 | pCEconEntityWeapon.FallbackStatTrak = -1; 101 | 102 | pCEconEntityWeapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)weaponInfo.DefIndex; 103 | 104 | pCEconEntityWeapon.AttributeManager.Item.ItemID = 16384; 105 | pCEconEntityWeapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF; 106 | pCEconEntityWeapon.AttributeManager.Item.ItemIDHigh = 16384 >> 32; 107 | 108 | if (pBasePlayerWeapon.CBodyComponent is { SceneNode: not null }) 109 | { 110 | var skeleton = GetSkeletonInstance(pBasePlayerWeapon.CBodyComponent.SceneNode); 111 | skeleton.ModelState.MeshGroupMask = 2; 112 | } 113 | 114 | if (ConstantsWeapon.g_KnivesMap.ContainsKey(weaponId)) 115 | { 116 | Server.ExecuteCommand($"i_subclass_change {weaponInfo.DefIndex} {entity.Index}"); 117 | } 118 | } 119 | } 120 | }); 121 | }); 122 | 123 | RegisterListener((entity, parent) => { }); 124 | 125 | RegisterListener(entity => { }); 126 | 127 | base.Load(hotReload); 128 | } 129 | 130 | private static CSkeletonInstance GetSkeletonInstance(CGameSceneNode node) 131 | { 132 | Func GetSkeletonInstance = VirtualFunction.Create(node.Handle, 8); 133 | return new CSkeletonInstance(GetSkeletonInstance(node.Handle)); 134 | } 135 | 136 | // Commands can also be registered using the `Command` attribute. 137 | [ConsoleCommand("css_skin", "Get skin")] 138 | // The `CommandHelper` attribute can be used to provide additional information about the command. 139 | [CommandHelper(minArgs: 1, usage: "[defIndex] [paintId] [seed]", whoCanExecute: CommandUsage.CLIENT_ONLY)] 140 | public void OnCssSkinCommand(CCSPlayerController? player, CommandInfo commandInfo) 141 | { 142 | var defIndex = int.Parse(commandInfo.GetArg(1)); 143 | var paintId = int.Parse(commandInfo.GetArg(2)); 144 | var seed = int.Parse(commandInfo.GetArg(3)); 145 | 146 | ulong playerSteamId = player!.SteamID; 147 | 148 | bool isKnife = ConstantsWeapon.g_KnivesMap.ContainsKey(defIndex); 149 | bool isWeapon = ConstantsWeapon.g_WeaponsMap.ContainsKey(defIndex); 150 | 151 | 152 | if (!player.IsValid || player.Index <= 0) return; 153 | 154 | var skins = _usersService.Get(playerSteamId.ToString()).ToList(); 155 | 156 | if (isKnife) 157 | { 158 | var skin = skins.FirstOrDefault(data => data.IsKnife); 159 | if (skin != null) 160 | { 161 | skin.DefIndex = defIndex; 162 | skin.Paint = paintId; 163 | skin.Wear = 0.00000001f; 164 | skin.Seed = seed; 165 | skin.IsKnife = true; 166 | skin.steamid = player.SteamID.ToString(); 167 | _usersService.Update(skin); 168 | } 169 | else 170 | { 171 | var newSkin = new WeaponInfo() 172 | { 173 | steamid = playerSteamId.ToString(), 174 | Seed = seed, 175 | Wear = 0.00000001f, 176 | IsKnife = true, 177 | DefIndex = defIndex, 178 | Paint = paintId 179 | }; 180 | _usersService.Create(newSkin); 181 | } 182 | } 183 | 184 | if (isWeapon) 185 | { 186 | var skin = skins.FirstOrDefault(data => data.DefIndex == defIndex); 187 | if (skin != null) 188 | { 189 | skin.DefIndex = defIndex; 190 | skin.Paint = paintId; 191 | skin.Wear = 0.00000001f; 192 | skin.Seed = seed; 193 | skin.IsKnife = false; 194 | skin.steamid = player.SteamID.ToString(); 195 | _usersService.Update(skin); 196 | } 197 | else 198 | { 199 | var newSkin = new WeaponInfo() 200 | { 201 | steamid = playerSteamId.ToString(), 202 | Seed = seed, 203 | Wear = 0.00000001f, 204 | IsKnife = false, 205 | DefIndex = defIndex, 206 | Paint = paintId 207 | }; 208 | _usersService.Create(newSkin); 209 | } 210 | } 211 | 212 | g_PlayersWeapons[playerSteamId] = _usersService.Get(playerSteamId.ToString()).ToList(); 213 | 214 | var weapons = player.PlayerPawn.Value?.WeaponServices.MyWeapons; 215 | 216 | foreach (var weaponData in weapons) 217 | { 218 | if (weaponData.IsValid && weaponData.Value != null) 219 | { 220 | if (ConstantsWeapon.g_KnivesMap.ContainsKey(weaponData.Value.AttributeManager.Item 221 | .ItemDefinitionIndex) || ConstantsWeapon.g_WeaponsMap.ContainsKey(weaponData.Value 222 | .AttributeManager.Item 223 | .ItemDefinitionIndex)) 224 | { 225 | if (isWeapon) 226 | { 227 | player.RemoveItemByDesignerName(weaponData.Value.DesignerName, true); 228 | } 229 | 230 | if (isKnife) 231 | { 232 | player.RemoveItemByDesignerName("weapon_knife", true); 233 | } 234 | } 235 | } 236 | } 237 | 238 | if (ConstantsWeapon.g_WeaponsMap.TryGetValue(defIndex, out string weapon_name)) 239 | { 240 | player.GiveNamedItem(weapon_name); 241 | } 242 | 243 | if (ConstantsWeapon.g_KnivesMap.ContainsKey(defIndex)) 244 | { 245 | player.GiveNamedItem("weapon_knife"); 246 | } 247 | } 248 | } -------------------------------------------------------------------------------- /CSSKin/Core/Configs/BaseConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using CounterStrikeSharp.API.Core; 3 | using CSSKin.Core.Enums; 4 | 5 | namespace CSSKin.Core.Configs; 6 | 7 | public class BaseConfig : IBasePluginConfig 8 | { 9 | public string ConnectionString { get; set; } = ""; 10 | public string MongoDatabaseName { get; set; } = ""; 11 | public string MysqlTableName { get; set; } = ""; 12 | [JsonPropertyName("DatabaseType")] 13 | public string DbType { get; set; } = Enum.GetName(DatabaseType.MONGODB); 14 | public int Version { get; set; } 15 | } -------------------------------------------------------------------------------- /CSSKin/Core/Enums/DatabaseType.cs: -------------------------------------------------------------------------------- 1 | namespace CSSKin.Core.Enums; 2 | 3 | public enum DatabaseType 4 | { 5 | MONGODB, 6 | MYSQL 7 | } -------------------------------------------------------------------------------- /CSSKin/Core/Services/IServiceRepository.cs: -------------------------------------------------------------------------------- 1 | namespace CSSKin.Core.Services; 2 | 3 | public interface IServiceRepository 4 | { 5 | T Create(T data); 6 | void Delete(string uuid); 7 | IEnumerable Get(); 8 | IEnumerable? Get(string uuid); 9 | void Update(T data); 10 | } -------------------------------------------------------------------------------- /CSSKin/Core/Services/WeaponServerMysqlRepository.cs: -------------------------------------------------------------------------------- 1 | using CSSKin.Models; 2 | using Dapper; 3 | using MySqlConnector; 4 | 5 | namespace CSSKin.Core.Services; 6 | 7 | public class WeaponServerMysqlRepository : IServiceRepository 8 | { 9 | private MySqlConnection _connection; 10 | private MySqlCommand _command; 11 | private string TableName; 12 | 13 | public WeaponServerMysqlRepository(string connectionString, string tableName) 14 | { 15 | TableName = tableName; 16 | _connection = new MySqlConnection(connectionString); 17 | _connection.Open(); 18 | _connection.Query( 19 | $"CREATE TABLE IF NOT EXISTS {TableName} (Id BIGINT PRIMARY KEY auto_increment,DefIndex INT,Paint INT, Seed INT, Wear DOUBLE NOT NULL, IsKnife BOOLEAN NOT NULL, steamid VARCHAR(255) NOT NULL);"); 20 | _connection.Close(); 21 | } 22 | 23 | public WeaponInfo Create(WeaponInfo data) 24 | { 25 | _connection.Open(); 26 | var newEntityId = _connection.QuerySingle( 27 | $"INSERT INTO {TableName} (DefIndex, Paint, Seed, Wear, IsKnife, steamid) VALUES ({data.DefIndex}, {data.Paint}, {data.Seed}, {data.Wear}, {data.IsKnife}, '{data.steamid}');"); 28 | _connection.Close(); 29 | return Get(data.steamid).First(c => c.Id == newEntityId); 30 | } 31 | 32 | public void Delete(string uuid) 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | 37 | public IEnumerable Get() 38 | { 39 | _connection.Open(); 40 | List skins = _connection.Query($"SELECT * FROM {TableName}").ToList(); 41 | _connection.Close(); 42 | return skins; 43 | } 44 | 45 | public IEnumerable? Get(string uuid) 46 | { 47 | _connection.Open(); 48 | List skins = _connection.Query($"SELECT * FROM {TableName}").Where(data => data.steamid == uuid).ToList(); 49 | _connection.Close(); 50 | return skins; 51 | } 52 | 53 | public void Update(WeaponInfo data) 54 | { 55 | _connection.Open(); 56 | _connection.Query( 57 | $"UPDATE {TableName} SET DefIndex = {data.DefIndex},Paint = {data.Paint},Seed = {data.Seed},Wear = {data.Wear},IsKnife = {data.IsKnife},steamid = '{data.steamid}' WHERE Id = {data.Id};"); 58 | _connection.Close(); 59 | } 60 | } -------------------------------------------------------------------------------- /CSSKin/Core/Services/WeaponServiceCollectionRepository.cs: -------------------------------------------------------------------------------- 1 | using CSSKin.Models; 2 | using MongoDB.Bson; 3 | using MongoDB.Driver; 4 | 5 | namespace CSSKin.Core.Services; 6 | 7 | public class WeaponServiceCollectionRepository : IServiceRepository 8 | { 9 | private readonly IMongoCollection mongoCollection; 10 | 11 | public WeaponServiceCollectionRepository(string connectionString, string databaseName) 12 | { 13 | var client = new MongoClient(connectionString); 14 | client.StartSession(); 15 | var database = client.GetDatabase(databaseName); 16 | 17 | mongoCollection = database.GetCollection("UserSkins"); 18 | } 19 | 20 | 21 | public WeaponInfo Create(WeaponInfo data) 22 | { 23 | var index = mongoCollection.CountDocuments(new BsonDocument()) + 1; 24 | data.Id = index; 25 | mongoCollection.InsertOne(data); 26 | return data; 27 | } 28 | 29 | public void Delete(string uuid) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | public IEnumerable Get() 35 | { 36 | return mongoCollection.Find(data => true).ToEnumerable(); 37 | } 38 | 39 | public IEnumerable? Get(string uuid) 40 | { 41 | return mongoCollection.Find(data => data.steamid == uuid).ToEnumerable();; 42 | } 43 | 44 | public void Update(WeaponInfo data) 45 | { 46 | mongoCollection.ReplaceOne(Data => Data.Id == data.Id, data); 47 | } 48 | } -------------------------------------------------------------------------------- /CSSKin/Core/Utilities/ConstantsWeapon.cs: -------------------------------------------------------------------------------- 1 | namespace CSSKin.Core.Utilities; 2 | 3 | public class ConstantsWeapon 4 | { 5 | internal static Dictionary g_WeaponsMap = new() 6 | { 7 | { 1, "weapon_deagle" }, 8 | { 2, "weapon_elite" }, 9 | { 3, "weapon_fiveseven" }, 10 | { 4, "weapon_glock" }, 11 | { 7, "weapon_ak47" }, 12 | { 8, "weapon_aug" }, 13 | { 9, "weapon_awp" }, 14 | { 10, "weapon_famas" }, 15 | { 11, "weapon_g3sg1" }, 16 | { 13, "weapon_galilar" }, 17 | { 14, "weapon_m249" }, 18 | { 16, "weapon_m4a1" }, 19 | { 17, "weapon_mac10" }, 20 | { 19, "weapon_p90" }, 21 | { 23, "weapon_mp5sd" }, 22 | { 24, "weapon_ump45" }, 23 | { 25, "weapon_xm1014" }, 24 | { 26, "weapon_bizon" }, 25 | { 27, "weapon_mag7" }, 26 | { 28, "weapon_negev" }, 27 | { 29, "weapon_sawedoff" }, 28 | { 30, "weapon_tec9" }, 29 | { 32, "weapon_hkp2000" }, 30 | { 33, "weapon_mp7" }, 31 | { 34, "weapon_mp9" }, 32 | { 35, "weapon_nova" }, 33 | { 36, "weapon_p250" }, 34 | { 38, "weapon_scar20" }, 35 | { 39, "weapon_sg556" }, 36 | { 40, "weapon_ssg08" }, 37 | { 60, "weapon_m4a1_silencer" }, 38 | { 61, "weapon_usp_silencer" }, 39 | { 63, "weapon_cz75a" }, 40 | { 64, "weapon_revolver" } 41 | }; 42 | 43 | internal static Dictionary g_KnivesMap = new() 44 | { 45 | { 42, "weapon_knife" }, 46 | { 59, "weapon_knife" }, 47 | { 500, "weapon_bayonet" }, 48 | { 503, "weapon_knife_css" }, 49 | { 505, "weapon_knife_flip" }, 50 | { 506, "weapon_knife_gut" }, 51 | { 507, "weapon_knife_karambit" }, 52 | { 508, "weapon_knife_m9_bayonet" }, 53 | { 509, "weapon_knife_tactical" }, 54 | { 512, "weapon_knife_falchion" }, 55 | { 514, "weapon_knife_survival_bowie" }, 56 | { 515, "weapon_knife_butterfly" }, 57 | { 516, "weapon_knife_push" }, 58 | { 517, "weapon_knife_cord" }, 59 | { 518, "weapon_knife_canis" }, 60 | { 519, "weapon_knife_ursus" }, 61 | { 520, "weapon_knife_gypsy_jackknife" }, 62 | { 521, "weapon_knife_outdoor" }, 63 | { 522, "weapon_knife_stiletto" }, 64 | { 523, "weapon_knife_widowmaker" }, 65 | { 525, "weapon_knife_skeleton" }, 66 | { 526, "weapon_knife_kukri" } 67 | }; 68 | } -------------------------------------------------------------------------------- /CSSKin/Models/WeaponInfo.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using MongoDB.Bson.Serialization.Attributes; 3 | 4 | namespace CSSKin.Models; 5 | 6 | public class WeaponInfo 7 | { 8 | [BsonId] 9 | public long Id { get; set; } 10 | public int DefIndex { get; set; } 11 | public int Paint { get; set; } 12 | public int Seed { get; set; } 13 | public double Wear { get; set; } 14 | public bool IsKnife { get; set; } 15 | public string steamid { get; set; } 16 | } -------------------------------------------------------------------------------- /CSSKin/SkinBridge/addons/SkinBridge/SkinBridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dyshay/CS2Skin/9c793a246fdb7ef659c85c5003b641af577e0df1/CSSKin/SkinBridge/addons/SkinBridge/SkinBridge.so -------------------------------------------------------------------------------- /CSSKin/SkinBridge/addons/metamod/SkinBridge.vdf: -------------------------------------------------------------------------------- 1 | "Metamod Plugin" 2 | { 3 | "alias" "SkinBridge" 4 | "file" "addons/SkinBridge/SkinBridge" 5 | } 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CS2 Skin 2 | 3 | CS2 Skin: A simple plugin for effortless weapon skin customization in Counter-Strike 2 4 | # Features 5 | 6 | - Weapons 7 | - Knife 8 | 9 | ### Requirements 10 | 11 | - [Metamod:Source](https://www.sourcemm.net/downloads.php/?branch=master) (build 1219 or higher) 12 | - [CounterStrikeSharp](https://github.com/roflmuffin/CounterStrikeSharp/releases/latest) (1.0.153) 13 | - [MongoDB](https://www.mongodb.com/) or [MySql]() 14 | - [SkinBridge](https://github.com/Dyshay/CS2Skin/tree/master/CSSKin/SkinBridge/addons) 15 | 16 | ### Instructions 17 | 18 | - In **`addons/counterstrikesharp/configs/core.json`** set **FollowCS2ServerGuidelines** to **`false`** 19 | - In **`addons`** move SkinBridge 20 | 21 | 22 | ### Config 23 |
{
24 |   "ConnectionString": "", //"Server=host;Database=dbName;Uid=userName;Pwd=password;Port=3306;" (For MySQL)
25 |   "MongoDatabaseName": "", // If you use mongoDB
26 |   "MysqlTableName": "", // MySqlTableName
27 |   "DatabaseType": "MYSQL", // "MYSQL" or "MONGODB"
28 |   "Version": 0  // Don't touch
29 | }
30 | 31 | ### Give Weapon 32 | 33 | - You can use console command : css_skin {defIndex} {paintId} {seed} {wear} 34 | --------------------------------------------------------------------------------