# HG changeset patch # User David Anderson # Date 1179884640 0 # Node ID de0223664adc2a88c57c4ae113b335642f6f4f15 # Parent baa0ec2b5ac736d0e5f0344dca4ed6fe778f7553 added request amb293 - SetFailState diff -r baa0ec2b5ac7 -r de0223664adc core/smn_core.cpp --- a/core/smn_core.cpp Tue May 22 23:45:53 2007 +0000 +++ b/core/smn_core.cpp Wed May 23 01:44:00 2007 +0000 @@ -246,6 +246,17 @@ 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 @@ {"MorePlugins", MorePlugins}, {"ReadPlugin", ReadPlugin}, {"ThrowError", ThrowError}, + {"SetFailState", SetFailState}, {NULL, NULL}, }; diff -r baa0ec2b5ac7 -r de0223664adc plugins/include/sourcemod.inc --- a/plugins/include/sourcemod.inc Tue May 22 23:45:53 2007 +0000 +++ b/plugins/include/sourcemod.inc Wed May 23 01:44:00 2007 +0000 @@ -213,6 +213,16 @@ 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. *