From 8891ce815ec6ee24da2af007223eb40f05cb30a8 Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:02:25 +0200 Subject: [PATCH] 3.2b - Schema for stickers when using custom coords - Fixed some not found team key --- VERSION | 2 +- WeaponAction.cs | 43 ++++++++++++++++++++++--------------------- WeaponPaints.cs | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/VERSION b/VERSION index 75fc8132..a900d95b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1a \ No newline at end of file +3.1b \ No newline at end of file diff --git a/WeaponAction.cs b/WeaponAction.cs index aa3bf5fe..daec1d55 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -20,8 +20,10 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet"); - if (isKnife && !GPlayersKnife.ContainsKey(player.Slot) || - isKnife && GPlayersKnife[player.Slot][player.Team] == "weapon_knife") return; + if (isKnife && (!GPlayersKnife.ContainsKey(player.Slot) || + !GPlayersKnife[player.Slot].ContainsKey(player.Team) || + GPlayersKnife[player.Slot][player.Team] == "weapon_knife")) + return; if (isKnife) { @@ -52,7 +54,9 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon bool isLegacyModel; if (_config.Additional.GiveRandomSkin && - !GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex)) + GPlayerWeaponsInfo.ContainsKey(player.Slot) && + (!GPlayerWeaponsInfo[player.Slot].ContainsKey(player.Team) || + !GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex))) { // Random skins weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex); @@ -103,14 +107,7 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon weapon.AttributeManager.Item.CustomName = weaponInfo.Nametag; weapon.FallbackPaintKit = weaponInfo.Paint; - if (weaponInfo is { Paint: 38, Seed: 0 }) - { - weapon.FallbackSeed = _fadeSeed++; - } - else - { - weapon.FallbackSeed = weaponInfo.Seed; - } + weapon.FallbackSeed = weaponInfo is { Paint: 38, Seed: 0 } ? _fadeSeed++ : weaponInfo.Seed; weapon.FallbackWear = weaponInfo.Wear; CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit); @@ -186,15 +183,13 @@ private void SetStickers(CCSPlayerController? player, CBasePlayerWeapon weapon) CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {stickerSlot} id", ViewAsFloat(sticker.Id)); - // CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, - // $"sticker slot {stickerSlot} schema", stickerSlot); - // if (stickerSlot == 5) - // { + if (sticker.OffsetX != 0 || sticker.OffsetY != 0) + CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, + $"sticker slot {stickerSlot} schema", 0); CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {stickerSlot} offset x", sticker.OffsetX); CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {stickerSlot} offset y", sticker.OffsetY); - // } CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {stickerSlot} wear", sticker.Wear); CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, @@ -217,8 +212,11 @@ private void SetKeychain(CCSPlayerController? player, CBasePlayerWeapon weapon) int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex; if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) || - !playerWeaponsInfo[player.Team].TryGetValue(weaponDefIndex, out var value) || - value.KeyChain == null) return; + !playerWeaponsInfo.TryGetValue(player.Team, out var teamWeaponsInfo) || + !teamWeaponsInfo.TryGetValue(weaponDefIndex, out var value) || + value.KeyChain == null) + return; + var keyChain = value.KeyChain; CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, @@ -406,9 +404,12 @@ private void GivePlayerGloves(CCSPlayerController player) return; if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) || - !gloveInfo.TryGetValue(player.Team, out var gloveId) || gloveId == 0) return; - - WeaponInfo weaponInfo = GPlayerWeaponsInfo[player.Slot][player.Team][gloveId]; + !gloveInfo.TryGetValue(player.Team, out var gloveId) || + gloveId == 0 || + !GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) || + !playerWeaponsInfo.TryGetValue(player.Team, out var teamWeaponsInfo) || + !teamWeaponsInfo.TryGetValue(gloveId, out var weaponInfo)) + return; item.ItemDefinitionIndex = gloveId; item.ItemIDLow = 16384 & 0xFFFFFFFF; diff --git a/WeaponPaints.cs b/WeaponPaints.cs index 350ed997..1324ad42 100644 --- a/WeaponPaints.cs +++ b/WeaponPaints.cs @@ -17,7 +17,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig "Nereziel & daffyy"; public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based"; public override string ModuleName => "WeaponPaints"; - public override string ModuleVersion => "3.1a"; + public override string ModuleVersion => "3.1b"; public override void Load(bool hotReload) {