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

Percentage


Post New Thread Reply   
 
Thread Tools Display Modes
Bladell
Senior Member
Join Date: Jun 2012
Old 06-14-2013 , 08:51   Re: Percentage
Reply With Quote #21

I don't know this coding language...please tell me what I have to replace.
Quote:
Originally Posted by "Emp`
//use id as the player's id, not i
doesn't tell me anything.
Bladell is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 06-14-2013 , 19:00   Re: Percentage
Reply With Quote #22

i -> id

Last edited by Emp`; 06-14-2013 at 19:01.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Bladell
Senior Member
Join Date: Jun 2012
Old 06-16-2013 , 05:19   Re: Percentage
Reply With Quote #23

Now work
Code:
#include <superheromod>

new gPlayerLevel[33]
new gServerLevels[33]
new gRequiredXP[33]
new gPlayerXP[33]
new gReqXP[33]
new gWork
new gWork2
new gWork3
new gWork4

public plugin_init()
{
	register_plugin("Superhero show percent", "1.0", "Jelle")
	
	set_task(1.0, "get_level", _, _, _, "b")
}

public get_level( id )
{
	new players[32], playerCount
	get_players(players, playerCount, "ah")
	
	for ( new i = 0; i < playerCount; i++ )
	{
		id = players[i]
		gServerLevels[ id ] = sh_get_num_lvls()
		
		gPlayerLevel[id] = sh_get_user_lvl(id)
		
		if ( gPlayerLevel[id] > gServerLevels[ id ] )
		{
			gRequiredXP[id] = sh_get_lvl_xp(gPlayerLevel[id])
		}
		
		else
		{
			gRequiredXP[id] = 0
		}
		
		gPlayerXP[id] = sh_get_user_xp(id)
		gReqXP[id] = sh_get_lvl_xp( gPlayerLevel[id] - 1 )
		gWork = gRequiredXP[id] - gReqXP[id]
		gWork2 = gPlayerXP[id] - gReqXP[id]
		gWork3 = gWork2*100/gWork
		gWork4 = 100 - gWork3
		set_hudmessage( 255, 170, 0, 0.06, 0.82, 0, 6.0, 1.0 );
		show_hudmessage( id, "LVL: %d/%d %d% until next level", gPlayerLevel[ id ], gServerLevels[ id ], gWork4 );
	}
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
But if I give me 1 xp...this plugin show me that I have -100 xp.And the percentage symbol doesn't appear.
Bladell is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 06-16-2013 , 11:59   Re: Percentage
Reply With Quote #24

Did you wait at least one second? It updates all players levels each second.

and why create the work variables as a global when you are only using it in one forward?
__________________
No idea what to write here...

Last edited by Jelle; 06-16-2013 at 12:01.
Jelle is offline
Send a message via MSN to Jelle
Bladell
Senior Member
Join Date: Jun 2012
Old 06-17-2013 , 06:33   Re: Percentage
Reply With Quote #25

I wait one round...I really don't know what's the problem.I hope that my calculations are good.Do you want to test it?
Bladell is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 06-17-2013 , 11:18   Re: Percentage
Reply With Quote #26

Quote:
Originally Posted by Bladell View Post
I wait one round...I really don't know what's the problem.I hope that my calculations are good.Do you want to test it?
It is not easy for me to test these days since my server is being weird and running all the servers behind the desktop, and I don't really have time to setup and test on a newly downloaded server for my gaming system.
I did not really look at your calculations. You can try inserting the values that might be there in some cases, and check with a calculator if you get the right results.

You can also print all results in the chat as a debug, to see if a calculation is going wrong.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Bladell
Senior Member
Join Date: Jun 2012
Old 06-17-2013 , 12:45   Re: Percentage
Reply With Quote #27

I mean to test it on my server...nvm, I can't make other plugin.
Bladell is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 06-24-2013 , 01:58   Re: Percentage
Reply With Quote #28

try this
PHP Code:
#include <superheromod>

public plugin_init()
{
    
register_plugin("Superhero show percent""1.1""Jelle")
    
    
set_task(1.0"get_level"___"b")
}

public 
get_level()
{
    new 
players[32], playerCountid
    get_players
(playersplayerCount"ah")
    
    new 
playerLevelMaxLevelReqXpPlayerXpxpdiffpercent_to_lvl
    
    MaxLevel 
sh_get_num_lvls()
    
    for ( new 
0playerCounti++ )
    {
        
id players[i]
        
playerLevel sh_get_user_lvl(id)
        if ( 
playerLevel MaxLevel )
        {
            
ReqXp sh_get_lvl_xp(playerLevel) - sh_get_lvl_xp(playerLevel 1)
            
PlayerXp sh_get_user_xp(id)
            
xpdiff ReqXp PlayerXp
            percent_to_lvl 
100 - ((xpdiff 100) / ReqXp)

            
set_hudmessage25517000.060.8206.01.0 );
            
show_hudmessageid"LVL: %d/%d %d%% until next level"playerLevelMaxLevelpercent_to_lvl );
        } else {
            
set_hudmessage25517000.060.8206.01.0 );
            
show_hudmessageid"MAX LVL");
        }
    }

__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
Bladell
Senior Member
Join Date: Jun 2012
Old 06-25-2013 , 05:11   Re: Percentage
Reply With Quote #29

Thakns !
How can I make to show the result with 2 decimals?Ex: 96,32%

new Float: percent_to_lvl and what?
Bladell is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 07-23-2013 , 14:25   Re: Percentage
Reply With Quote #30

No ideea?
Bladell 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 02:56.


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