SA-MP Forums Archive
working with rates - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: working with rates (/showthread.php?tid=102622)



working with rates - thuron - 16.10.2009

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?


Re: working with rates - Peter_Corneile - 17.10.2009

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);



Re: working with rates - thuron - 17.10.2009

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?


Re: working with rates - thuron - 17.10.2009

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.


Re: working with rates - thuron - 19.10.2009

**BUMP**


Re: working with rates - Think - 19.10.2009

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.


Re: working with rates - thuron - 19.10.2009

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


Re: working with rates - [nl]daplayer - 20.10.2009

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.


Re: working with rates - Think - 20.10.2009

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);



Re: working with rates - thuron - 20.10.2009

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