From 40e18c9663312a68832d180e5536a9e759275b8d Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Wed, 6 Aug 2025 16:16:23 +0300 Subject: [PATCH 1/6] we don't need IncrementWearForWeaponWithStickers anymore --- WeaponAction.cs | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/WeaponAction.cs b/WeaponAction.cs index 6b52ed27..8037cef1 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -137,27 +137,6 @@ namespace WeaponPaints UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel); } - // silly method to update sticker when call RefreshWeapons() - private void IncrementWearForWeaponWithStickers(CCSPlayerController player, CBasePlayerWeapon weapon) - { - int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex; - if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null || - weaponInfo.Stickers.Count <= 0) return; - - float wearIncrement = 0.001f; - float currentWear = weaponInfo.Wear; - - var playerWear = _temporaryPlayerWeaponWear.GetOrAdd(player.Slot, _ => new ConcurrentDictionary()); - - float incrementedWear = playerWear.AddOrUpdate( - weaponDefIndex, - currentWear + wearIncrement, - (_, oldWear) => Math.Min(oldWear + wearIncrement, 1.0f) - ); - - weapon.FallbackWear = incrementedWear; - } - private void SetStickers(CCSPlayerController? player, CBasePlayerWeapon weapon) { if (player == null || !player.IsValid) return; @@ -350,8 +329,6 @@ namespace WeaponPaints { newWeapon.Clip1 = ammo.Item1; newWeapon.ReserveAmmo[0] = ammo.Item2; - - IncrementWearForWeaponWithStickers(player, newWeapon); } catch (Exception ex) { From 191773fc5acfea9838a5d761d1b51f31baa8a4eb Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Sun, 10 Aug 2025 20:12:14 +0300 Subject: [PATCH 2/6] fix gloves and knives --- Events.cs | 7 +++++-- WeaponAction.cs | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Events.cs b/Events.cs index ab49894c..62e3652a 100644 --- a/Events.cs +++ b/Events.cs @@ -13,7 +13,7 @@ namespace WeaponPaints [GameEventHandler] public HookResult OnClientFullConnect(EventPlayerConnectFull @event, GameEventInfo info) - { + { CCSPlayerController? player = @event.Userid; if (player is null || !player.IsValid || player.IsBot || @@ -142,7 +142,10 @@ namespace WeaponPaints GivePlayerMusicKit(player); GivePlayerAgent(player); - GivePlayerGloves(player); + Server.NextFrame(() => + { + GivePlayerGloves(player); + }); GivePlayerPin(player); return HookResult.Continue; diff --git a/WeaponAction.cs b/WeaponAction.cs index 8037cef1..44d8cd7d 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -37,6 +37,9 @@ namespace WeaponPaints weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key; weapon.AttributeManager.Item.EntityQuality = 3; + + weapon.AttributeManager.Item.AttributeList.Attributes.RemoveAll(); + weapon.AttributeManager.Item.NetworkedDynamicAttributes.Attributes.RemoveAll(); break; } default: @@ -96,9 +99,8 @@ namespace WeaponPaints weapon.AttributeManager.Item.AttributeList.Attributes.RemoveAll(); weapon.AttributeManager.Item.NetworkedDynamicAttributes.Attributes.RemoveAll(); - weapon.AttributeManager.Item.ItemID = 16384; - weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF; - weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32; + UpdatePlayerEconItemId(weapon.AttributeManager.Item); + weapon.AttributeManager.Item.CustomName = weaponInfo.Nametag; weapon.FallbackPaintKit = weaponInfo.Paint; @@ -373,13 +375,19 @@ namespace WeaponPaints return; item.ItemDefinitionIndex = gloveId; - item.ItemIDLow = 16384 & 0xFFFFFFFF; - item.ItemIDHigh = 16384; + + UpdatePlayerEconItemId(item); + item.NetworkedDynamicAttributes.Attributes.RemoveAll(); CAttributeListSetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weaponInfo.Paint); CAttributeListSetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture seed", weaponInfo.Seed); CAttributeListSetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture wear", weaponInfo.Wear); + item.AttributeList.Attributes.RemoveAll(); + CAttributeListSetOrAddAttributeValueByName.Invoke(item.AttributeList.Handle, "set item texture prefab", weaponInfo.Paint); + CAttributeListSetOrAddAttributeValueByName.Invoke(item.AttributeList.Handle, "set item texture seed", weaponInfo.Seed); + CAttributeListSetOrAddAttributeValueByName.Invoke(item.AttributeList.Handle, "set item texture wear", weaponInfo.Wear); + item.Initialized = true; SetBodygroup(pawn, "default_gloves", 1); From be8633f82b43f290fb0f4fe61f28466759bcb1ae Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Sun, 10 Aug 2025 20:13:00 +0300 Subject: [PATCH 3/6] fix keychain seed --- WeaponAction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeaponAction.cs b/WeaponAction.cs index 44d8cd7d..e77cb098 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -196,7 +196,7 @@ namespace WeaponPaints CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "keychain slot 0 offset z", keyChain.OffsetZ); CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, - "keychain slot 0 seed", keyChain.Seed); + "keychain slot 0 seed", ViewAsFloat(keyChain.Seed)); } private static void GiveKnifeToPlayer(CCSPlayerController? player) From b801b6592a57b4ddf51933fc12c7e03339b14607 Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Mon, 11 Aug 2025 09:59:24 +0300 Subject: [PATCH 4/6] fix gloves overlapping when change team --- WeaponAction.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/WeaponAction.cs b/WeaponAction.cs index e77cb098..7ba36456 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -357,9 +357,14 @@ namespace WeaponPaints pawn.SetModel(model); } + CEconItemView item = pawn.EconGloves; + + item.NetworkedDynamicAttributes.Attributes.RemoveAll(); + item.AttributeList.Attributes.RemoveAll(); + + Instance.AddTimer(0.08f, () => - { - CEconItemView item = pawn.EconGloves; + { try { if (!player.IsValid) From 23cd692032656bda4aeab86a2428f30545d49098 Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Mon, 11 Aug 2025 10:20:11 +0300 Subject: [PATCH 5/6] revert IncrementWearForWeaponWithStickers --- WeaponAction.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/WeaponAction.cs b/WeaponAction.cs index 7ba36456..c0352b5c 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -138,6 +138,27 @@ namespace WeaponPaints UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel); } + + // silly method to update sticker when call RefreshWeapons() + private void IncrementWearForWeaponWithStickers(CCSPlayerController player, CBasePlayerWeapon weapon) + { + int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex; + if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null || + weaponInfo.Stickers.Count <= 0) return; + + float wearIncrement = 0.001f; + float currentWear = weaponInfo.Wear; + + var playerWear = _temporaryPlayerWeaponWear.GetOrAdd(player.Slot, _ => new ConcurrentDictionary()); + + float incrementedWear = playerWear.AddOrUpdate( + weaponDefIndex, + currentWear + wearIncrement, + (_, oldWear) => Math.Min(oldWear + wearIncrement, 1.0f) + ); + + weapon.FallbackWear = incrementedWear; + } private void SetStickers(CCSPlayerController? player, CBasePlayerWeapon weapon) { @@ -151,7 +172,7 @@ namespace WeaponPaints foreach (var sticker in weaponInfo.Stickers) { int stickerSlot = weaponInfo.Stickers.IndexOf(sticker); - + CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {stickerSlot} id", ViewAsFloat(sticker.Id)); if (sticker.OffsetX != 0 || sticker.OffsetY != 0) @@ -168,7 +189,7 @@ namespace WeaponPaints CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {stickerSlot} rotation", sticker.Rotation); } - + if (_temporaryPlayerWeaponWear.TryGetValue(player.Slot, out var playerWear) && playerWear.TryGetValue(weaponDefIndex, out float storedWear)) { @@ -331,6 +352,8 @@ namespace WeaponPaints { newWeapon.Clip1 = ammo.Item1; newWeapon.ReserveAmmo[0] = ammo.Item2; + + IncrementWearForWeaponWithStickers(player, newWeapon); } catch (Exception ex) { From 5b43b2daef83b784ff246b1d4d7867d053482be9 Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Mon, 11 Aug 2025 12:32:50 +0300 Subject: [PATCH 6/6] fix weapon name in menu for M4A4 --- Variables.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Variables.cs b/Variables.cs index 9648ba27..d5ceeb3a 100644 --- a/Variables.cs +++ b/Variables.cs @@ -25,7 +25,7 @@ public partial class WeaponPaints {"weapon_g3sg1", "G3SG1"}, {"weapon_galilar", "Galil AR"}, {"weapon_m249", "M249"}, - {"weapon_m4a1", "M4A1"}, + {"weapon_m4a1", "M4A4"}, {"weapon_mac10", "MAC-10"}, {"weapon_p90", "P90"}, {"weapon_mp5sd", "MP5-SD"},