04.03.2016, 12:43
Hey guys, I'd like to calculate the K/D ratio of families in war, however I'm having a hardtime building the k/d ratio.
Been trying several options and it keeps rounding the score (2.0000 for e.g) I know why it happens(due to me using the int dini, but I'm having a hard time realising on how to convert it into a double or what so over.
Here's what you'll need:
+ REPing the helper(in 24 hrs tho)
Been trying several options and it keeps rounding the score (2.0000 for e.g) I know why it happens(due to me using the int dini, but I'm having a hard time realising on how to convert it into a double or what so over.
Here's what you'll need:
PHP код:
stock WarInfo(playerid)
{
if(dini_Int(warfile, "faction1") != -1)
{
new string[ 164 ],
factionex1 = dini_Int(warfile,"faction1"),
factionex2 = dini_Int(warfile,"faction2");
new T1KDR, T2KDR;
if(dini_Int(warfile, "faction1deaths")!=0)
T1KDR = (dini_Int(warfile, "faction1kills")/dini_Int(warfile, "faction1deaths"));
else
T1KDR = (dini_Int(warfile, "faction1kills"));
if(dini_Int(warfile, "faction2deaths")!=0)
T2KDR = (dini_Int(warfile, "faction2kills")/dini_Int(warfile, "faction2deaths"));
else
T2KDR = (dini_Int(warfile, "faction2kills"));
/*int aa = (dini_Int(warfile, "faction1kills") + (dini_Int(warfile, "faction2kills");
int bb = (dini_Int(warfile, "faction1deaths") + (dini_Int(warfile, "faction2deaths");
int cc = aa+bb;
*/
// "{52565f}[WAR]{52565f} A war between %s and %s has been started", teams[ GetTeam(f1) ][teamname], teams[ GetTeam(f2) ][teamname]);
SendClientMessage(playerid, COLOR_WHITE, "{52565f}==============================================================================");
format(string, sizeof(string), "{9da8b9} %s vs. %s", teams[ GetTeam(factionex1) ][teamname],teams[ GetTeam(factionex2) ][teamname]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "{9da8b9} %s points: %d. Kills: %d, Deaths: %d, K/D Ratio: %f", teams[ GetTeam(factionex1) ][teamname], dini_Int(warfile, "faction1points"),
dini_Int(warfile, "faction1kills"), dini_Int(warfile, "faction1deaths"), T1KDR);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "{9da8b9} %s points: %d. Kills: %d, Deaths: %d, K/D Ratio: %f ", teams[ GetTeam(factionex2) ][teamname], dini_Int(warfile, "faction2points"), dini_Int(warfile, "faction2kills"),dini_Int(warfile, "faction2deaths"), T2KDR);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "{9da8b9} Points needed: %d. Total Kills: %d, Total Deaths: %d", dini_Int(warfile, "pointsgoal"),(dini_Int(warfile, "faction1kills")+dini_Int(warfile, "faction2kills")),(dini_Int(warfile, "faction2deaths")+dini_Int(warfile, "faction1deaths")));
SendClientMessage(playerid, COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_WHITE, "{52565f}==============================================================================");
return 1;
}
else return SendClientInfo(playerid, "There is no war at the moment.");
}