- Small changes
- Fixed gloves command
This commit is contained in:
Dawid Bepierszcz
2024-02-21 12:03:48 +01:00
parent a1285bef26
commit 5d5e0f2bd1
6 changed files with 98 additions and 92 deletions

View File

@@ -150,11 +150,12 @@ namespace WeaponPaints
g_playersKnife[(int)player!.Index] = knifeKey;
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
AddTimer(0.1f, () => RefreshWeapons(player), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
if (weaponSync != null)
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
AddTimer(0.2f, () => RefreshWeapons(player), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
}
};
foreach (var knifePair in knivesOnly)
@@ -266,7 +267,7 @@ namespace WeaponPaints
};
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
AddTimer(0.15f, () => RefreshWeapons(p), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
AddTimer(0.2f, () => RefreshWeapons(p), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
}
};

View File

@@ -202,17 +202,17 @@ namespace WeaponPaints
return HookResult.Continue;
}
private void OnTick()
{
foreach (var player in Utilities.GetPlayers())
foreach (var player in Utilities.GetPlayers().Where(p =>
p is not null && p.IsValid &&
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE && p.SteamID.ToString().Length == 17
&& !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected && p.Team != CounterStrikeSharp.API.Modules.Utils.CsTeam.None
)
)
{
try
{
if (player is null || !player.IsValid || !player.PawnIsAlive || player.SteamID.ToString().Length != 17
|| player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
continue;
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.ContainsKey(player.Slot) && !string.IsNullOrEmpty(PlayerWeaponImage[player.Slot]))
{
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));

View File

@@ -1 +1 @@
1.8c
1.8d

View File

@@ -202,16 +202,16 @@ namespace WeaponPaints
{
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
return;
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
return;
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
if (weapons == null || weapons.Count == 0)
return;
if (player.Team == CsTeam.None || player.Team == CsTeam.Spectator)
return;
if (weapons != null && weapons.Count > 0)
{
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
bool bomb = false;
@@ -248,7 +248,13 @@ namespace WeaponPaints
}
}
if (!weapon.Value.DesignerName.Contains("knife") && WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
if (!weapon.Value.DesignerName.Contains("knife")
&&
!weapon.Value.DesignerName.Contains("bayonet")
&&
!weapon.Value.DesignerName.Contains("kukri")
&&
WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
{
int clip1 = weapon.Value.Clip1;
int reservedAmmo = weapon.Value.ReserveAmmo[0];
@@ -269,7 +275,7 @@ namespace WeaponPaints
}
player.RemoveWeapons();
AddTimer(0.1f, () =>
AddTimer(0.3f, () =>
{
GiveKnifeToPlayer(player);
@@ -313,7 +319,6 @@ namespace WeaponPaints
}
}, TimerFlags.STOP_ON_MAPCHANGE);
}
}
internal void RefreshKnife(CCSPlayerController? player)
{

View File

@@ -158,7 +158,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.8c";
public override string ModuleVersion => "1.8d";
public static WeaponPaintsConfig GetWeaponPaintsConfig()
{

View File

@@ -219,7 +219,7 @@ namespace WeaponPaints
try
{
await using var connection = await _database.GetConnectionAsync();
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`) VALUES(@steamid, @weapon_defindex, @paint) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex";
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`) VALUES(@steamid, @weapon_defindex) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex";
await connection.ExecuteAsync(query, new { steamid = player.SteamId, weapon_defindex = defindex });
}
catch (Exception e)