added request amb293 - SetFailState
authorDavid Anderson <dvander@alliedmods.net>
Wed May 23 01:44:00 2007 +0000 (2007-05-23)
changeset 837de0223664adc
parent 836 baa0ec2b5ac7
child 838 1a610bdea281
added request amb293 - SetFailState
core/smn_core.cpp
plugins/include/sourcemod.inc
     1.1 --- a/core/smn_core.cpp	Tue May 22 23:45:53 2007 +0000
     1.2 +++ b/core/smn_core.cpp	Wed May 23 01:44:00 2007 +0000
     1.3 @@ -246,6 +246,17 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t SetFailState(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	char *str;
    1.10 +	pContext->LocalToString(params[1], &str);
    1.11 +
    1.12 +	CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
    1.13 +	pPlugin->SetErrorState(Plugin_Error, "%s", str);
    1.14 +
    1.15 +	return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str);
    1.16 +}
    1.17 +
    1.18  REGISTER_NATIVES(coreNatives)
    1.19  {
    1.20  	{"GetPluginFilename",	GetPluginFilename},
    1.21 @@ -257,5 +268,6 @@
    1.22  	{"MorePlugins",			MorePlugins},
    1.23  	{"ReadPlugin",			ReadPlugin},
    1.24  	{"ThrowError",			ThrowError},
    1.25 +	{"SetFailState",		SetFailState},
    1.26  	{NULL,					NULL},
    1.27  };
     2.1 --- a/plugins/include/sourcemod.inc	Tue May 22 23:45:53 2007 +0000
     2.2 +++ b/plugins/include/sourcemod.inc	Wed May 23 01:44:00 2007 +0000
     2.3 @@ -213,6 +213,16 @@
     2.4  native bool:GetPluginInfo(Handle:plugin, PluginInfo:info, String:buffer[], maxlength);
     2.5  
     2.6  /**
     2.7 + * Causes the plugin to enter a failed state.  An error will be thrown and
     2.8 + * the plugin will be paused until it is unloaded or reloaded.
     2.9 + *
    2.10 + * @param string		Message to print.
    2.11 + * @noreturn
    2.12 + * @error				Always.
    2.13 + */
    2.14 +native SetFailState(const String:string[]);
    2.15 +
    2.16 +/**
    2.17   * Aborts the current callback and throws an error.  This function
    2.18   * does not return in that no code is executed following it.
    2.19   *