Raised This Month: $ Target: $400
 0% 

Solved [callfunc_begin_i] Public function -1 is invalid


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-04-2017 , 12:52   Re: [callfunc_begin_i] Public function -1 is invalid
Reply With Quote #7

Quote:
Originally Posted by KliPPy View Post
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(pluginIdparamCount)
{
    new 
callbackFunctionName[MAX_FUNCTIONNAME_LENGTH];
    
get_string(1callbackFunctionNamecharsmax(callbackFunctionName));
    
    
// Create a forward with 1 cell parameter
    
new const forwardHandle CreateOneForward(pluginIdcallbackFunctionNameFP_CELL);
    
    new 
returnValue// Whatever the called function returns will be stored here
    // Execute the function with first parameter's value being 5
    
ExecuteForward(forwardHandlereturnValue5);
    
    
// 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.
__________________
edon1337 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode