Raised This Month: $ Target: $400
 0% 

[solved]how to?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jc980
Veteran Member
Join Date: Jan 2010
Location: God is with us...
Old 05-17-2011 , 12:35   [solved]how to?
Reply With Quote #1

how do I make an integer into a percent?

example i want the value of "zp44_xp[id] = 128796" to turn into percent?

and the value of its max xp before leveling up is "max_xp = 140000"

so how can i do it.

and its shows in HUD Message

[Level: 14000] [Experience: 75%]

anyone?
__________________

Last edited by jc980; 05-17-2011 at 13:01.
jc980 is offline
Nyuszy
Senior Member
Join Date: Apr 2009
Old 05-17-2011 , 12:53   Re: [help]how to?
Reply With Quote #2

PHP Code:
new exp zp44_xp[id] / max_xp 100
client_print
(idprint_center"Experience: %i%"exp
Nyuszy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-17-2011 , 12:59   Re: [help]how to?
Reply With Quote #3

Quote:
Originally Posted by Nyuszy View Post
PHP Code:
new exp zp44_xp[id] / max_xp 100
client_print
(idprint_center"Experience: %i%"exp
1. You should multiply 100 first, otherwise it will be a truncated decimal always resulting in 0.
2. To show a percent sign in a format, you need to use a double percent sign.

PHP Code:
new exp zp44_xp[id] * 100 max_xp
client_print
(idprint_center"Experience: %i%%"exp
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
jc980
Veteran Member
Join Date: Jan 2010
Location: God is with us...
Old 05-17-2011 , 13:00   Re: [help]how to?
Reply With Quote #4

Quote:
Originally Posted by Nyuszy View Post
PHP Code:
new exp zp44_xp[id] / max_xp 100
client_print
(idprint_center"Experience: %i%"exp
yehey! thank you! topic solved.

@exolent

does "%i^%" work too?

and do i have to make a floatround?
__________________

Last edited by jc980; 05-17-2011 at 13:02.
jc980 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-17-2011 , 19:54   Re: [help]how to?
Reply With Quote #5

Quote:
Originally Posted by jc980 View Post
yehey! thank you! topic solved.

@exolent

does "%i^%" work too?

and do i have to make a floatround?
0. Only Exolent's code will work correctly.
1. Try it and find out.
2. With Exolent's code, it effectively rounds for you automatically (rounds to floor)
__________________
fysiks 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 04:18.


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