From bff8a726ce17e30c953f91a36428578202c021e3 Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Sun, 20 Oct 2024 01:53:21 +0200 Subject: [PATCH 1/2] 2.9c - Fixed music kits --- Commands.cs | 4 ++++ Events.cs | 37 +++---------------------------------- VERSION | 2 +- WeaponAction.cs | 15 +++++++++------ WeaponPaints.cs | 2 +- 5 files changed, 18 insertions(+), 42 deletions(-) diff --git a/Commands.cs b/Commands.cs index 9a62bbdc..3b082852 100644 --- a/Commands.cs +++ b/Commands.cs @@ -682,6 +682,8 @@ private void SetupMusicMenu() playerMusic[team] = 0; } } + + GivePlayerMusicKit(player); if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"])) { @@ -712,6 +714,8 @@ private void SetupMusicMenu() { playerMusic[team] = 0; } + + GivePlayerMusicKit(player); if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"])) { diff --git a/Events.cs b/Events.cs index a2ed22df..2450cf7a 100644 --- a/Events.cs +++ b/Events.cs @@ -111,35 +111,6 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo return HookResult.Continue; } - [GameEventHandler(HookMode.Pre)] - public HookResult OnPlayerMvp(EventRoundMvp @event, GameEventInfo info) - { - var player = @event.Userid; - if (player == null || !player.IsValid || player.IsBot) - return HookResult.Continue; - - if (!(GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) - && musicInfo.TryGetValue(player.Team, out var musicId) - && musicId != 0)) - return HookResult.Continue; - - @event.Musickitid = musicId; - @event.Nomusic = 0; - @event.Musickitmvps = 1; - @event.Value = 1; - - var newEvent = new EventRoundMvp(true) - { - Musickitid = musicId, - Nomusic = 0, - Musickitmvps = 1, - Value = 1 - }; - - newEvent.FireEvent(false); - return HookResult.Continue; - } - private void OnMapStart(string mapName) { if (Config.Additional is { KnifeEnabled: false, SkinEnabled: false, GloveEnabled: false }) return; @@ -171,7 +142,6 @@ private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info) private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) { _gBCommandsAllowed = false; - return HookResult.Continue; } @@ -249,9 +219,8 @@ private void OnTick() if (!Config.Additional.ShowSkinImage) return; foreach (var player in Utilities.GetPlayers().Where(p => - p is { IsValid: true, PlayerPawn.IsValid: true } && - (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE - && !p.IsBot && p is { Connected: PlayerConnectedState.PlayerConnected } + p is { IsValid: true, PlayerPawn.IsValid: true, IsBot: false } and + { Connected: PlayerConnectedState.PlayerConnected } ) ) { @@ -284,7 +253,7 @@ private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) if (player is null || !player.IsValid) return HookResult.Continue; - if (victim == null || victim == player) + if (victim == null || !victim.IsValid || victim == player) return HookResult.Continue; if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return HookResult.Continue; diff --git a/VERSION b/VERSION index 83ff4ce3..9e77c679 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.9b \ No newline at end of file +2.9c \ No newline at end of file diff --git a/WeaponAction.cs b/WeaponAction.cs index 1f9ffdd0..4a35b249 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -473,17 +473,20 @@ private static void GivePlayerAgent(CCSPlayerController player) private static void GivePlayerMusicKit(CCSPlayerController player) { - if (GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) || musicInfo == null || + if (player.IsBot) return; + if (!GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) || !musicInfo.TryGetValue(player.Team, out var musicId) || musicId == 0) return; if (player.InventoryServices == null) return; - - player.InventoryServices.MusicID = musicId; - Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices"); + player.MusicKitID = musicId; + // player.MvpNoMusic = false; + player.InventoryServices.MusicID = musicId; Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitID"); - player.MusicKitMVPs = musicId; - Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitMVPs"); + // Utilities.SetStateChanged(player, "CCSPlayerController", "m_bMvpNoMusic"); + Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices"); + // player.MusicKitMVPs = musicId; + // Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitMVPs"); } private static void GivePlayerPin(CCSPlayerController player) diff --git a/WeaponPaints.cs b/WeaponPaints.cs index 025cb23e..dec0aa3d 100644 --- a/WeaponPaints.cs +++ b/WeaponPaints.cs @@ -16,7 +16,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 => "2.9b"; + public override string ModuleVersion => "2.9c"; public override void Load(bool hotReload) { From a6b9982367dd53686325971a4d463b883eef9e05 Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Sun, 20 Oct 2024 01:56:59 +0200 Subject: [PATCH 2/2] Update Events.cs --- Events.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Events.cs b/Events.cs index 2450cf7a..348fed38 100644 --- a/Events.cs +++ b/Events.cs @@ -256,7 +256,9 @@ private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) if (victim == null || !victim.IsValid || victim == player) return HookResult.Continue; - if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return HookResult.Continue; + if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) || + !teamInfo.TryGetValue(player.Team, out var teamWeapons) ) + return HookResult.Continue; CBasePlayerWeapon? weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value; @@ -264,7 +266,7 @@ private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex; - if (!GPlayerWeaponsInfo[player.Slot][player.Team].TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0) + if (!teamWeapons.TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0) return HookResult.Continue; if (!weaponInfo.StatTrak) return HookResult.Continue;