Tags doesn't actually do anything except makes the compiler capable of telling you that you might have used a variable in the wrong context. After compilation they're basically gone.
However, if you end up using a tag and enforce it's usage in other plugins I would recommend putting them in the API plugin as well.
The enum is basically useless in your API plugin if you're not using them individually in any way. It should be in the include which is used for the secondary plugin, along with the native declaration.
I strongly suggest using the first example of these.
Code:
// API Plugin
public plugin_natives()
register_native("ExampleNative", "nativeExample");
public nativeExample(plugin, params)
{
return 999;
}
// Secondary Plugin
native ExampleNative();
Data ends up here
|
V
new data = ExampleNative();
Code:
// API Plugin
public plugin_natives()
register_native("ExampleNative", "nativeExample");
public nativeExample(plugin, params)
{
set_param_byref(1, 999);
}
// Secondary Plugin
native ExampleNative(&data);
Data ends up here
|
V
ExampleNative(data);
If you're using tagged byref. Look how CsTeams based natives are declared in the include for guidance:
Code:
native CsTeams:cs_get_user_team(index, &{CsInternalModel,_}:model = CS_DONTCHANGE);
Example of tag mismatching still working fine
GetPlayerType1(), sends tagged, receives as tagged.
GetPlayerType2(), sends UNtagged, receives as tagged.
GetPlayerType3(), sends tagged, receives as UNtagged.
GetPlayerType4(), sends UNtagged, receives as UNtagged.
Code:
new PlayerClass:PlayerType[33]
public plugin_init()
{
register_plugin("Test Plugin 2", "1.0", "[ --{-@ ]");
}
public plugin_natives()
{
register_native("GetPlayerType1", "native_GetPlayerType1");
register_native("GetPlayerType2", "native_GetPlayerType2");
register_native("GetPlayerType3", "native_GetPlayerType1");
register_native("GetPlayerType4", "native_GetPlayerType2");
PlayerType[0] = PlayerClass:1;
PlayerType[1] = PlayerClass:2;
PlayerType[2] = PlayerClass:3;
PlayerType[3] = PlayerClass:4;
}
public PlayerClass:native_GetPlayerType1(plugin, params)
{
new id = get_param(1);
return PlayerType[id];
}
public native_GetPlayerType2(plugin, params)
{
new id = get_param(1);
return _:PlayerType[id];
}
Code:
enum PlayerClass
{
Class1,
Class2 // et.c...
};
native PlayerClass:GetPlayerType1(id);
native PlayerClass:GetPlayerType2(id);
native GetPlayerType3(id);
native GetPlayerType4(id);
public plugin_init()
{
server_print("Method 1: %d", GetPlayerType1(0));
server_print("Method 2: %d", GetPlayerType2(1));
server_print("Method 3: %d", GetPlayerType3(2));
server_print("Method 4: %d", GetPlayerType4(3));
Code:
Method 1: 1
Method 2: 2
Method 3: 3
Method 4: 4
__________________