Raised This Month: $ Target: $400
 0% 

Solved [HELP] Percentage error ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-18-2020 , 14:55   Re: [HELP] Percentage error ?
Reply With Quote #1

Lol, I think we discovered the problem yesterday.

currentXP is too close to neededXP, resulting in 100%. Reset currentXP on new level?
__________________
Bugsy is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 04-18-2020 , 14:57   Re: [HELP] Percentage error ?
Reply With Quote #2

yes, how do i reset currentXP ?

(CurrentXP-CurrentXP)/neededxp)*100 ?
elmedin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-18-2020 , 15:52   Re: [HELP] Percentage error ?
Reply With Quote #3

currentXP = 0

But if you are modifying someone elses plugin it likely needs more work than this to make it continue working properly.
__________________
Bugsy is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 04-18-2020 , 16:06   Re: [HELP] Percentage error ?
Reply With Quote #4

where do i put it ?


Code:
			
			// User is under level 10
			else if ( p_data[id][P_LEVEL] < MAX_LEVELS )
			{
	
		
			
			

		   

			new precentage[33] 
			new neededXP = XP_GetByLevel( p_data[id][P_LEVEL]+1 )
			new currentXP = p_data[id][P_XP]
			currentXP = 0
			precentage[id] = floatround((float(currentXP)/float(neededXP))*100.0)
			
		   
			
				pos += formatex( szRaceInfo[pos], 255, "%s %L: %d   XP: %d ", szShortRaceName, id, "WORD_LEVEL", p_data[id][P_LEVEL], precentage[id]  );
				formatex( szXPInfo, 31, "%L: %d   XP: %d", id, "WORD_LEVEL", p_data[id][P_LEVEL], precentage[id] );
			}
elmedin is offline
Th3822
Member
Join Date: Jan 2013
Location: Venezuela
Old 04-19-2020 , 09:33   Re: [HELP] Percentage error ?
Reply With Quote #5

Quote:
Originally Posted by elmedin View Post
where do i put it ?


Code:
			
			// User is under level 10
			else if ( p_data[id][P_LEVEL] < MAX_LEVELS )
			{
	
		
			
			

		   

			new precentage[33] 
			new neededXP = XP_GetByLevel( p_data[id][P_LEVEL]+1 )
			new currentXP = p_data[id][P_XP]
			currentXP = 0
			precentage[id] = floatround((float(currentXP)/float(neededXP))*100.0)
			
		   
			
				pos += formatex( szRaceInfo[pos], 255, "%s %L: %d   XP: %d ", szShortRaceName, id, "WORD_LEVEL", p_data[id][P_LEVEL], precentage[id]  );
				formatex( szXPInfo, 31, "%L: %d   XP: %d", id, "WORD_LEVEL", p_data[id][P_LEVEL], precentage[id] );
			}
didn't read the full code, just did a quick check on XP_GetByLevel (it wasn't needed tho)
test with:
Code:
			new precentage[33] 
			new neededXP = XP_GetByLevel( p_data[id][P_LEVEL]+1 )
			new currentXP = p_data[id][P_XP]
			new diffXP = XP_GetByLevel( p_data[id][P_LEVEL] )
			precentage[id] = ((float(currentXP - diffXP)/float(neededXP - diffXP))*100.0)
it should work

Last edited by Th3822; 04-19-2020 at 09:41. Reason: forgot to remove the floatround, to avoid getting >= 99.5% rounded to 100%
Th3822 is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 04-19-2020 , 10:50   Re: [HELP] Percentage error ?
Reply With Quote #6

Quote:
Originally Posted by Th3822 View Post
didn't read the full code, just did a quick check on XP_GetByLevel (it wasn't needed tho)
test with:
Code:
			new precentage[33] 
			new neededXP = XP_GetByLevel( p_data[id][P_LEVEL]+1 )
			new currentXP = p_data[id][P_XP]
			new diffXP = XP_GetByLevel( p_data[id][P_LEVEL] )
			precentage[id] = ((float(currentXP - diffXP)/float(neededXP - diffXP))*100.0)
it should work
Damn u did it lmao, thanks bro it worked <3
elmedin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-18-2020 , 16:15   Re: [HELP] Percentage error ?
Reply With Quote #7

I'd need to see the full plugin.

There is no simple fix for this based on what I've seen. You need to modify the logic that gives XP or what happens when the XP level changes.
__________________
Bugsy is offline
Old 04-18-2020, 16:38
elmedin
This message has been deleted by elmedin.
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 04-18-2020 , 16:41   Re: [HELP] Percentage error ?
Reply With Quote #9

Its the war3ft mode and its edited by the inl files let me send you it


https://www51.zippyshare.com/v/rITUK37n/file.html
elmedin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-18-2020 , 22:48   Re: [HELP] Percentage error ?
Reply With Quote #10

Please attach the plugin and any necessary files in this thread.
__________________
Bugsy 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 00:56.


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