diff --git a/core/smn_hudtext.cpp b/core/smn_hudtext.cpp index 6f7af02e..d1b90bf1 100644 --- a/core/smn_hudtext.cpp +++ b/core/smn_hudtext.cpp @@ -70,6 +70,7 @@ struct hud_text_parms float holdTime; float fxTime; int channel; + bool isSet = false; }; class HudMsgHelpers : @@ -282,6 +283,7 @@ static cell_t SetHudTextParams(IPluginContext *pContext, const cell_t *params) g_hud_params.g2 = 255; g_hud_params.b2 = 250; g_hud_params.a2 = 0; + g_hud_params.isSet = true; return 1; } @@ -308,6 +310,7 @@ static cell_t SetHudTextParamsEx(IPluginContext *pContext, const cell_t *params) g_hud_params.g2 = static_cast(color2[1]); g_hud_params.b2 = static_cast(color2[2]); g_hud_params.a2 = static_cast(color2[3]); + g_hud_params.isSet = true; return 1; } @@ -384,6 +387,11 @@ static cell_t ShowSyncHudText(IPluginContext *pContext, const cell_t *params) return -1; } + if (!g_hud_params.isSet) + { + return pContext->ThrowNativeError("ShowSyncHudText first requires a call to SetHudTextParams or SetHudTextParamsEx"); + } + if ((err = s_HudMsgHelpers.ReadHudSyncObj(params[2], pContext->GetIdentity(), &obj)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[2], err); @@ -468,6 +476,11 @@ static cell_t ShowHudText(IPluginContext *pContext, const cell_t *params) return -1; } + if (!g_hud_params.isSet) + { + return pContext->ThrowNativeError("ShowHudText first requires a call to SetHudTextParams or SetHudTextParamsEx"); + } + client = params[1]; if ((pPlayer = g_Players.GetPlayerByIndex(client)) == NULL) {