Race Progress
#3

Something like this, basic code

pawn Код:
/// top
new Float:MaxDistance;
new Float:FullDistance[sizeof(CPCoords));

Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
    return VectorSize(x1-x2, y1-y2, z1-z2);

// when race start
MaxDistance = 0.0;
for(new i = 0; i < TotalCP-1; i++)
{
    FullDistance[i+1] = GetDistanceBetweenPoints(CPCoords[i][0], CPCoords[i][1], CPCoords[i][2], CPCoords[i + 1][0], CPCoords[i + 1][1], CPCoords[i + 1][2]);
    MaxDistance += FullDistance[i+1];
}

// when player enter race checkpoint
CPPercentage[playerid] += FullDistance[ CPProgress[playerid] ]; // CPProgress must be checkpointid 0,1,2,...

// somewhere
forward Float:GetCPPercentage(playerid);
public Float:GetCPPercentage(playerid)
{
    new Float:CP_Percentage = 100.0 - ( MaxDistance - CPPercentage[playerid] );
    return CP_Percentage;
}
Reply


Messages In This Thread
Race Progress - by GSFBart - 25.06.2017, 20:11
Re: Race Progress - by GSFBart - 26.06.2017, 15:38
Re: Race Progress - by Jefff - 26.06.2017, 23:36
Re: Race Progress - by GSFBart - 01.07.2017, 13:26

Forum Jump:


Users browsing this thread: 1 Guest(s)