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
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-03-2017 , 07:14   Re: [callfunc_begin_i] Public function -1 is invalid
Reply With Quote #6

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

klippy 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:45.


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