Quote:
Originally Posted by KliPPy
PHP Code:
public plugin_natives()
{
register_native("some_native", "some_native_handler");
}
// In 1.8.3 it has been increased to 64
#if AMXX_VERSION_NUM < 183
const MAX_FUNCTIONNAME_LENGTH = 32;
#else
const MAX_FUNCTIONNAME_LENGTH = 64;
#endif
//native some_native(const callbackFunctionName[]);
public some_native_handler(pluginId, paramCount)
{
new callbackFunctionName[MAX_FUNCTIONNAME_LENGTH];
get_string(1, callbackFunctionName, charsmax(callbackFunctionName));
// Create a forward with 1 cell parameter
new const forwardHandle = CreateOneForward(pluginId, callbackFunctionName, FP_CELL);
new returnValue; // Whatever the called function returns will be stored here
// Execute the function with first parameter's value being 5
ExecuteForward(forwardHandle, returnValue, 5);
// Make sure to destroy it when you don't need it anymore
DestroyForward(forwardHandle);
}
// In that other plugin
native some_native(const callbackFunctionName[]);
someFunction()
{
some_native("MyFunction");
}
public MyFunction(param)
{
// param's value is 5
return 10; // `returnValue` will be 10 in the main plugin
}
|
The usage in external plugins would be same as the current method, right? Thanks.
__________________