Compare commits

...

3 Commits

Author SHA1 Message Date
stefanx111
5b43b2daef fix weapon name in menu for M4A4 2025-08-11 12:32:50 +03:00
stefanx111
23cd692032 revert IncrementWearForWeaponWithStickers 2025-08-11 10:20:11 +03:00
stefanx111
b801b6592a fix gloves overlapping when change team 2025-08-11 09:59:24 +03:00
2 changed files with 33 additions and 5 deletions

View File

@@ -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"},

View File

@@ -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<int, float>());
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)
{
@@ -357,9 +380,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)