Raised This Month: $13 Target: $400
 3% 

Solved Native: get_user_rank


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Senior Member
Join Date: Sep 2019
Old 06-29-2020 , 08:12   Native: get_user_rank
Reply With Quote #1

I made Native for get_user_rank but it show me only first word of rank name how to fix it ?



PHP Code:
enum _:mData {
    
m_szRankName32 ],
    
m_iRankXP
};

new const 
g_mPlayerDataMAXLEVEL ][ mData ] = {
    { 
"Private"},
    { 
"Specialist"50 },
    { 
"Corporal"200 },
    { 
"Sargeant"350 },
    { 
"Staff Sargeant"600 },
    { 
"Warrant Officer"1000 },
    { 
"Chief Warrant Officer"1500 },
    { 
"Second Lieutenant"2500 },
    { 
"First Lieutenant"5000 },
    { 
"Captain"8250 },
    { 
"Major"13500 },
    { 
"Colonel"20000 },
    { 
"General"30000 },
    { 
"General of The Army"45000 }
};


public 
plugin_natives()
{
    
register_native("get_user_rank""native_get_user_rank"1)
}

// Native: get_user_rank
public native_get_user_rank(id)
{
    return 
g_mPlayerDatag_iPlayerLevelid ] ][ m_szRankName ]


Last edited by Supremache; 07-02-2020 at 18:11.
Supremache is offline
alferd
Veteran Member
Join Date: Dec 2019
Old 06-29-2020 , 08:32   Re: Native: get_user_rank
Reply With Quote #2

PHP Code:
m_szRankName512 
test
alferd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-29-2020 , 08:42   Re: Native: get_user_rank
Reply With Quote #3

https://forums.alliedmods.net/showthread.php?t=242017
__________________
Bugsy is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 06-29-2020 , 10:17   Re: Native: get_user_rank
Reply With Quote #4

@alferd - Not worked


@Bugsy - I did it but i have got this problme

What i did:
PHP Code:

public plugin_natives()
{

    
register_native("get_user_rank""_get_user_rank"1)
}

public 
_get_user_rank()
{
    new 
iLen get_param);
    
set_string2g_mPlayerDatag_iPlayerLevelget_param(1) ] ] [ m_szRankName ], iLen );

The problem:

Code:
L 06/29/2020 - 16:16:22: [AMXX] Run time error 10 (plugin "lvl.amxx") (native "get_param") - debug not enabled

Last edited by Supremache; 06-29-2020 at 10:17.
Supremache is offline
MagNNusS
Member
Join Date: May 2018
Location: World of Bushi
Old 06-29-2020 , 11:46   Re: Native: get_user_rank
Reply With Quote #5

Quote:
Originally Posted by Supremache View Post
PHP Code:
register_native("get_user_rank""_get_user_rank"1
You registered a native on style 1 but the function you've used it is in the old one.
Take a real quick look at this post. So you can see where's the difference between style 1 and the old one.
__________________
Just an impractical signature
nothing to see here.
MagNNusS is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 06-29-2020 , 12:13   Re: Native: get_user_rank
Reply With Quote #6

Quote:
Originally Posted by MagNNusS View Post
You registered a native on style 1 but the function you've used it is in the old one.
Take a real quick look at this post. So you can see where's the difference between style 1 and the old one.
I dont understand!!, Sorry this is my first time in native coding.
Supremache is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-29-2020 , 12:54   Re: Native: get_user_rank
Reply With Quote #7

Quote:
Originally Posted by MagNNusS View Post
You registered a native on style 1 but the function you've used it is in the old one.
Take a real quick look at this post. So you can see where's the difference between style 1 and the old one.
"the old one"
Style 0 is not "old", in fact it is what you should use. Style 1 is deprecated, do not use it.
OP, just switch to style 0 natives, no point in trying to fix code you shouldn't write in the first place.
Then read this: https://forums.alliedmods.net/showthread.php?t=41251

P.S: enable debug already. Don't post error logs with debug disabled, they are useless.
__________________

Last edited by HamletEagle; 06-29-2020 at 12:56.
HamletEagle is online now
Supremache
Senior Member
Join Date: Sep 2019
Old 06-29-2020 , 15:37   Re: Native: get_user_rank
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
"the old one"
Style 0 is not "old", in fact it is what you should use. Style 1 is deprecated, do not use it.
OP, just switch to style 0 natives, no point in trying to fix code you shouldn't write in the first place.
Then read this: https://forums.alliedmods.net/showthread.php?t=41251

P.S: enable debug already. Don't post error logs with debug disabled, they are useless.
I did it but rank name didn't show



.inc
Quote:
/**
* Returns the client's current rank.
*
* @param id Client index.
* @param buffer Buffer to store the rank name in.
* @param len Maximum buffer length.
* @noreturn
*/

native get_user_rank(id)
PHP Code:

public plugin_natives()
{
    
register_library("levels")
    
register_native("get_user_rank""_get_user_rank"1)
}


public 
_get_user_rank(iPlugin,iParams)
{
    if(
iParams != 1)
        return 
PLUGIN_CONTINUE
        
    
new id get_param(1)
    if(!
id)
        return 
PLUGIN_CONTINUE;
        
    
set_string(idg_mPlayerDatag_iPlayerLevelid ] ][ m_szRankName ], 2)
    
    return 
PLUGIN_CONTINUE



Last edited by Supremache; 06-29-2020 at 15:38.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-29-2020 , 16:50   Re: Native: get_user_rank
Reply With Quote #9

You're still using style 1

register_native("get_user_rank", "_get_user_rank", 1)

And maxlen is set to 2, use charsmax( g_mPlayerData[][ m_szRankName ] )

set_string( id, g_mPlayerData[ g_iPlayerLevel[ id ] ][ m_szRankName ], 2)
__________________

Last edited by Bugsy; 06-29-2020 at 16:51.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-29-2020 , 16:56   Re: Native: get_user_rank
Reply With Quote #10

And show me how you're using this native in your plugin. You should post all code, not snippets.
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 13:35.


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