working with rates
#1

I want to have a bar in my server, which gives a percentage of the total health. (dont go whining about not needing it, its just an example) how should i do that? in this case the max is different every time. about 50 different maxes. How should i get the percentage of the current health, out of the maxed health, which is different every time?
Reply
#2

Just add this function to the code .. When the player drinks or eats something
pawn Код:
new Float:health;
GetPlayerHealth(playerid,health);
SetPlayerHealth(playerid,health+20);
Reply
#3

Quote:
Originally Posted by ►Peter Corneile◄ [hugu-hosting.co.uk
]
Just add this function to the code .. When the player drinks or eats something
pawn Код:
new Float:health;
GetPlayerHealth(playerid,health);
SetPlayerHealth(playerid,health+20);
?? did you actually read my post?
Reply
#4

simply said: i want a way to view a percentage of a changing total. like 1st time it is 5 out of 360, second time it is 140 out of 1945. and the percentage will both 1st and 2nd time, tell the percentage of the small variable, out of the largest one, the max.
Reply
#5

**BUMP**
Reply
#6

pawn Код:
new Float:Health;
GetPlayerHealth(playerid, Health);
format(string, 128, "This is your percentage of health: %.0f%%",Health);
So 100.0 health equals 100 percent health, if you have 120 itll say 120 percent.

Its dead simple actually, just show the current health with a percent sign behind it.
Reply
#7

Quote:
Originally Posted by thuron
simply said: i want a way to view a percentage of a changing total. like 1st time it is 5 out of 360, second time it is 140 out of 1945. and the percentage will both 1st and 2nd time, tell the percentage of the small variable, out of the largest one, the max.
read it. the Health is just something to explain it. not the real thing
Reply
#8

Bumping and double posting is not allowed, if you don't understand something, search the forum, search the internet, search whatever you need and you will understand it. If you bump it. It looks like you are someone who always gets his/her way. Do some research, i think there will be already released filterscripts doing the same thing as that you are asking

P.S. Sorry for my spelling mistakes, i am dutch.
Reply
#9

Quote:
Originally Posted by thuron
Quote:
Originally Posted by thuron
simply said: i want a way to view a percentage of a changing total. like 1st time it is 5 out of 360, second time it is 140 out of 1945. and the percentage will both 1st and 2nd time, tell the percentage of the small variable, out of the largest one, the max.
read it. the Health is just something to explain it. not the real thing
if i get it right you need something like this:

pawn Код:
new Float:num = 65489; // This r your total crap
    new Float:num2 = 100; // This r your num you want the percentage from..?
    new Float:divider = (num/100);
    new Float:percentage = (num2/divider);

    printf("This r your percentage: %.02f%%", percentage);
Reply
#10

Quote:
Originally Posted by Doom (NoZer0)
Bumping and double posting is not allowed, if you don't understand something, search the forum, search the internet, search whatever you need and you will understand it. If you bump it. It looks like you are someone who always gets his/her way. Do some research, i think there will be already released filterscripts doing the same thing as that you are asking

P.S. Sorry for my spelling mistakes, i am dutch.
omglol. ^


Pandabeer:ill try it in a sec, if i see it like this, i think it should work. ill respond soon if it works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)