Skip to content

Commit

Permalink
Merge pull request #170 from daffyyyy/main
Browse files Browse the repository at this point in the history
1.9b
  • Loading branch information
daffyyyy authored Feb 22, 2024
2 parents 391efd5 + ff2e7ff commit ead5ae2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 23 deletions.
14 changes: 12 additions & 2 deletions Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
32 changes: 16 additions & 16 deletions Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance
pickupCount++;
g_knifePickupCount[player.Slot] = pickupCount;

RefreshWeapons(player);
AddTimer(0.2f, () => RefreshWeapons(player));
}

return HookResult.Continue;
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9a
1.9b
7 changes: 5 additions & 2 deletions WeaponAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -272,6 +272,9 @@ internal void RefreshWeapons(CCSPlayerController? player)
{
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value;
CCSWeaponBaseGun? gun = weapon?.As<CCSWeaponBaseGun>();
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, () =>
Expand Down Expand Up @@ -362,7 +365,7 @@ private static void RefreshGloves(CCSPlayerController player)
pawn.SetModel(model);
}

Instance.AddTimer(0.2f, () =>
Instance.AddTimer(0.06f, () =>
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion WeaponPaints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
public override string ModuleAuthor => "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()
{
Expand Down
2 changes: 1 addition & 1 deletion WeaponSynchronization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ead5ae2

Please sign in to comment.