Problems with ratio...
#1

Hey guys, I have problems with ratio, it's showing some weird letters, instead numbers like 0.00...


Here is the code on /stats command, I use...

Код:
new Float:ratio=floatdiv(PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
Ratio: %.2f, ratio);
Reply
#2

You have used
pawn Код:
new string[50];
format(string, sizeof(string), "Ratio: %f", ratio);
or not? :O because I don't see it there ^^ xD
Reply
#3

Yes I used it, I didn't show whole code, just part where ratio is used..
Reply
#4

I think you have to transform the integer into a float

pawn Код:
new Float:Kills = PlayerInfo[playerid][pKills];
new Float:Deaths = PlayerInfo[playerid][pDeaths];
new Float:ratio = floatdiv(Kills, Deaths);
or:

pawn Код:
new Float:Kills = float(PlayerInfo[playerid][pKills]);
new Float:Deaths = float(PlayerInfo[playerid][pDeaths]);
new Float:ratio = floatdiv(Kills, Deaths);
Second might be better ^^ xD
Reply
#5

This should work: new Float:ratio = Float:PlayerInfo[playerid][pKills]/Float:PlayerInfo[playerid][pDeaths];
Reply
#6

Quote:
Originally Posted by Mастерминд
This should work: new Float:ratio = Float:PlayerInfo[playerid][pKills]/Float:PlayerInfo[playerid][pDeaths];
This is the best possibility xD ^^
I have always the usage to make everything diffcult O.o xD
Reply
#7

while someone's Kills are 0 and Deaths are 0 too, ratio dosen't activates even if u have it with ' %f ', or ' %.2f '. A ratio activates when you have Kills 1, Deaths 1... There is the same message you have in your screen on the Area 51 server.
Reply
#8

pawn Код:
new Float:ratio=floatdiv(PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
Ratio: %0.2f, ratio);
Reply
#9

Quote:
Originally Posted by Iuri
while someone's Kills are 0 and Deaths are 0 too, ratio dosen't activates even if u have it with ' %f ', or ' %.2f '. A ratio activates when you have Kills 1, Deaths 1... There is the same message you have in your screen on the Area 51 server.
Thats true, 0/0 = Infinite :O
Reply
#10

Yea, ur right, 0/0 = Infinite =DD
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)