diff --git a/Store/src/cs2-store.cs b/Store/src/cs2-store.cs index b4a6002..07df24c 100644 --- a/Store/src/cs2-store.cs +++ b/Store/src/cs2-store.cs @@ -9,7 +9,7 @@ namespace Store; public class Store : BasePlugin, IPluginConfig { public override string ModuleName => "Store"; - public override string ModuleVersion => "1.3"; + public override string ModuleVersion => "1.4"; public override string ModuleAuthor => "schwarper"; public Item_Config Config { get; set; } = new Item_Config(); diff --git a/Store/src/item/items/playerskin.cs b/Store/src/item/items/playerskin.cs index b7ce7c7..eada5ee 100644 --- a/Store/src/item/items/playerskin.cs +++ b/Store/src/item/items/playerskin.cs @@ -56,7 +56,9 @@ public static bool OnEquip(CCSPlayerController player, Dictionary p.SteamID == player.SteamID && p.Type == "playerskin" && (p.Slot == teamnum || p.Slot == 1)); @@ -206,7 +208,7 @@ private static (string modelname, bool disableleg)? GetModel(CCSPlayerController } } - private static (string modelname, bool disableleg)? GetDefaultModel(CCSPlayerController player) + private static (string modelname, bool disableleg, string? skin)? GetDefaultModel(CCSPlayerController player) { string[] modelsArray = player.Team == CsTeam.CounterTerrorist ? Config.DefaultModels.CounterTerrorist : Config.DefaultModels.Terrorist; int maxIndex = modelsArray.Length; @@ -217,13 +219,13 @@ private static (string modelname, bool disableleg)? GetDefaultModel(CCSPlayerCon string model = modelsArray[randomnumber]; - return (model, Config.Settings.DefaultModelDisableLeg); + return (model, Config.Settings.DefaultModelDisableLeg, null); } return null; } - private static (string modelname, bool disableleg)? GetStoreModel(Store_Equipment item) + private static (string modelname, bool disableleg, string? skin)? GetStoreModel(Store_Equipment item) { Dictionary? itemdata = Item.GetItem(item.Type, item.UniqueId); @@ -232,6 +234,8 @@ private static (string modelname, bool disableleg)? GetStoreModel(Store_Equipmen return null; } - return (item.UniqueId, itemdata["disable_leg"] is "true" or "1"); + itemdata.TryGetValue("skin", out var skn); + + return (item.UniqueId, itemdata["disable_leg"] is "true" or "1", skn); } } \ No newline at end of file diff --git a/Store/src/playerutils/playerutils.cs b/Store/src/playerutils/playerutils.cs index c6926a7..7810f78 100644 --- a/Store/src/playerutils/playerutils.cs +++ b/Store/src/playerutils/playerutils.cs @@ -21,7 +21,7 @@ static public void PrintToChatMessage(this CCSPlayerController player, string me } } - static public void ChangeModelDelay(this CCSPlayerController player, string model, bool disableleg, int slotNumber) + static public void ChangeModelDelay(this CCSPlayerController player, string model, bool disableleg, int slotNumber, string? skin) { float apply_delay = float.Max(Config.Settings.ApplyPlayerskinDelay, 0.1f); @@ -32,11 +32,11 @@ static public void ChangeModelDelay(this CCSPlayerController player, string mode return; } - player.PlayerPawn.Value?.ChangeModel(model, disableleg); + player.PlayerPawn.Value?.ChangeModel(model, disableleg, skin); }, TimerFlags.STOP_ON_MAPCHANGE); } - static public void ChangeModel(this CCSPlayerPawn pawn, string model, bool disableleg) + static public void ChangeModel(this CCSPlayerPawn pawn, string model, bool disableleg, string? skin) { if (model == string.Empty) { @@ -57,6 +57,11 @@ static public void ChangeModel(this CCSPlayerPawn pawn, string model, bool disab { pawn.Render = Color.FromArgb(255, originalRender.R, originalRender.G, originalRender.B); } + + if (skin != null) + { + pawn.AcceptInput("Skin", null, pawn, skin); + } }); }