This is the core plugin (jumpstats.amxx)
Code:
public plugin_natives()
{
register_library("jumpstats");
register_native("js_register_tech", "_register_tech");
}
public _register_tech(plugin, params)
{
if( g_total_jump_types == MAX_JUMP_TYPES )
{
log_amx("Unable to add more jump types.");
return JUMP_TYPE_ERROR;
}
static name[32], prefix[8];
get_string(1, name, sizeof(name) - 1);
get_string(2, prefix, sizeof(prefix) - 1);
log_amx("New jump type: %i - %s - %s", g_total_jump_types, name, prefix);
return g_total_jump_types++;
}
And it logs everything correctly:
Code:
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 0 - LongJump - lj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 1 - HighJump - hj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 2 - WeirdJump - wj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 3 - CountJump - cj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 4 - Double CountJump - dcj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 5 - Multi CountJump - mcj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 6 - Drop CountJump - drcj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 7 - BhopJump - bj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 8 - StandUp BhopJump - sbj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 9 - Drop BhopJump - dbj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 10 - StandUp Drop BhopJump - sdbj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 11 - LadderJump - laj
L 07/18/2009 - 18:42:18: [jumpstats.amxx] New jump type: 12 - LadderBhop - lab
Then I have this code for the sub-plugins (plugins with 1 technique don't loop):
Code:
// From jumpstats.inc:
#if defined _jumpstats_included
#endinput
#endif
#define _jumpstats_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib jumpstats
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib jumpstats
#endif
#else
#pragma library jumpstats
#endif
native js_register_tech(const name[], const prefix[]);
// Using the js_longjump.sma for the example
enum
{
TYPE_LONG,
TYPE_HIGH,
TYPE_TOTAL
};
new const g_jump_names[TYPE_TOTAL][] =
{
"LongJump",
"HighJump"
};
new const g_jump_prefixes[TYPE_TOTAL][] =
{
"lj",
"hj"
};
public plugin_init()
{
for( new i = 0; i < TYPE_TOTAL; i++ )
{
g_jump_ids[i] = js_register_tech(g_jump_names[i], g_jump_prefixes[i]);
if( g_jump_ids[i] == JUMP_TYPE_ERROR )
{
set_fail_state("Failed to register jump type.");
}
else
{
log_amx("Successfully registered technique [ID: %i] [Name: %s]", g_jump_ids[i], g_jump_names[i]);
}
}
}
And it gives me this output:
Code:
L 07/18/2009 - 18:42:18: [js_longjump.amxx] Successfully registered technique [ID: 1] [Name: LongJump]
L 07/18/2009 - 18:42:18: [js_longjump.amxx] Successfully registered technique [ID: 1] [Name: HighJump]
L 07/18/2009 - 18:42:18: [js_weirdjump.amxx] Successfully registered technique [ID: 1] [Name: WeirdJump]
L 07/18/2009 - 18:42:18: [js_countjump.amxx] Successfully registered technique [ID: 1] [Name: CountJump]
L 07/18/2009 - 18:42:18: [js_countjump.amxx] Successfully registered technique [ID: 1] [Name: Double CountJump]
L 07/18/2009 - 18:42:18: [js_countjump.amxx] Successfully registered technique [ID: 1] [Name: Multi CountJump]
L 07/18/2009 - 18:42:18: [js_countjump.amxx] Successfully registered technique [ID: 1] [Name: Drop CountJump]
L 07/18/2009 - 18:42:18: [js_bhopjump.amxx] Successfully registered technique [ID: 1] [Name: BhopJump]
L 07/18/2009 - 18:42:18: [js_bhopjump.amxx] Successfully registered technique [ID: 1] [Name: StandUp BhopJump]
L 07/18/2009 - 18:42:18: [js_bhopjump.amxx] Successfully registered technique [ID: 1] [Name: Drop BhopJump]
L 07/18/2009 - 18:42:18: [js_bhopjump.amxx] Successfully registered technique [ID: 1] [Name: StandUp Drop BhopJump]
L 07/18/2009 - 18:42:18: [js_ladderjump.amxx] Successfully registered technique [ID: 1] [Name: LadderJump]
L 07/18/2009 - 18:42:18: [js_ladderjump.amxx] Successfully registered technique [ID: 1] [Name: LadderBhop]
It always returns 1 from the native, but I have no idea why.
It should return the "g_total_jump_types" variable from jumpstats.amxx, but it doesn't.
__________________