Raised This Month: $51 Target: $400
 12% 

Dynamic native always giving 1 as return


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-18-2009 , 20:29   Dynamic native always giving 1 as return
Reply With Quote #1

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 07-18-2009 , 20:48   Re: Dynamic native always giving 1 as return
Reply With Quote #2

prefix[8] ... i already told you its neither a prefix nor a suffix it should be abbreviation

Code:
ab·bre·vi·a·tion
-The act or product of shortening.
-A shortened form of a word or phrase used chiefly in writing to represent the complete form, such as Mass. for Massachusetts or USMC for United States Marine Corps.
// just as a little example since you use it in your code: "tech" is an abbreviation of "technique" :P

pre·fix
- To put or attach before or in front of.
- [Grammar]  An affix, such as dis- in disbelieve, attached to the front of a word to produce a derivative word or an inflected form.
b2t: did you try to return the variable without post incrementing yet?
__________________

Last edited by SchlumPF*; 07-18-2009 at 20:51.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-18-2009 , 20:52   Re: Dynamic native always giving 1 as return
Reply With Quote #3

Quote:
Originally Posted by SchlumPF* View Post
b2t: did you try to return the variable without post incrementing yet?
This shouldn't help since returns value should be from 0 to 12.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-18-2009 at 20:58.
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-18-2009 , 20:55   Re: Dynamic native always giving 1 as return
Reply With Quote #4

Quote:
Originally Posted by SchlumPF* View Post
prefix[8] ... i already told you its neither a prefix nor a suffix it should be abbreviation

Code:
ab·bre·vi·a·tion
-The act or product of shortening.
-A shortened form of a word or phrase used chiefly in writing to represent the complete form, such as Mass. for Massachusetts or USMC for United States Marine Corps.
// just as a little example since you use it in your code: "tech" is an abbreviation of "technique" :P

pre·fix
- To put or attach before or in front of.
- [Grammar]  An affix, such as dis- in disbelieve, attached to the front of a word to produce a derivative word or an inflected form.
b2t: did you try to return the variable without post incrementing yet?
I know my English. I know that prefix is not the correct word for this, but "abbreviation" is.
However, in the earlier versions, it was used as a prefix for something, which is why I'm keeping it that.
Also, "abbreviation" is too long.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 07-18-2009 , 21:36   Re: Dynamic native always giving 1 as return
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
This shouldn't help since returns value should be from 0 to 12.
i just asked this because i cant see any mistake in this either but using the var without incrementing jsut works fine while returning it with a post incremental doesnt.

Quote:
Originally Posted by Exolent[jNr] View Post
I know my English. I know that prefix is not the correct word for this, but "abbreviation" is.
However, in the earlier versions, it was used as a prefix for something, which is why I'm keeping it that.
Also, "abbreviation" is too long.
thats exactly why i had to write that... your english is crap!!! it just hurts my eyes to see such nonsense (calling lj a prefix).
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-18-2009 , 22:09   Re: Dynamic native always giving 1 as return
Reply With Quote #6

Quote:
Originally Posted by SchlumPF* View Post
i just asked this because i cant see any mistake in this either but using the var without incrementing jsut works fine while returning it with a post incremental doesnt.
So you're saying that this should work:

Code:
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);         g_total_jump_types++;         return g_total_jump_types-1; }

EDIT:

It does work. Thanks.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 07-18-2009 at 22:15.
Exolent[jNr] is offline
Reply



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 08:36.


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