ID:143908
 
Code:
stat("Powerlevel", "[round((src.PL/src.MaxPL)*100)]%")


Problem description:
I want this to show in 1/10ths like 90.1% but it only shows wholes, can someone please help?

stat("Powerlevel", "[round((src.PL/src.MaxPL)*100,0.1)]%")

That should do it. For more info on round(), see the reference.
In response to Hazman
Thanks, it worked great :)
In response to Hazman
Hazman wrote:
stat("Powerlevel", "[round((src.PL/src.MaxPL)*100,0.1)]%")

That should do it. For more info on round(), see the reference.

The only problem with this method is that it will round up in some cases, which may not be desirable when showing power; 100% should be pure 100% after all. If there's a need to always round down, then you need to do this:

stat("Powerlevel", "[round((src.PL/src.MaxPL)*1000)/10]%")


Lummox JR
In response to Lummox JR
But for it to round up to a number greater than 100, PL>maxPL would have to be true. If you do not allow for a number to exceed its maximum value, it should never round up to greater than 100%. If you do allow for a number to exceed the maximum value, then you would want to allow for it to round up above 100%. Or am I missing something?
In response to Loduwijk
If that case ever happens, conjunction with other methods will be helpful.. such as using min() or even a mini if statement [hint: ? operator]

_>
In response to GhostAnime
GhostAnime wrote:
If that case ever happens

If what case ever happens? The stat going over the max-stat? If that's what you mean, then of course, that's sort of part of my point.

I just don't get why you should take into account the possibility of having something that is greater than 100% and stripping the decimal as you either want to be able to go over max, thus making greater than 100% viable, or you don't want to allow it to be greater than the maximum, in which case the code is flawed somewhere else if it ever does go above maximum.