SA-MP Forums Archive
Problems with ratio... - 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: Problems with ratio... (/showthread.php?tid=138384)



Problems with ratio... - leapfish - 01.04.2010

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



Re: Problems with ratio... - Last_Stand_Guardian - 01.04.2010

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


Re: Problems with ratio... - leapfish - 01.04.2010

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


Re: Problems with ratio... - Last_Stand_Guardian - 01.04.2010

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


Re: Problems with ratio... - M4S7ERMIND - 01.04.2010

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


Re: Problems with ratio... - Last_Stand_Guardian - 01.04.2010

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


Re: Problems with ratio... - Iuri - 01.04.2010

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.


Re: Problems with ratio... - Andy_McKinley - 01.04.2010

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



Re: Problems with ratio... - Last_Stand_Guardian - 01.04.2010

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


Re: Problems with ratio... - Iuri - 01.04.2010

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