Raised This Month: $32 Target: $400
 8% 

[Req] Gunxp Percentage with decimals


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 02-21-2018 , 16:25   [Req] Gunxp Percentage with decimals
Reply With Quote #1

Hello i need this to be on Percentage with decimals, Example : 12.93%/100%


Here down its the player XP and The XP need for level (Example: 800/1200)

get_user_xp(id), get_user_max_level(id)
elmedin is offline
InteX01
Senior Member
Join Date: Jan 2017
Old 02-21-2018 , 16:56   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #2

try like this..
Make new that will be precentage..
Than Devide needed XP for nextlevel by 100 and multiply with current XP

PHP Code:
new precentage[33]
.
.
.
new 
neededXP get_user_max_level(id// i think this is needed xp for next level ???
new currentXP get_user_xp(id//
// and like
precentage[id] = ((currentXP neededXP) * 100
idk is this right way but try, test, play.

heres a example,,,, u have 300/1500 XP
so 300 / 1500 = 0.2
0.2 x 100 = 20%..
And if u want none decimals use %.0f or as u wrote if u want two decimals after point use %.2f

Last edited by InteX01; 02-21-2018 at 17:00.
InteX01 is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 02-21-2018 , 17:11   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #3

I tested it and it doesnt work :/
elmedin is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 02-21-2018 , 17:15   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #4

PHP Code:
        new precentage[33
        new 
neededXP get_user_max_level(id)
        new 
currentXP get_user_xp(id)
        
precentage[id] = ((currentXP neededXP) * 100)  
        
set_hudmessage(redgreenblueHUD_STATS_XHUD_STATS_Y06.01.10.00.0, -1)
        
ShowSyncHudMsg(ID_SHOWHUDg_MsgSync2"[Health: %s] | [%L%s] | [%L %d] | [FPS: %d]^n[Rank: %s of %s] | [Level: %i] | [Percent: %.2f]"healthstring,ID_SHOWHUD,"CLASS_CLASS"
        
,class,ID_SHOWHUD,"AMMO_PACKS1",g_ammopacks[ID_SHOWHUD],fps[id], g_Rankg_RankMaxget_user_level(id), precentage[id]); 
elmedin is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 02-21-2018 , 17:16   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #5

Here is the inc file

PHP Code:
// Gun Xp Mod Include File //
#if defined _gunxpmod_included
  #endinput
#endif
#define _gunxpmod_included

#if !defined charsmax
    #define charsmax(%1) sizeof(%1)-1
#endif 

// Returns player Experience.
native get_user_xp(id)

// Sets player Experience.
native set_user_xp(idamount)

// Returns player Level.
native get_user_level(id)

// Sets player Level.
native set_user_level(idamount)

// Returns player Level by Xp.
native get_user_max_level(id)

// Register Item.
stock find_itemplugin()
{
    for(new 
0get_pluginsnum(); ++i)
    {
        new 
temp[2], name[64]
        
get_plugin(iname63temp1temp1temp1temp1)
         if(
equali(name"gunxpmod_shop.amxx")) {
             return 
i;
        }
    }
     return -
1;
}

stock find_itemindex()
{
    new 
temp[2], name[64], pluginname[64]
    
get_plugin(-1pluginname63temp1temp1temp1temp1)
    for (new 
0get_pluginsnum(); ++i)
    {
        
get_plugin(iname63temp1temp1temp1temp1)
         if(
equal(namepluginname))
        {
             return 
i
        
}
    }
     return -
1
}

stock register_gxm_item(item_name[], item_desc[], item_cost)
{
    new 
item_index find_itemindex()
    new 
itemplugin find_itemplugin()
    new 
itemregfunc get_func_id("register_item_gxm"itemplugin)

    new 
temp callfunc_begin_i(itemregfuncitemplugin)
    if(
temp == -|| temp == -2)
    {
        if(
temp == -2
        {
            
log_amx("You have to many items, and need to increase the MAX_UNLOCKS define!")
        } 
        else 
        {
            
log_amx("A unkown error has happend, make sure the Upgrades plugin is loaded!")
        }
        return 
PLUGIN_HANDLED;        
    }

    
callfunc_push_int(item_index)
    
callfunc_push_str(item_name)
    
callfunc_push_str(item_desc)
    
callfunc_push_int(item_cost)
    
    
temp callfunc_end()
    if(
temp == -|| temp == -2
    {
        return 
PLUGIN_HANDLED;
    }
    return 
temp;
}
stock client_printcolor(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg,190,input,3);
    
replace_all(msg,190,"/g","^4");// green txt
    
replace_all(msg,190,"/y","^1");// orange txt
    
replace_all(msg,190,"/ctr","^3");// team txt
    
replace_all(msg,190,"/w","^0");// team txt
    
if (idplayers[0] = id; else get_players(players,count,"ch");
    for (new 
i=0;i<count;i++)
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }

elmedin is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-21-2018 , 17:58   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #6

I recommend calling Floats instead of classic variables.
__________________
Relaxing is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 02-21-2018 , 18:06   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #7

Can you show me how?
elmedin is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-22-2018 , 01:10   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #8

Quote:
Originally Posted by elmedin View Post
Can you show me how?
https://wiki.alliedmods.net/Pawn_Tutorial
Read this whole thread and do some side effects into the code the upper member send you.
__________________
Relaxing is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 02-22-2018 , 10:37   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #9

PHP Code:
new precentage[33



new 
currentXP get_user_xp(id// 
// and like 
precentage[id] = ((currentXP 15000) * 100
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 02-22-2018 , 14:56   Re: [Req] Gunxp Percentage with decimals
Reply With Quote #10

I tried this but when i get new level my xp wont return in 0% but in different valute

PHP Code:
new precentage[33
new 
neededXP get_user_max_level(id// i think this is needed xp for next level ??? 
new currentXP get_user_xp(id// 
precentage[id] = ((float(currentXP)/float(neededXP))*100.0

Last edited by elmedin; 02-22-2018 at 15:01.
elmedin 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 15:13.


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