diff --git a/Commands.cs b/Commands.cs index 3c111b17..cfc5a2da 100644 --- a/Commands.cs +++ b/Commands.cs @@ -248,7 +248,7 @@ namespace WeaponPaints } 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 @@ namespace WeaponPaints { 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 @@ namespace WeaponPaints { 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 @@ namespace WeaponPaints 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 @@ namespace WeaponPaints 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 @@ namespace WeaponPaints } } - 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 @@ namespace WeaponPaints { 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 @@ namespace WeaponPaints 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 @@ namespace WeaponPaints } - 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;