What I want to achieve is to add the ability to change the HUD color by firing a map entity, because sometimes the player will be playing as different characters. After reading this amazing tutorial, I created a static class called
HUDManager
with static fields defining the RGB values, as well as a static method to change these values. I modified the UnpackRGB()
method to use the values from this class, and so far, it has worked with the default values (though I haven’t yet tried to use this method at runtime).After a few more hours spent reading the SDK code and tutorials, I created an entity class, linked it, and... suddenly realized that entities are defined and declared on the server side, while my
HUDManager
is on the client side. So now I need a way to call a client-side method from the server.I found this tutorial on temporary entity messages, which seems like what I need (or at least something very similar). However, it doesn’t fully solve my problem - none of the constants defined in
const.h
(from hl_cdll
) seem to help.I also found a file called
UserMessages.cpp
in hldll
, which seems to use the REG_USER_MSG
method. This is a macro for g_engfuncs.pfnRegUserMsg
, which I presume, based on the file name and the comment above enginefuncs_s
, is an interface to an engine function of the same name. Since the engine’s code is not open-source, I can’t dig deeper to verify if this is the function I need. That’s why I’m asking for help.Some possibly useful information: I’m using the Half-Life Unified SDK, and my mod is intended to be entirely single-player.
I feel like this might be a very basic question that's already been answered somewhere, or there may be a tutorial about it that I just haven't found yet. Forgive my dumb C# brain xd
Oh, and if I’ve already posted this… I assume that after changing static variables of
HUDManager
at runtime (which I haven’t yet tested), I’ll need to manually redraw the HUD to apply the new colors. My second question is: how can I do this? I found the gHUD
variable in cdll_int.h
, which I assume is the main HUD variable on the client side? The CHud
class (to which gHUD
belongs) has a Redraw
method with two arguments: flTime
and intermission
. What exactly does flTime
refer to (specifically the m_flTime
variable, which is assigned in the Redraw
method)? The comment says it's "the current client time," but the current time in what context and in what format? m_flTime
is used in so many places that I can’t quite grasp its meaning.