From bc16947907c1e9c7e005b85dfad000d07874212b Mon Sep 17 00:00:00 2001 From: frothy-wifi Date: Mon, 8 Apr 2024 16:40:53 -0500 Subject: [PATCH] Final v1.3 files --- manifest.json | 4 +- mods/FrothyWiFi.CYNHUD/mod.json | 10 ++-- .../mod/scripts/vscripts/cynhud.nut | 52 +++++++++++++++---- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/manifest.json b/manifest.json index b7583dd..69d371b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "CYNHUD", - "version_number": "1.2.1", + "version_number": "1.3.0", "website_url": "https://github.com/frothy-wifi/CYNHUD", - "description": "Adds an easily customizable (through Mod Settings) message to your HUD. The default message is a Cyn reference.", + "description": "Adds an easily customizable (through Mod Settings) message to your HUD and useful game commands.", "dependencies": [] } \ No newline at end of file diff --git a/mods/FrothyWiFi.CYNHUD/mod.json b/mods/FrothyWiFi.CYNHUD/mod.json index 9d38d45..35ec0d4 100755 --- a/mods/FrothyWiFi.CYNHUD/mod.json +++ b/mods/FrothyWiFi.CYNHUD/mod.json @@ -1,17 +1,19 @@ { "Name": "FrothyWiFi.CYNHUD", - "Description": "Adds an easily customizable (through Mod Settings) message to your HUD. The default message is a Cyn reference.", + "Description": "Adds an easily customizable (through Mod Settings) message to your HUD and useful game commands.", "LoadPriority": 2, "RequiredOnClient": false, - "Version": "1.2.1", + "Version": "1.3.0", "ConVars": [ { "Name": "ch_hud_message", - "DefaultValue": "get snuck-up on" + "DefaultValue": "get snuck-up on", + "HelpString": "The message CYNHUD will display on your HUD." }, { "Name": "ch_hud_message_pos", - "DefaultValue": "Middle" + "DefaultValue": "Middle", + "HelpString": "The position of the message CYNHUD will display on your HUD. (Bottom, Middle, Top)" } ], "Scripts": [ diff --git a/mods/FrothyWiFi.CYNHUD/mod/scripts/vscripts/cynhud.nut b/mods/FrothyWiFi.CYNHUD/mod/scripts/vscripts/cynhud.nut index 7b991d0..66f558d 100755 --- a/mods/FrothyWiFi.CYNHUD/mod/scripts/vscripts/cynhud.nut +++ b/mods/FrothyWiFi.CYNHUD/mod/scripts/vscripts/cynhud.nut @@ -1,18 +1,30 @@ global function CynHud_Init; #if CLIENT -void function CynHud_WriteChatMessage(string message) { - Chat_GameWriteLine("\x1b[113mCYNHUD Control:\x1b[0m " + message); -} - -void function CynHud_Init() { - thread CynHud_DoMessage(); -} - var rui = null; string mapName = ""; string message = ""; string messagePos = ""; +bool shouldReload = false; +bool hasShownWelcomeTextAlready = false; + +ClClient_MessageStruct function CynHud_CommandFilter(ClClient_MessageStruct message) { + if (message.message == "$ch.help") { + message.shouldBlock = true; + Chat_GameWriteLine("\x1b[33m--== CYNHUD commands ==--\x1b[0m"); + Chat_GameWriteLine("All CYNHUD commands \x1b[112mmust\x1b[0m be prefaced with \x1b[33m\"$ch.\"\x1b[0m."); + Chat_GameWriteLine("\x1b[33m$ch.help\x1b[0m - Show available commands."); + Chat_GameWriteLine("\x1b[33m$ch.reload\x1b[0m - Reload the HUD message manually.") + Chat_GameWriteLine("\x1b[33m$ch.uid\x1b[0m - Show your user ID. CYNHUD also uses this to greet you."); + } else if (message.message == "$ch.reload") { + message.shouldBlock = true; + shouldReload = true; + } else if (message.message == "$ch.uid") { + message.shouldBlock = true; + CynHud_WriteChatMessage("You are Pilot \x1b[111m" + NSGetLocalPlayerUID() + "\x1b[0m."); + } + return message; +} void function CynHud_ConfigureRui() { RuiSetInt(rui, "maxLines", 1); @@ -47,17 +59,37 @@ void function CynHud_DoMessage() { while (mapName == GetMapName()) { WaitFrame(); + if (!hasShownWelcomeTextAlready && mapName != "mp_lobby") { + CynHud_WriteChatMessage("Welcome back, \x1b[111m" + NSGetLocalPlayerUID() + "\x1b[0m. Run $ch.help for a list of commands."); + hasShownWelcomeTextAlready = true; + } + if (shouldReload) { + shouldReload = false; + RuiDestroy(rui); + CynHud_WriteChatMessage("Manual reload request recieved; reloading HUD message."); + CynHud_DoMessage(); + } if (GetConVarString("ch_hud_message") != message) { RuiDestroy(rui); - CynHud_WriteChatMessage("Reloading HUD message."); + CynHud_WriteChatMessage("Message changed; reloading HUD message."); CynHud_DoMessage(); } if (GetConVarString("ch_hud_message_pos") != messagePos) { RuiDestroy(rui); - CynHud_WriteChatMessage("Reloading HUD message."); + CynHud_WriteChatMessage("Message position changed; reloading HUD message."); CynHud_DoMessage(); } } RuiDestroy(rui); + hasShownWelcomeTextAlready = false; +} + +void function CynHud_WriteChatMessage(string message) { + Chat_GameWriteLine("\x1b[33mCYNHUD:\x1b[0m " + message); +} + +void function CynHud_Init() { + AddCallback_OnReceivedSayTextMessage(CynHud_CommandFilter); + thread CynHud_DoMessage(); } #endif \ No newline at end of file