diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index ab600e12..a799213c 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -29,15 +29,22 @@ struct Plugin public Plugin:myinfo; /** - * Called when the plugin is fully initialized and all known external references are resolved, - * such as dynamic natives. + * Called when the plugin is fully initialized and all known external references are resolved. + * This is called even if the plugin type is "private." + * NOTE: Errors in this function will cause the plugin to stop running. * * @noreturn */ -forward OnPluginInit(); +forward OnPluginInit(Handle:myself); /** - * Called before OnPluginInit, in case the plugin wants to check for load failure. + * Called before OnPluginInit, in case the plugin wants to check for load failure. + * This is called even if the plugin type is "private." Any natives from modules are + * not available at this point. Thus, this forward should only be used for explicit + * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters. + * + * NOTE: It is not safe to call externally resolved natives until OnPluginInit(). + * NOTE: Any sort of RTE in this function will cause the plugin to fail loading. * * @param myself Handle to the plugin. * @param late Whether or not the plugin was loaded "late" (after map load). @@ -45,14 +52,7 @@ forward OnPluginInit(); * @param err_max Maximum number of characters for error message buffer. * @return True if load success, false otherwise. */ -forward bool:OnPluginLoad(Handle:myself, bool:late, String:error[], err_max); - -/** - * Called when the plugin is first mapped into memory. Use this to set dynamic natives ONLY. - * - * @noreturn - */ -forward OnCreatePlugin(); +forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max); /** * Called when the plugin is about to be unloaded. diff --git a/plugins/test.sma b/plugins/test.sma index fa317e82..af46f8c6 100644 --- a/plugins/test.sma +++ b/plugins/test.sma @@ -9,16 +9,21 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" } -public Test(num, &num2) +copy(String:dest[], maxlength, const String:source[]) { - num2 += num + new len - return num + while (source[len] != '\0' && len < maxlength) + { + dest[len] = source[len] + len++ + } + + dest[len] = '\0' } -public Test2(num, &num2) +public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) { - num2 += num - - return num + copy(error, err_max, "I don't like food anymore!") + return false }