Raised This Month: $ Target: $400
 0% 

Native help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-01-2018 , 17:20   Native help
Reply With Quote #1

I'm trying to test some stuff but it doesn't work.

get_user_level(id) simply returns 0 while i set iLevel[33] = 5 in the main plugin. what's wrong?

my include file is called level_test.inc

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Native Test" #define VERSION "1.0" #define AUTHOR "author" new iLevel[33] = 5 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     } public plugin_natives() {     register_library("level_test")         register_native("get_user_level", "_get_user_level") } public _get_user_level(iPlugin, iParams) {     if(iParams != 1) {         return PLUGIN_CONTINUE     }         new id = get_param(1)         if(!id) {         return PLUGIN_CONTINUE     }         return iLevel[id] }

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <level_test> #define PLUGIN "Test Plugin" #define VERSION "1.0" #define AUTHOR "author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say /test", "Test") } public Test(id) {     client_print(id, print_chat, "level: %d", get_user_level(id)) }

Code:
#pragma reqlib "level_test" native get_user_level(id)
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-01-2018 , 18:03   Re: Native help
Reply With Quote #2

new iLevel[33] = {5, ...}
__________________
HamletEagle is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-04-2018 , 06:18   Re: Native help
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
new iLevel[33] = {5, ...}

Well this was just to test something, thanks for your response.

How should it be done in a level system with the same array structure?

Native is meant to be used in a top 10 system.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-04-2018 , 07:09   Re: Native help
Reply With Quote #4

The native is correct. What is not correct is how you initialize your variable(meaning the test is wrong).
new iLevel[33] = 5 will set only index 0 to 5, the others remain 0. That's why your native returns 0. To set the entire array you must use the syntax I provided.
__________________

Last edited by HamletEagle; 05-04-2018 at 07:10.
HamletEagle is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-07-2018 , 09:28   Re: Native help
Reply With Quote #5

Well, players are given a certain value when killing someone in-game with the plugin i'm trying to fix. So that should work shouldn't it?

for example
Code:
iLevel[id] += 5

Then why does it still show 0 in the top 10?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-07-2018 , 12:25   Re: Native help
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
Well, players are given a certain value when killing someone in-game with the plugin i'm trying to fix. So that should work shouldn't it?

for example
Code:
iLevel[id] += 5

Then why does it still show 0 in the top 10?
Provide your actual test code.
__________________

Last edited by HamletEagle; 05-07-2018 at 12:26.
HamletEagle is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-07-2018 , 11:42   Re: Native help
Reply With Quote #7

new iLevel[33] = 5
This will only set iLevel[0] to 5, which will be ignored since the plugin returns 0 if the id is 0.

The native works as intended.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Native Test" #define VERSION "1.0" #define AUTHOR "author" new iLevel[33] = 5; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     } public plugin_natives() {     register_library("level_test")     iLevel[2] = 666;     for ( new i ; i < sizeof iLevel ; i++ )         server_print("iLevel[%d]: %d", i, iLevel[i]);         register_native("get_user_level", "_get_user_level") } public _get_user_level(iPlugin, iParams) {     if(iParams != 1)         return 0         new id = get_param(1)     server_print("id: %d", id);         if(!id) {         return 0     }         return iLevel[id] }
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #pragma reqlib "level_test" native get_user_level(id) #define PLUGIN "Test Plugin" #define VERSION "1.0" #define AUTHOR "author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("test", "Test") } public Test(id) {     server_print("level: %d", get_user_level(2)) }
Code:
iLevel[0]: 5
iLevel[1]: 0
iLevel[2]: 666
iLevel[3]: 0
iLevel[4]: 0
iLevel[5]: 0
iLevel[6]: 0
iLevel[7]: 0
iLevel[8]: 0
iLevel[9]: 0

... and so on...

test
id: 2
level: 666
__________________

Last edited by Black Rose; 05-07-2018 at 11:44.
Black Rose is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-13-2018 , 14:31   Re: Native help
Reply With Quote #8

this is the code that needs to be fixed. This isn't my code, just edited the accuracy part into the level part but it doesn't work. get_player_level() is made like i posted before in the test version. The only difference is that i don't set iLevel[33] = 5, iLevel[33] changes all the time when players level up killing people.

PHP Code:
format_top15(sBuffer[MAX_BUFFER_LENGTH 1])
{
    new 
iMax get_statsnum()
    new 
izStats[8], izBody[8], istate[4]//, SzName[32]
    
new iLen 0
 
    
//get_user_name(id, szName, 31);
   
    
if (iMax 10)
        
iMax 10
    
new lNick[20], lKills[20], lDeaths[20], lHs[20], lAcc[20], lLvl[20]
    
format(lNick19"Nick")
    
format(lKills19"Kills")
    
format(lDeaths19"Deaths")
    
format(lHs19"Headshots")
    
format(lLvl,charsmax(lLvl), "Level")
    
//format(lAcc, 19, "Accuracy")
    //format(knifeGetLevel(id), 19, "Level")
 
    //ucfirst(lAcc)
 
    
iLen formatsBufferMAX_BUFFER_LENGTH,
                  
"<head><META http-equiv=Content-Type content='text/html ;charset=UTF-8'></head><style>body{background:#191818;background-image: url(^"http://i63.tinypic.com/2v0g7br.jpg^");margin:5pt;padding:2pt;font-family:Tahoma;color:#eaeaea}.A{background-color:#262626;opacity:0.6;filter:alpha(opacity=60);}.B{background-color:#0b0b0b;opacity:0.6;filter:alpha(opacity=60);}td{font-size:15px}</style><center><table width=100%% background=^"^">" ) 
    
iLen += formatsBuffer[iLen], MAX_BUFFER_LENGTH iLen,
                  
"<tr><td><br/> <td></tr><tr><td><br/> <td></tr><tr><td><br/> <td></tr><tr><td><br/> <td></tr><tr><td><br/> <b><td></tr><tr><td>%s<td>%s<td>%s<td>%s<td>%s<td>%s</b>",
                  
"#"lNicklKillslDeathslHslLvl //knifeGetLevel(id) )
   
    
new players[32], inumid
    get_players
(playersinum)
   
    for(new 
iinumi++) {
        
id players[i]
    }
   
    for (new 
0iMax && MAX_BUFFER_LENGTH iLen 0i++)
    {
        if (
equal(istate,"A")) copy(istate,3,"B")
                else 
copy(istate,3,"A")
                
get_stats(iizStatsizBodyt_sNameMAX_NAME_LENGTH,sAuthid,MAX_NAME_LENGTH)
        while( 
contain t_sName"<" ) != -)
                
replacet_sName,MAX_BUFFER_LENGTH 1,"<""[" )
        while( 
contain t_sName">" ) != -)
                
replacet_sName,MAX_BUFFER_LENGTH 1,">""]" )
        if(
get_pcvar_num(authidgoster) == 1){
            
iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH iLen"<tr class=%s><td>%d<td>%s (%s)<td>%d<td>%d<td>%d<td>%d%%",istate1t_sNamesAuthidizStats[STATS_KILLS],
                
izStats[STATS_DEATHS], izStats[STATS_HS], get_player_level(id))
 
        }
        else{
            
iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH iLen"<tr class=%s><td>%d<td>%s <td>%d<td>%d<td>%d<td>%d%%",istate1t_sNameizStats[STATS_KILLS],
                
izStats[STATS_DEATHS], izStats[STATS_HS], get_player_level(id))
 
 
        }
    }
    
copy(sBuffer[iLen],MAX_BUFFER_LENGTH iLen,"</table></center>")

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-27-2018 , 13:13   Re: Native help
Reply With Quote #9

bump
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-28-2018 , 08:59   Re: Native help
Reply With Quote #10

Quote:
Originally Posted by Black Rose View Post
iLevel[2] = 666;
what the...

OP, this won't work since you're only getting the last id that was set in players[32] by get_players.

Spoiler




Spoiler
__________________









Last edited by CrazY.; 05-28-2018 at 09:03.
CrazY. 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 04:43.


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