diff --git a/.github/en.md b/.github/en.md index 660b1c0..dcdd8a4 100644 --- a/.github/en.md +++ b/.github/en.md @@ -385,6 +385,14 @@ This plugin uses content from the following projects: ## 📋 Changelog +
+v1.2.3.b3 + +- #### General + - ###### Added automatic HUD hiding to prevent conflicts with other plugins using the center HUD system (`HideHudForOtherPlugins` in `config.json`). + +
+
v1.2.3.b2 diff --git a/.github/pl.md b/.github/pl.md index f2c2f0a..d7a2cd7 100644 --- a/.github/pl.md +++ b/.github/pl.md @@ -384,6 +384,14 @@ Plugin korzysta z zawartości następujących projektów: ## 📋 Lista Zmian +
+v1.2.3.b3 + +- #### Ogólne + - ###### Dodano automatyczne ukrywanie HUD-u, aby zapobiec konfliktom z innymi pluginami korzystającymi z centralnego systemu HUD (`HideHudForOtherPlugins` w `config.json`. + +
+
v1.2.3.b2 diff --git a/jRandomSkills - SRC Files/src/command/Command.cs b/jRandomSkills - SRC Files/src/command/Command.cs index 8b6dbb8..9969e7f 100644 --- a/jRandomSkills - SRC Files/src/command/Command.cs +++ b/jRandomSkills - SRC Files/src/command/Command.cs @@ -1,8 +1,8 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; -using CounterStrikeSharp.API.Core.Attributes.Registration; using CounterStrikeSharp.API.Modules.Admin; using CounterStrikeSharp.API.Modules.Commands; +using CounterStrikeSharp.API.Modules.Entities; using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Utils; using src.menu; @@ -440,9 +440,12 @@ namespace src.command var playerInfo = PlayerManager.GetPlayerByIndex(PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index); if (playerInfo == null) return; - playerInfo.DisplayHUD = !playerInfo.DisplayHUD; + int tickCount = Server.TickCount; + bool isDisplayHUD = playerInfo.HideHUD < tickCount; + + playerInfo.HideHUD = isDisplayHUD ? int.MaxValue : int.MinValue; SkillUtils.CloseMenu(player); - player.PrintToChat($" {(playerInfo.DisplayHUD ? ChatColors.Green : ChatColors.Red)}{player.GetTranslation(playerInfo.DisplayHUD ? "hud_on" : "hud_off")}"); + player.PrintToChat($" {(!isDisplayHUD ? ChatColors.Green : ChatColors.Red)}{player.GetTranslation(!isDisplayHUD ? "hud_on" : "hud_off")}"); } [CommandHelper(minArgs: 2, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] diff --git a/jRandomSkills - SRC Files/src/jRandomSkills.cs b/jRandomSkills - SRC Files/src/jRandomSkills.cs index eb93e6c..e935cec 100644 --- a/jRandomSkills - SRC Files/src/jRandomSkills.cs +++ b/jRandomSkills - SRC Files/src/jRandomSkills.cs @@ -31,7 +31,7 @@ namespace src public override string ModuleName => "[CS2] [ jRandomSkills ]"; public override string ModuleAuthor => "D3X (Original), Juzlus (Modifier), ByDexterTR (Contributor)"; public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus."; - public override string ModuleVersion => "1.2.3.b2"; + public override string ModuleVersion => "1.2.3.b3"; public override void Load(bool hotReload) { @@ -368,7 +368,7 @@ namespace src public DateTime SkillDescriptionHudExpired { get; set; } public DateTime HudSuppressedUntil { get; set; } public string? PrintHTML { get; set; } - public bool DisplayHUD { get; set; } + public int HideHUD { get; set; } public bool SkillUsed = false; public bool? HudOnDeathBlocked { get; set; } } diff --git a/jRandomSkills - SRC Files/src/player/PlayerEvents.cs b/jRandomSkills - SRC Files/src/player/PlayerEvents.cs index 71a61db..3a67b9d 100644 --- a/jRandomSkills - SRC Files/src/player/PlayerEvents.cs +++ b/jRandomSkills - SRC Files/src/player/PlayerEvents.cs @@ -1,7 +1,5 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; -using CounterStrikeSharp.API.Core.Attributes; -using CounterStrikeSharp.API.Modules.Admin; using CounterStrikeSharp.API.Modules.Cvars; using CounterStrikeSharp.API.Modules.Events; using CounterStrikeSharp.API.Modules.Memory; @@ -12,6 +10,7 @@ using RayTraceAPI; using src.player.skills; using src.utils; using System.Collections.Concurrent; +using System.Text.RegularExpressions; using static CounterStrikeSharp.API.Core.Listeners; using static src.jRandomSkills; using Timer = CounterStrikeSharp.API.Modules.Timers.Timer; @@ -78,6 +77,8 @@ namespace src.player Instance.RegisterListener(OnPlayerConnectedBot); Instance.HookUserMessage(208, PlayerMakeSound); + Instance.HookUserMessage(207, GetPrintToCenterHtml); + VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre); VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamagePost, HookMode.Post); @@ -209,6 +210,45 @@ namespace src.player } } + private static HookResult GetPrintToCenterHtml(UserMessage um) + { + if (!Config.LoadedConfig.HideHudForOtherPlugins) return HookResult.Continue; + + int tickCount = Server.TickCount; + if (tickCount % 10 != 0) return HookResult.Continue; + + lock (setLock) + { + if (um.ReadUInt("eventid") != 226) + return HookResult.Continue; + + var debug = um.DebugString; + var match = Regex.Match(debug, @"val_string:\s*""(.*?)"""); + + if (match.Success) + { + var html = match.Groups[1].Value.Replace("\\'", "'"); + if (string.IsNullOrEmpty(html)) return HookResult.Continue; + + bool isOtherPlugin = !html.StartsWith(""); + + var player = um.Recipients.FirstOrDefault(); + if (player == null || !player.IsValid) return HookResult.Continue; + + var playerInfo = PlayerManager.GetPlayerByIndex(PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index); + if (playerInfo == null) return HookResult.Continue; + + if (isOtherPlugin && playerInfo.HideHUD != int.MaxValue) + { + playerInfo.HideHUD = tickCount + 15; + SkillUtils.CloseMenu(player); + } + } + + return HookResult.Continue; + } + } + private static HookResult WeaponFire(EventWeaponFire @event, GameEventInfo info) { lock (setLock) @@ -347,33 +387,6 @@ namespace src.player } } - private static HookResult WeaponDrop(DynamicHook hook) - { - lock (setLock) - { - CCSPlayerController player = hook.GetParam(0); - if (player == null || !player.IsValid) - return HookResult.Continue; - - var activeSkills = Instance.SkillPlayer - .Where(p => !p.IsDrawing) - .Select(p => p.Skill.ToString()) - .Distinct(); - - bool block = false; - foreach (string skillName in activeSkills) - { - bool? result = (bool?)Instance.SkillAction(skillName, "WeaponDrop", [hook, player]); - if (result == true) - { - block = true; - break; - } - } - return block ? HookResult.Handled : HookResult.Continue; - } - } - private static readonly Dictionary _skillNames = Enum.GetValues().ToDictionary(s => s, s => s.ToString()); private static readonly HashSet _activeSkillsSet = []; @@ -460,7 +473,7 @@ namespace src.player IsDrawing = false, SkillChance = 1, PrintHTML = null, - DisplayHUD = true, + HideHUD = int.MinValue, SkillUsed = false, }; @@ -516,26 +529,6 @@ namespace src.player } } - private static HookResult PlayerChat(EventPlayerChat @event, GameEventInfo info) - { - var userID = @event.Userid; - if (userID == 0 || string.IsNullOrEmpty(@event.Text)) return HookResult.Continue; - - string text = @event.Text.Split(' ')[0].Trim(); - - string commandName = text.StartsWith('!') || text.StartsWith('/') ? text[1..] : text; - - var player = Utilities.GetPlayerFromUserid(userID); - if (player == null || !player.IsValid) return HookResult.Continue; - - var skillPlayer = PlayerManager.GetPlayerByIndex(player!.Index); - if (skillPlayer == null) return HookResult.Continue; - - skillPlayer.HudSuppressedUntil = DateTime.Now.AddSeconds(5); - - return HookResult.Continue; - } - private static HookResult PlayerSpawned(EventPlayerSpawned @event, GameEventInfo info) { lock (setLock) @@ -719,7 +712,7 @@ namespace src.player private static readonly Dictionary nextRoundPicks = []; - public static void UpdateSkillHUD(CCSPlayerController? player, string? headerLine, string? centerLine, string? extraLine, bool isDescription) + public static void UpdateSkillHUD(CCSPlayerController? player, jSkill_PlayerInfo? skillPlayer, string? headerLine, string? centerLine, string? extraLine, bool isDescription) { lock (setLock) { @@ -746,11 +739,9 @@ namespace src.player ? "" : $"
{emptySymbol}{extraLine}{emptySymbol}"; - var hudContent = infoLine + skillLine + remainingLine; - + var hudContent = "" + infoLine + skillLine + remainingLine; player.PrintToCenterHtml(hudContent); } } - } } diff --git a/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs b/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs index cb960bd..1c2f354 100644 --- a/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs +++ b/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs @@ -80,7 +80,7 @@ namespace src.player if (gameRules == null || gameRules.WarmupPeriod == true || gameRules.GamePhase >= 5) return; var skillPlayer = PlayerManager.GetPlayerByIndex(PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index); - if (skillPlayer == null || !skillPlayer.DisplayHUD) return; + if (skillPlayer == null || skillPlayer.HideHUD >= Server.TickCount) return; if (skillPlayer.HudSuppressedUntil > now) return; @@ -191,7 +191,7 @@ namespace src.player if (string.IsNullOrEmpty(skillLine)) return; - Event.UpdateSkillHUD(player, infoLine, skillLine, remainingLine, isDescription); + Event.UpdateSkillHUD(player, skillPlayer, infoLine, skillLine, remainingLine, isDescription); } } } diff --git a/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs b/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs index 3a6ab09..89a5437 100644 --- a/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs +++ b/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs @@ -235,7 +235,7 @@ namespace src.player.skills } } - public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00911f", CsTeam onlyTeam = CsTeam.Terrorist, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Uncommon) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity) + public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00911f", CsTeam onlyTeam = CsTeam.Terrorist, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = 1, Rarity rarity = Rarity.Uncommon) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity) { } } diff --git a/jRandomSkills - SRC Files/src/utils/Config.cs b/jRandomSkills - SRC Files/src/utils/Config.cs index 57c4dbc..270e4f5 100644 --- a/jRandomSkills - SRC Files/src/utils/Config.cs +++ b/jRandomSkills - SRC Files/src/utils/Config.cs @@ -86,6 +86,7 @@ namespace src.utils public float SkillDescriptionDuration { get; set; } public bool DisplayAlwaysDescription { get; set; } public bool DisableSpectateHUD { get; set; } + public bool HideHudForOtherPlugins { get; set; } public bool EnableFlashingHtmlHudFix { get; set; } public bool TraceRayBeam { get; set; } public string DisableHUDOnDeathPermission { get; set; } @@ -118,6 +119,7 @@ namespace src.utils EnableFlashingHtmlHudFix = false; TraceRayBeam = false; DisableSpectateHUD = false; + HideHudForOtherPlugins = true; DisableHUDOnDeathPermission = "@jRandomSkills/death"; DisableSkillsOnRoundEnd = false; CurseSkillPerPlayer = null; diff --git a/jRandomSkills - SRC Files/src/utils/SkillUtils.cs b/jRandomSkills - SRC Files/src/utils/SkillUtils.cs index 9ff3798..ff1bead 100644 --- a/jRandomSkills - SRC Files/src/utils/SkillUtils.cs +++ b/jRandomSkills - SRC Files/src/utils/SkillUtils.cs @@ -834,7 +834,7 @@ namespace src.utils if (player == null || !player.IsValid) return; var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index); - if (playerInfo == null || !playerInfo.DisplayHUD) return; + if (playerInfo == null || playerInfo.HideHUD >= Server.TickCount) return; if (player.IsBot) { @@ -944,7 +944,6 @@ namespace src.utils UpdateServerTeamScores(ctScore, tScore); jRandomSkills.Instance.GameRules?.TerminateRound(5f, winnerTeam == CsTeam.CounterTerrorist ? RoundEndReason.BombDefused : RoundEndReason.TargetBombed); - // TerminateRoundFunc.Invoke(jRandomSkills.Instance.GameRules.Handle, 5f, winnerTeam == CsTeam.CounterTerrorist ? RoundEndReason.BombDefused : RoundEndReason.TargetBombed, 0, 0); } private static void UpdateServerTeamScores(short ctScore, short tScore) diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll index 39e6f9b..83c6c5d 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll differ diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/configs/config.json b/jRandomSkills - Server Files/plugins/jRandomSkills/configs/config.json index 31a1b3b..bb77ff6 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/configs/config.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/configs/config.json @@ -16,6 +16,7 @@ "SkillDescriptionDuration": 7.0, "DisplayAlwaysDescription": false, "DisableSpectateHUD": false, + "HideHudForOtherPlugins": true, "EnableFlashingHtmlHudFix": false, "TraceRayBeam": false, "DisableHUDOnDeathPermission": "@jRandomSkills/death", @@ -213,4 +214,4 @@ "Permissions": "@jRandomSkills/owner" } } -} +} \ No newline at end of file diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/configs/skillsInfo.json b/jRandomSkills - Server Files/plugins/jRandomSkills/configs/skillsInfo.json index 5018687..3c17250 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/configs/skillsInfo.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/configs/skillsInfo.json @@ -189,6 +189,22 @@ "MaxPerServer": -1, "Rarity": "Common" }, + { + "Cooldown": 15.0, + "TeleportAngle": 10.0, + "TeleportDistance": 100.0, + "NeedsTeammates": true, + "DisableOnFreezeTime": true, + "OnlyTeam": 0, + "Color": "#bcf542", + "Active": true, + "Name": "TeamTeleport", + "HudDuration": null, + "DescriptionHudDuration": null, + "RequiredPermission": "", + "MaxPerServer": 2, + "Rarity": "Common" + }, { "Cooldown": 30.0, "NeedsTeammates": false, diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll index f013b7f..bba02a6 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll differ diff --git a/updater.json b/updater.json index 8832adf..4e62161 100644 --- a/updater.json +++ b/updater.json @@ -1,19 +1,31 @@ { "name": "jRandomSkills", - "current_version": "v1.2.3.b1", + "current_version": "v1.2.3.b3", "releases": [ + { + "version": "v1.2.3.b3", + "release_date": "2026-08-01", + "download": "https://github.com/Juzlus/jRandomSkills/releases/download/v1.2.3.b3/jRandomSkills.v1.2.3.b3.zip", + "output_folder": "addons/counterstrikesharp/" + }, + { + "version": "v1.2.3.b2", + "release_date": "2026-07-31", + "download": "https://github.com/Juzlus/jRandomSkills/releases/download/v1.2.3.b2/jRandomSkills.v1.2.3.b2.zip", + "output_folder": "addons/counterstrikesharp/" + }, { "version": "v1.2.3.b1", "release_date": "2026-07-27", "download": "https://github.com/Juzlus/jRandomSkills/releases/download/v1.2.3.b1/jRandomSkills.v1.2.3.b1.zip", "output_folder": "addons/counterstrikesharp/" - } + }, { "version": "v1.2.2.b9", "release_date": "2026-07-23", "download": "https://github.com/Juzlus/jRandomSkills/releases/download/v1.2.2.b9/jRandomSkills.v1.2.2.b9.zip", "output_folder": "addons/counterstrikesharp/" - } + }, { "version": "v1.2.2.b8", "release_date": "2026-07-14",