From d04bc0879abd6d3773c34bb772b5fc27d0633e46 Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Thu, 18 Jan 2024 01:36:05 +0100 Subject: [PATCH] 1.3i - Updated css - Minor changes --- Events.cs | 14 ++++++++++---- VERSION | 2 +- WeaponAction.cs | 1 + WeaponPaints.cs | 14 +++++++------- WeaponPaints.csproj | 6 +++--- WeaponSynchronization.cs | 3 ++- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Events.cs b/Events.cs index 20b0a701..a92bb475 100644 --- a/Events.cs +++ b/Events.cs @@ -40,9 +40,14 @@ namespace WeaponPaints if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.UserId == null) return; if (Config.Additional.KnifeEnabled) - g_playersKnife.Remove((int)player.Index); + g_playersKnife.TryRemove((int)player.Index, out _); if (Config.Additional.SkinEnabled) - gPlayerWeaponsInfo.Remove((int)player.Index); + { + if (gPlayerWeaponsInfo.TryRemove((int)player.Index, out var innerDictionary)) + { + innerDictionary.Clear(); + } + } if (commandsCooldown.ContainsKey((int)player.UserId)) { commandsCooldown.Remove((int)player.UserId); @@ -52,7 +57,8 @@ namespace WeaponPaints private void OnEntityCreated(CEntityInstance entity) { if (!Config.Additional.SkinEnabled) return; - var designerName = entity.DesignerName; + if (entity == null || !entity.IsValid || string.IsNullOrEmpty(entity.DesignerName)) return; + string designerName = entity.DesignerName; if (!weaponList.ContainsKey(designerName)) return; bool isKnife = false; var weapon = new CBasePlayerWeapon(entity.Handle); @@ -229,7 +235,7 @@ namespace WeaponPaints private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info) { CCSPlayerController? player = @event.Userid; - if (player == null || !player.IsValid || player.IsBot) + if (player == null || !player.IsValid) { return HookResult.Continue; } diff --git a/VERSION b/VERSION index 98c19152..0fc61d4e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3h \ No newline at end of file +1.3i \ No newline at end of file diff --git a/WeaponAction.cs b/WeaponAction.cs index cbda2888..a04aa3c8 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -62,6 +62,7 @@ namespace WeaponPaints internal static void GiveKnifeToPlayer(CCSPlayerController? player) { if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return; + if (g_playersKnife.TryGetValue((int)player.Index, out var knife)) { player.GiveNamedItem(knife); diff --git a/WeaponPaints.cs b/WeaponPaints.cs index 130fb322..bdf922bf 100644 --- a/WeaponPaints.cs +++ b/WeaponPaints.cs @@ -2,13 +2,14 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core.Attributes; using CounterStrikeSharp.API.Modules.Cvars; -using Newtonsoft.Json.Linq; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; +using System.Collections.Concurrent; namespace WeaponPaints; -[MinimumApiVersion(132)] +[MinimumApiVersion(142)] public partial class WeaponPaints : BasePlugin, IPluginConfig { internal static readonly Dictionary weaponList = new() @@ -72,11 +73,10 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig g_knifePickupCount = new Dictionary(); - internal static Dictionary g_playersKnife = new(); - internal static Dictionary> gPlayerWeaponsInfo = new Dictionary>(); + internal static ConcurrentDictionary g_playersKnife = new ConcurrentDictionary(); + internal static ConcurrentDictionary> gPlayerWeaponsInfo = new ConcurrentDictionary>(); internal static List skinsList = new List(); internal static WeaponSynchronization? weaponSync; - //internal static List g_changedKnife = new(); internal bool g_bCommandsAllowed = true; internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php"); @@ -145,7 +145,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig "Nereziel & daffyy"; public override string ModuleDescription => "Skin and knife selector, standalone and web-based"; public override string ModuleName => "WeaponPaints"; - public override string ModuleVersion => "1.3h"; + public override string ModuleVersion => "1.3i"; public static WeaponPaintsConfig GetWeaponPaintsConfig() { diff --git a/WeaponPaints.csproj b/WeaponPaints.csproj index b8fa2437..16fb048d 100644 --- a/WeaponPaints.csproj +++ b/WeaponPaints.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/WeaponSynchronization.cs b/WeaponSynchronization.cs index 5742a654..4e712cba 100644 --- a/WeaponSynchronization.cs +++ b/WeaponSynchronization.cs @@ -1,6 +1,7 @@ using Dapper; using MySqlConnector; using Newtonsoft.Json.Linq; +using System.Collections.Concurrent; namespace WeaponPaints { @@ -94,7 +95,7 @@ namespace WeaponPaints if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Index, out _)) { - WeaponPaints.gPlayerWeaponsInfo[player.Index] = new Dictionary(); + WeaponPaints.gPlayerWeaponsInfo[player.Index] = new ConcurrentDictionary(); } try {