v1.2.3.b3 - HUD auto-hide
Added automatic HUD hiding to prevent conflicts with other plugins using the center HUD system.
This commit is contained in:
parent
7b142cf933
commit
9857be3236
14 changed files with 108 additions and 68 deletions
8
.github/en.md
vendored
8
.github/en.md
vendored
|
|
@ -385,6 +385,14 @@ This plugin uses content from the following projects:
|
|||
|
||||
## 📋 Changelog
|
||||
|
||||
<details>
|
||||
<summary><b>v1.2.3.b3</b></summary>
|
||||
|
||||
- #### General
|
||||
- ###### Added automatic HUD hiding to prevent conflicts with other plugins using the center HUD system (`HideHudForOtherPlugins` in `config.json`).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>v1.2.3.b2</b></summary>
|
||||
|
||||
|
|
|
|||
8
.github/pl.md
vendored
8
.github/pl.md
vendored
|
|
@ -384,6 +384,14 @@ Plugin korzysta z zawartości następujących projektów:
|
|||
|
||||
## 📋 Lista Zmian
|
||||
|
||||
<details>
|
||||
<summary><b>v1.2.3.b3</b></summary>
|
||||
|
||||
- #### Ogólne
|
||||
- ###### Dodano automatyczne ukrywanie HUD-u, aby zapobiec konfliktom z innymi pluginami korzystającymi z centralnego systemu HUD (`HideHudForOtherPlugins` w `config.json`.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>v1.2.3.b2</b></summary>
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<OnClientPutInServer>(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("<jRS/>");
|
||||
|
||||
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<CCSPlayerController>(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<Skills, string> _skillNames =
|
||||
Enum.GetValues<Skills>().ToDictionary(s => s, s => s.ToString());
|
||||
private static readonly HashSet<Skills> _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<uint, jSkill_SkillInfo> 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
|
|||
? ""
|
||||
: $"<br>{emptySymbol}<font class='fontSize-{(isDescription ? config.SkillDescriptionLineSize : config.InfoLineSize)}' color='{(isDescription ? config.SkillDescriptionLineColor : config.InfoLineColor)}'>{extraLine}</font>{emptySymbol}";
|
||||
|
||||
var hudContent = infoLine + skillLine + remainingLine;
|
||||
|
||||
var hudContent = "<jRS/>" + infoLine + skillLine + remainingLine;
|
||||
player.PrintToCenterHtml(hudContent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Binary file not shown.
18
updater.json
18
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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue