diff --git a/Commands.cs b/Commands.cs index 6d8245e6..851bf472 100644 --- a/Commands.cs +++ b/Commands.cs @@ -10,8 +10,7 @@ namespace WeaponPaints { if (!Config.AdditionalSetting.CommandWpEnabled || !Config.AdditionalSetting.SkinEnabled || !g_bCommandsAllowed) return; if (!Utility.IsPlayerValid(player)) return; - if (player == null || player.Index <= 0) return; - int playerIndex = (int)player!.Index; + if (player == null || !player.IsValid || player.UserId == null || player.Index <= 0 || player.IsBot) return; PlayerInfo playerInfo = new PlayerInfo { @@ -22,8 +21,6 @@ namespace WeaponPaints IpAddress = player?.IpAddress?.Split(":")[0] }; - if (player == null || player.UserId == null) return; - if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) || DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow)) { diff --git a/Events.cs b/Events.cs index 29171812..73a253cd 100644 --- a/Events.cs +++ b/Events.cs @@ -16,8 +16,8 @@ namespace WeaponPaints UserId = player.UserId, Index = (int)player.Index, SteamId = player.SteamID, - Name = player?.PlayerName, - IpAddress = player?.IpAddress?.Split(":")[0] + Name = player.PlayerName, + IpAddress = player.IpAddress?.Split(":")[0] }; if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return; @@ -173,7 +173,7 @@ namespace WeaponPaints weaponSync = new WeaponSynchronization(DatabaseConnectionString, Config, GlobalShareApi, GlobalShareServerId); }); - + /* g_hTimerCheckSkinsData = AddTimer(10.0f, () => { List players = Utilities.GetPlayers(); @@ -196,6 +196,7 @@ namespace WeaponPaints _ = weaponSync.GetKnifeFromDatabase(playerInfo); } }, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT); + */ } private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info) @@ -273,7 +274,7 @@ namespace WeaponPaints { try { - if (player == null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV) continue; + if (player == null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected == PlayerConnectedState.PlayerDisconnecting) continue; var viewModels = GetPlayerViewModels(player); diff --git a/WeaponPaints.cs b/WeaponPaints.cs index dbfc6232..27e15c47 100644 --- a/WeaponPaints.cs +++ b/WeaponPaints.cs @@ -141,7 +141,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig commandsCooldown = new Dictionary(); private string DatabaseConnectionString = string.Empty; - private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null; + //private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null; public WeaponPaintsConfig Config { get; set; } = new(); public override string ModuleAuthor => "Nereziel & daffyy"; public override string ModuleDescription => "Skin and knife selector, standalone and web-based"; @@ -273,7 +273,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig responseBodyTask = response.Content.ReadAsStringAsync(); responseBodyTask.Wait(); string responseBody = responseBodyTask.Result; - GlobalShareServerId = Int32.Parse(responseBody); + GlobalShareServerId = int.Parse(responseBody); } else {