How do I calculate the percentage of player progress in a race? I tried with TotalCP - 1, but it does not work properly ._.
PHP Code:
function Float:GetCPPercentage(playerid)
{
if(CPProgress[playerid] != 0)
{
new Float:Dist;
Dist = ((GetPlayerDistanceFromPoint(playerid, CPCoords[TotalCP - 1][0], CPCoords[TotalCP - 1][1], CPCoords[TotalCP - 1][2]) * 100.0) / DistAllCP);
CPPercentage[playerid] = 100.0 - Dist;
}
return CPPercentage[playerid];
}
PHP Code:
Loop(i, TotalCP)
{
if(i != TotalCP - 1) DistAllCP = DistAllCP + GetDistance(CPCoords[i][0], CPCoords[i][1], CPCoords[i][2], CPCoords[i + 1][0], CPCoords[i + 1][1], CPCoords[i + 1][2]);
}
PHP Code:
#define GetDistance(%1,%2,%3,%4,%5,%6) floatsqroot((%1-%4)*(%1-%4) + (%2-%5)*(%2-%5) + (%3-%6)*(%3-%6))