killsчdeaths Ratio problem -
HurtLocker - 01.04.2013
I want to get the value Ratio=Kills/Deaths. I succesfully save and load kills and deaths with dini. But when a player has for example 5 deaths and 6 kills, Ratio becomes 1. If kills<deaths, then Ratio=0. How can I make ratio=5/6=0.83?
I also have R as Float like this:
Re: killsчdeaths Ratio problem -
Vince - 01.04.2013
Quote:
Originally Posted by HurtLocker
with dini
|
* Vince shivers.
Anyway, integer divided by integer remains integer. Use something like:
pawn Код:
new Float:ratio = float(kills)/float(deaths);
Re: killsчdeaths Ratio problem -
HurtLocker - 01.04.2013
Thanks a lot.
Re: killsчdeaths Ratio problem -
HurtLocker - 01.04.2013
In order to use the /stats command, I need to load the Ratio value from .ini file. I tried dini_Float(file, "Ratio"). I received, error: tag mismatch. Then, I tried dini_Int instead of dini_Float but the ratio value that was shown was 0.000. How can I load the Ratio value unharmed with this format?
pawn Код:
format(string,sizeof(string), "%s's STATS: [ Kills: %d || Deaths: %d || Ratio: %f || Money: %d || Score: %d || Admin level: %d ]", name, kills, deaths, R, money, score, alv);
SendClientMessage(playerid, 0x87CEEBFF, string);
Re: killsчdeaths Ratio problem -
MP2 - 01.04.2013
WHATISHERE = dini_Float(...);
and how do you declare ('new') it?
Re: killsчdeaths Ratio problem -
Konstantinos - 01.04.2013
No, don't do that. The ratio is changing everytime you get a kill/death and loading from a file would be failure, as it should save the kills/deaths again and again. Just make a variable that is assigned with the value of kills/deaths and then just print that!
Re: killsчdeaths Ratio problem -
HurtLocker - 01.04.2013
Quote:
Originally Posted by MP2
WHATISHERE = dini_Float(...);
and how do you declare ('new') it?
|
Thanks a lot. I didnt type "Float:R"...
Quote:
Originally Posted by Dwane
No, don't do that. The ratio is changing everytime you get a kill/death and loading from a file would be failure, as it should save the kills/deaths again and again. Just make a variable that is assigned with the value of kills/deaths and then just print that!
|
I don't understand why it would "fail" but nice idea.
Re: killsчdeaths Ratio problem -
Konstantinos - 01.04.2013
Quote:
Originally Posted by HurtLocker
In order to use the /stats command, I need to load the Ratio value from .ini file.
|
Let's say you're in a minigame and you get 50 kills and 10 deaths in 4 minutes. Doing what you said above will show the old ratio, so you need to save every new kill/death.
However, there's just an easier way to do that and that's to store the result of (kills/deaths) to a new variable and display it everytime someone uses the /stats command. It doesn't need to save and load the ratio at all, it's just pointless!