From 19d004c21dddf268c519d405a83f680cf0ce5623 Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:41:32 +0100 Subject: [PATCH 1/2] 1.9b - Fixed weapons on retake - FIxed saving --- Commands.cs | 14 ++++++++++++-- Events.cs | 32 ++++++++++++++++---------------- VERSION | 2 +- WeaponAction.cs | 7 +++++-- WeaponPaints.cs | 2 +- WeaponSynchronization.cs | 2 +- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/Commands.cs b/Commands.cs index 3c111b17..cfc5a2da 100644 --- a/Commands.cs +++ b/Commands.cs @@ -248,7 +248,7 @@ private void SetupSkinsMenu() } gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Paint = paintID; - gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Wear = 0.01f; + gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Wear = 0.00f; gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Seed = 0; PlayerInfo playerInfo = new PlayerInfo @@ -381,7 +381,17 @@ private void SetupGlovesMenu() { Task.Run(async () => { - await weaponSync.SyncGloveToDatabase(playerInfo, (ushort)weaponDefindex); + await weaponSync.SyncGloveToDatabase(playerInfo, weaponDefindex); + + if (!gPlayerWeaponsInfo[playerInfo.Slot].ContainsKey(weaponDefindex)) + { + gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex] = new WeaponInfo(); + } + + gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Paint = paint; + gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Wear = 0.00f; + gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Seed = 0; + }); } RefreshGloves(player); diff --git a/Events.cs b/Events.cs index 049d7bde..48ca5394 100644 --- a/Events.cs +++ b/Events.cs @@ -52,7 +52,7 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo { CCSPlayerController player = @event.Userid; - if (player is null || !player.IsValid || !player.UserId.HasValue || player.IsBot || + if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17) return HookResult.Continue; PlayerInfo playerInfo = new PlayerInfo @@ -71,25 +71,25 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo Task.Run(async () => { await weaponSync.SyncWeaponPaintsToDatabase(playerInfo); + + // Remove player data + if (Config.Additional.SkinEnabled) + { + gPlayerWeaponsInfo.TryRemove(player.Slot, out _); + } + if (Config.Additional.KnifeEnabled) + { + g_playersKnife.TryRemove(player.Slot, out _); + } + if (Config.Additional.GloveEnabled) + { + g_playersGlove.TryRemove(player.Slot, out _); + } }); } // Remove player's command cooldown commandsCooldown.Remove(player.Slot); - // Remove player data - if (Config.Additional.SkinEnabled) - { - gPlayerWeaponsInfo.TryRemove(player.Slot, out _); - } - if (Config.Additional.KnifeEnabled) - { - g_playersKnife.TryRemove(player.Slot, out _); - } - if (Config.Additional.GloveEnabled) - { - g_playersGlove.TryRemove(player.Slot, out _); - } - return HookResult.Continue; } @@ -160,7 +160,7 @@ public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance pickupCount++; g_knifePickupCount[player.Slot] = pickupCount; - RefreshWeapons(player); + AddTimer(0.3f, () => RefreshWeapons(player)); } return HookResult.Continue; diff --git a/VERSION b/VERSION index f3ec514b..e171316e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9a \ No newline at end of file +1.9b \ No newline at end of file diff --git a/WeaponAction.cs b/WeaponAction.cs index 722f385e..3f27e177 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -263,7 +263,7 @@ internal void RefreshWeapons(CCSPlayerController? player) } } - for (int i = 0; i < 3; i++) + for (int i = 1; i <= 3; i++) { player.ExecuteClientCommand($"slot {i}"); player.ExecuteClientCommand($"slot {i}"); @@ -272,6 +272,9 @@ internal void RefreshWeapons(CCSPlayerController? player) { var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value; CCSWeaponBaseGun? gun = weapon?.As(); + + if (gun?.VData?.GearSlot == gear_slot_t.GEAR_SLOT_C4 || gun?.VData?.GearSlot == gear_slot_t.GEAR_SLOT_GRENADES) return; + player.DropActiveWeapon(); AddTimer(0.22f, () => @@ -362,7 +365,7 @@ private static void RefreshGloves(CCSPlayerController player) pawn.SetModel(model); } - Instance.AddTimer(0.2f, () => + Instance.AddTimer(0.06f, () => { try { diff --git a/WeaponPaints.cs b/WeaponPaints.cs index bedcdec8..be4dbab9 100644 --- a/WeaponPaints.cs +++ b/WeaponPaints.cs @@ -155,7 +155,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig "Nereziel & daffyy"; public override string ModuleDescription => "Skin, gloves and knife selector, standalone and web-based"; public override string ModuleName => "WeaponPaints"; - public override string ModuleVersion => "1.9a"; + public override string ModuleVersion => "1.9b"; public static WeaponPaintsConfig GetWeaponPaintsConfig() { diff --git a/WeaponSynchronization.cs b/WeaponSynchronization.cs index a40d3261..2802c086 100644 --- a/WeaponSynchronization.cs +++ b/WeaponSynchronization.cs @@ -120,7 +120,7 @@ internal async Task SyncKnifeToDatabase(PlayerInfo player, string knife) } - internal async Task SyncGloveToDatabase(PlayerInfo player, ushort defindex) + internal async Task SyncGloveToDatabase(PlayerInfo player, int defindex) { if (!_config.Additional.GloveEnabled || player == null || string.IsNullOrEmpty(player.SteamId)) return; From c9a1fad496fa79ea453429687dddc5cc3e78a75b Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:43:25 +0100 Subject: [PATCH 2/2] 1.9b --- Events.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Events.cs b/Events.cs index 48ca5394..a978b4e6 100644 --- a/Events.cs +++ b/Events.cs @@ -160,7 +160,7 @@ public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance pickupCount++; g_knifePickupCount[player.Slot] = pickupCount; - AddTimer(0.3f, () => RefreshWeapons(player)); + AddTimer(0.2f, () => RefreshWeapons(player)); } return HookResult.Continue;