Ok, I think I finally get it!
So we have this
first plugin:
PHP Code:
new anInt;
//We call this because OnPluginLoad() is apparently called too late. I mean just look at the name of this, it honestly looks like it belongs in here.
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
CreateNative("setAnInt", native_setAnInt);
RegPluginLibrary("uselessnatives.inc");
return APLRes_Success;
}
public native_getAnInt(Handle:plugin, numParams)
{
return anInt;
}
public native_setAnInt(Handle:plugin, numParams)
{
//setAnInt(value);
new set = GetNativeCell(2); //First param, the value we'll be setting int to.
anInt = set;
return;
}
then we have this strange
include file:
PHP Code:
#if defined _uselessnatives_included
#endinput
#endif
#define _uselessnatives_included
native native_setAnInt(int, value);
and finally
second plugin:
PHP Code:
#include <uselessnatives>
public OnPluginStart()
{
RegConsoleCmd("sm_nativeprint", command_printNatives, "Print what you set");
}
public Action:command_printNatives(client, args)
{
setAnInt(50);
getAnInt();
return Plugin_Handled;
}
Sooooooooooooooo... What is happening here
?
1) setAnInt(50) from second plugin is actually a function. Function from first plugin called
native_setAnInt.
2) it pass the value 50 via
uselessnatives.inc
3) uselessnatives.inc communicate with
CreateNative("setAnInt", native_setAnInt) from first plugin
4) and by this magic, 50 is set in
native_setAnInt function in first plugin. This function than changes value of anInt = 50.
That's setAnInt. Passing data from second plugin to the first plugin.
After it is set (passed) it is called by a function getAnInt. And there is no need for magic? It is just called like this? Directly?
I need to pass an array from first plugin to second. Only one-way. What do I need???