diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 9dc9d8c9..ac128dad 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -881,6 +881,63 @@ native rg_send_bartime2(const index, const duration, const Float:startPercent, c */ native rg_send_audio(const index, const sample[], const pitch = PITCH_NORM); +/** +* Sends a HUD message using the new queue system without formatting. +* +* @param index Client index, use 0 to display to all players +* @param message Message to send +* @param red Red color component +* @param green Green color component +* @param blue Blue color component +* @param x X position +* @param y Y position +* @param effects Effects +* @param fxtime FX Time +* @param holdtime Hold time +* @param fadeintime Fade in time +* @param fadeouttime Fade out time +* @param channel Channel +* +* @noreturn +*/ +native rg_send_hudmessage(const index, const message[], const red = 200, const green = 100, const blue = 0, const Float:x = -1.0, const Float:y = 0.35, const effects = 0, const Float:fxtime = 6.0, const Float:holdtime = 12.0, const Float:fadeintime = 0.1, const Float:fadeouttime = 0.2, const channel = 0); + +stock Float:__rg_hud_params[10]; +stock __rg_hud_colors[4]; + +/** +* Simulates the old set_hudmessage by saving parameters to globals. +*/ +stock rg_set_hudmessage(red=200, green=100, blue=0, Float:x=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2, channel=0) { + __rg_hud_colors[0] = red; + __rg_hud_colors[1] = green; + __rg_hud_colors[2] = blue; + __rg_hud_colors[3] = channel; + + __rg_hud_params[0] = x; + __rg_hud_params[1] = y; + __rg_hud_params[2] = float(effects); + __rg_hud_params[3] = fxtime; + __rg_hud_params[4] = holdtime; + __rg_hud_params[5] = fadeintime; + __rg_hud_params[6] = fadeouttime; +} + +/** +* Simulates the old show_hudmessage, automatically formatting the text and pushing to the queue. +*/ +stock rg_show_hudmessage(const index, const message[], any:...) { + new buffer[512]; + vformat(buffer, charsmax(buffer), message, 3); + + rg_send_hudmessage(index, buffer, + __rg_hud_colors[0], __rg_hud_colors[1], __rg_hud_colors[2], + __rg_hud_params[0], __rg_hud_params[1], + floatround(__rg_hud_params[2]), // effects + __rg_hud_params[3], __rg_hud_params[4], __rg_hud_params[5], __rg_hud_params[6], + __rg_hud_colors[3]); +} + /** * Sets a parameter of the member CSPlayerItem::m_ItemInfo * diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index 8222d68b..82583f92 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -858,6 +858,7 @@ class IReGameApi { virtual struct AmmoInfoStruct *GetAmmoInfoEx(const char *ammoName) = 0; virtual bool BGetICSEntity(const char *pchVersion) const = 0; virtual bool BGetIGameRules(const char *pchVersion) const = 0; + virtual void QueueHudMessage(int client, const struct hudtextparms_s &textparms, const char *pMessage) = 0; }; #define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001" diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 4e813bea..f94148b8 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -2138,6 +2138,65 @@ enum ItemInfo_e ItemInfo_iWeight }; +/** +* Sends a HUD message using the new queue system +* +* @param index Client index, use 0 to display to all players +* @param message Message to send +* @param red Red color component +* @param green Green color component +* @param blue Blue color component +* @param x X position +* @param y Y position +* @param effects Effects +* @param fxtime FX Time +* @param holdtime Hold time +* @param fadeintime Fade in time +* @param fadeouttime Fade out time +* @param channel Channel +* +* @noreturn +*/ +cell AMX_NATIVE_CALL rg_send_hudmessage(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index, arg_message, arg_red, arg_green, arg_blue, arg_x, arg_y, arg_effects, arg_fxtime, arg_holdtime, arg_fadeintime, arg_fadeouttime, arg_channel }; + + if (!g_ReGameApi) + return FALSE; + + int nIndex = params[arg_index]; + if (nIndex < 0 || nIndex > gpGlobals->maxClients) { + AMXX_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", nIndex); + return FALSE; + } + + char message[512]; + const char *szMessage = getAmxString(amx, params[arg_message], message); + + hudtextparms_t textparms; + textparms.r1 = params[arg_red]; + textparms.g1 = params[arg_green]; + textparms.b1 = params[arg_blue]; + textparms.a1 = 0; + + textparms.r2 = 255; + textparms.g2 = 255; + textparms.b2 = 250; + textparms.a2 = 0; + + textparms.x = *(float *)¶ms[arg_x]; + textparms.y = *(float *)¶ms[arg_y]; + textparms.effect = params[arg_effects]; + textparms.fxTime = *(float *)¶ms[arg_fxtime]; + textparms.holdTime = *(float *)¶ms[arg_holdtime]; + textparms.fadeinTime = *(float *)¶ms[arg_fadeintime]; + textparms.fadeoutTime = *(float *)¶ms[arg_fadeouttime]; + textparms.channel = params[arg_channel]; + + g_ReGameApi->QueueHudMessage(nIndex, textparms, szMessage); + return TRUE; +} + /** * Sets a parameter of the member CSPlayerItem::m_ItemInfo * @@ -3547,6 +3606,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_send_bartime", rg_send_bartime }, { "rg_send_bartime2", rg_send_bartime2 }, { "rg_send_audio", rg_send_audio }, + { "rg_send_hudmessage", rg_send_hudmessage }, { "rg_set_iteminfo", rg_set_iteminfo }, { "rg_get_iteminfo", rg_get_iteminfo },