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

Solved Native: get_user_rank


Post New Thread Reply   
 
Thread Tools Display Modes
Supremache
Senior Member
Join Date: Sep 2019
Old 06-30-2020 , 04:40   Re: Native: get_user_rank
Reply With Quote #21

Quote:
Originally Posted by Bugsy View Post
No, the code you used to create the HUD in your first post that isn't working correctly. This isn't that confusing, show all code that is causing you an issue if you want the problem resolved.
I added this hud just for test natives of plugin

PHP Code:
new syncObj
syncObj     
CreateHudSyncObj()

public 
ShowHud(id
{
    new 
iRank get_user_rank(id)
    new 
iXP get_user_xp(id)
    new 
iMaxLvl get_user_max_level(id)
    new 
iLevel get_user_level(id)
    
    
set_hudmessage(0212255, -1.00.006.012.0)
    
ShowSyncHudMsg(idsyncObj,"Rank: %s ^nXP: %i / %i ^nLevel: %i"iRankiXPiMaxLvliLevel)

}

public 
client_putinserverid ) {
    
set_task(1.0"ShowHud"id__"b")


I also have one more problem, I made give xp command but when i give XP for players or ZM or H or All, it's show me in show i have xp without getting upgraded on rank and level.
I give me self 10,000k XP but i have still in level 1 and max XP 50!!
Why i have this problem ?



PHP Code:
public cmdAddXP (iPlayerlevelcid)
{
    if(!
cmd_access(iPlayerlevelcid3))
        return 
PLUGIN_HANDLED;
        
    new 
arg [32]
    
read_argv (1arg31)
    
    new 
AddXP [32]
    
read_argv (2AddXPcharsmax (AddXP))
    
    new 
szPlayerXP get_user_xp(iPlayer)

    new 
szAdminName [32]
    new 
szPlayerName [32]
    
get_user_name (iPlayerszAdminNamecharsmax (szAdminName))
    
    if(
arg[0]=='@')
    {
        if(
equali(arg[1],"ALL") || equali(arg[1],"all"))
        {
            new 
iPlayers[32], totalplayersAll
            get_players
(iPlayerstotalplayers)
            
            for (new 
0totalplayersi++)
            {
                 
All iPlayers[i]
                 
set_user_xp(AllszPlayerXP str_to_num(AddXP))

            }
            
CheckLevel(All)
            
//client_print_color(0, print_chat, "[ADMIN]^1 ^3%s^1 dade^3 %i^1 XP na vsichki ^3igrachi^1!", AdminName, GiveXP)
        
}
        
        else if(
equali(arg[1],"ZM") || equali(arg[1],"zm") || equali(arg[1],"zombies") )
        {
            new 
iPlayers[32], totalplayersZOMBIE
            get_players
(iPlayerstotalplayers)
            
            for (new 
0totalplayersi++)
            {
                if (
get_user_team(iPlayers[i]) == 1)
                {
                    
ZOMBIE iPlayers[i]
                    
set_user_xp(ZOMBIEszPlayerXP str_to_num(AddXP))

                }
                
            }
            
CheckLevel(ZOMBIE)
            
//client_print_color(0, print_chat, "^4[Ranks]^1 ^3%s^1 dade^3 %i^1 XP na vsichki ^3 Teroristi^1.", AdminName, GiveXP)
        
}
        
        else if(
equali(arg[1],"H") || equali(arg[1],"h") || equali(arg[1],"humans"))
        {
            new 
iPlayers[32], totalplayersHUMAN
            get_players
(iPlayerstotalplayers)
            
            for(new 
0totalplayersi++)
            {
                if(
get_user_team(iPlayers[i]) == 2)
                {
                    
HUMAN iPlayers[i]
                    
set_user_xp(HUMANszPlayerXP str_to_num(AddXP))
                }
            }
            
CheckLevel(HUMAN)
            
//client_print_color(0, print_chat, "^4[Ranks]^1 ^3%s^1 dade^3 %i^1 XP na wsichki ^3 Kontra-Teroristi^1!", AdminName, GiveXP)
        
}
    }
    
    else
    {
        new 
iTarget cmd_target(iPlayerarg3)
        
get_user_name (iTargetszPlayerNamecharsmax (szPlayerName))
        
        if(
iTarget)
        {
            
set_user_xp(iTargetszPlayerXP str_to_num(AddXP))
            
CheckLevel(iTarget)
            
//LevelChat(0, "^1[ADMIN]^4 %s^1 dade^3 %i^1 XP na^3 %s^1.", AdminName, GiveXP, TargetName)
        
}
    }
    return 
PLUGIN_HANDLED

I want to know
var[] = buffer [] ???

I aslo want to know if i used style 0 with set it will be like this ?? amout = clamp ? Right ?
PHP Code:
// Native: set_user_xp
public _set_user_xp(iPlugin,iParams)
{
    
g_iPlayerXPget_param(1) ] = clamp(get_param(2), 0)

Supremache is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 06-30-2020 , 04:56   Re: Native: get_user_rank
Reply With Quote #22

This code seems copy-paste from here to me. But you are just copying stuff without knowledge. How to use them for instance. Why bother creating this plugin in first place if there is one that exists and functions correctly ?

Answering your question above
The hud isnt really an issue,
Code:
ShowSyncHudMsg(id, syncObj,"Rank: %s ^nXP: %i / %i ^nLevel: %i", iRank, iXP, iMaxLvl, iLevel)

Something i dont really understand, in this code you provided you never stored the rank string in an array but in the hud message it shows the full rank name ? you sure you provided the right code ?

Last edited by ZaX; 06-30-2020 at 05:03.
ZaX is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 06-30-2020 , 05:07   Re: Native: get_user_rank
Reply With Quote #23

Quote:
Originally Posted by ZaX View Post
This code seems copy-paste from here to me. But you are just copying stuff without knowledge. How to use them for instance. Why bother creating this plugin in first place if there is one that exists and functions correctly ?
What i didn't copied it from anyplugin, I have 3 month with amxmodx and i learning the codes like, if i want to make level system i searching for all level system plugin and see all code's styles and getten the best code and add it with my edition. We have an example in our country: Practice makes perfect.

I think you too in you first time with amxmodx was have the same thing and you was need to someone exmpling you how dose the codes using for.
Supremache is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 06-30-2020 , 05:16   Re: Native: get_user_rank
Reply With Quote #24

Quote:
Originally Posted by ZaX View Post
Something i dont really understand, in this code you provided you never stored the rank string in an array but in the hud message it shows the full rank name ? you sure you provided the right code ?
Oh, rank name are fixed and i said that but "bugzzy said show your codes for resolve all your problems"
I just want an explanation about the inquiries that were provided.
The problem not in hud, the problem in give xp codes when i give someone XP i show only he got XP but didn't got upgraded on his rank and levels.

Last edited by Supremache; 06-30-2020 at 05:19.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-30-2020 , 09:18   Re: Native: get_user_rank
Reply With Quote #25

Your issue was the rank name not displaying correctly, which you said is resolved. I never said I was going to solve all of your problems.
__________________
Bugsy is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 06-30-2020 , 10:45   Re: Native: get_user_rank
Reply With Quote #26

Quote:
Originally Posted by Bugsy View Post
Your issue was the rank name not displaying correctly, which you said is resolved. I never said I was going to solve all of your problems.
Okey thanks for your help but i want to inquiry for If i used the same style 0 for set_user_xp, will do the same ??
Is this correct ??
PHP Code:
// Native: set_user_xp
public _set_user_xp(iPlugin,iParams)
{
    
g_iPlayerXPget_param(1) ] = clamp(get_param(2), 0)

clamp = amount ??
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 06-30-2020 , 20:16   Re: Native: get_user_rank
Reply With Quote #27

Use max function instead of clamp
__________________
@Jailbreak MOD [Alot of features + API] 100% done !
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-30-2020 , 20:29   Re: Native: get_user_rank
Reply With Quote #28

Supermache, clamp is good when the input value can fall below or above a desired range.

So suppose you want to only allow values between 0 and 100, but the input value can range from -100 to 1000. Doing clamp( value , 0 , 100 ) will ensure the floor value is 0, ceiling value is 100, and if the value falls between those values, clamp returns that value.

clamp( -100 , 0 , 100 ) = 0
clamp( 0 , 0 , 100 ) = 0
clamp( 55 , 0 , 100 ) = 55
clamp( 100 , 0 , 100 ) = 100
clamp( 1000 , 0 , 100 ) = 100
__________________

Last edited by Bugsy; 06-30-2020 at 20:30.
Bugsy is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 07-02-2020 , 18:01   Re: Native: get_user_rank
Reply With Quote #29

@Natsheh - Okey I will try it

@Bugsy - Thank you for your help <3
Supremache 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 15:13.


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