diff --git a/core/smn_core.cpp b/core/smn_core.cpp index cd8de231..67c413c6 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -371,12 +371,35 @@ static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params) static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) { char *str; + CPlugin *pPlugin; + pContext->LocalToString(params[1], &str); + pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); - CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); - pPlugin->SetErrorState(Plugin_Error, "%s", str); + if (params[0] == 1) + { + pPlugin->SetErrorState(Plugin_Error, "%s", str); - return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); + return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); + } + else + { + char buffer[2048]; + + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1); + if (pContext->GetContext()->n_err != SP_ERROR_NONE) + { + pPlugin->SetErrorState(Plugin_Error, "%s", str); + return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "Formatting error (%s)", str); + } + else + { + pPlugin->SetErrorState(Plugin_Error, "%s", buffer); + return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer); + } + } + + return 0; } static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params) diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index a353b425..0f625607 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -282,11 +282,21 @@ native Handle:FindPluginByNumber(order_num); * Causes the plugin to enter a failed state. An error will be thrown and * the plugin will be paused until it is unloaded or reloaded. * - * @param string Message to print. + * For backwards compatibility, if no extra arguments are passed, no + * formatting is applied. If one or more additional arguments is passed, + * the string is formatted using Format(). If any errors are encountered + * during formatting, both the format specifier string and an additional + * error message are written. + * + * This function does not return, and no further code in the plugin is + * executed. + * + * @param string Format specifier string. + * @param ... Formatting arguments. * @noreturn * @error Always throws SP_ERROR_ABORT. */ -native SetFailState(const String:string[]); +native SetFailState(const String:string[], any:...); /** * Aborts the current callback and throws an error. This function