diff --git a/core/smn_core.cpp b/core/smn_core.cpp index 08891f3e..7e76cdba 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -246,6 +246,17 @@ static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) +{ + char *str; + pContext->LocalToString(params[1], &str); + + CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); + pPlugin->SetErrorState(Plugin_Error, "%s", str); + + return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); +} + REGISTER_NATIVES(coreNatives) { {"GetPluginFilename", GetPluginFilename}, @@ -257,5 +268,6 @@ REGISTER_NATIVES(coreNatives) {"MorePlugins", MorePlugins}, {"ReadPlugin", ReadPlugin}, {"ThrowError", ThrowError}, + {"SetFailState", SetFailState}, {NULL, NULL}, }; diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 170d0b52..bed7208d 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -212,6 +212,16 @@ native bool:IsPluginDebugging(Handle:hndl); */ native bool:GetPluginInfo(Handle:plugin, PluginInfo:info, String:buffer[], maxlength); +/** + * 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. + * @noreturn + * @error Always. + */ +native SetFailState(const String:string[]); + /** * Aborts the current callback and throws an error. This function * does not return in that no code is executed following it.