Race Position
#1

Currently the distance is calculated according to the checkpoints progress, but I have seen on some servers, the position being calculated by the distance between the players and the next checkpoint

From what I've seen, GetPlayerDistanceFromPoint works only for straight lines, is there any other method of calculating the position without checkpoints progress?

PHP Code:
function RaceRanking()
{
    new 
pScoreRace[MAX_PLAYERS][Enum_Race], RaceIndexsCPProgress[MAX_PLAYERS];
    Foreach(
iMAX_PLAYERS)
    {
        if(
JoinedRace[i] == true)
        {
            Foreach(
jMAX_PLAYERS)
            {
                if(
JoinedRace[j] == true)
                {
                    if(
!= i)
                    {
                        if(
CPProgress[i] < CPProgress[j])
                        {
                            
sCPProgress[i] = CPProgress[i];
                        }
                            
                        if(
CPProgress[i] == CPProgress[j])
                        {    
                            if((
GetPlayerDistanceFromPoint(iCPCoords[CPProgress[i]][0], CPCoords[CPProgress[i]][1], CPCoords[CPProgress[i]][2]) - 12
                            < (
GetPlayerDistanceFromPoint(jCPCoords[CPProgress[j]][0], CPCoords[CPProgress[j]][1], CPCoords[CPProgress[j]][2]) - 12)) // -12 is to fix the distance to the checkpoint, because the right position is in the center of the control point, but the callback is called on "touching" in CP.
                            
{
                                
sCPProgress[i] = CPProgress[i] + 1;
                            }
                            else
                            {
                                
sCPProgress[i] = CPProgress[i];
                            }
                        }
                    }
                }
            }
            
            if(
RacePlayerCount == 1)
            {
                
sCPProgress[i] = CPProgress[i];
            }
            
pScoreRace[RaceIndex][Race_PlayerScore] = sCPProgress[i];
            
pScoreRace[RaceIndex++][Race_PlayerID] = i;
            
GetRacePlayersScore(pScoreRace0RaceIndex);
            
            new 
ScoreText[256] = "~n~";
            for(new 
h5; ++h
            { 
                if(
RaceIndexformat(ScoreTextsizeof(ScoreText), "%s~n~~w~~h~%d| - ~y~%s"ScoreText1pName(pScoreRace[h][Race_PlayerID])); 
                else 
format(ScoreTextsizeof(ScoreText), "%s~n~~w~~h~%d| - ~r~~h~N/A"ScoreText1); 
            } 
            
TextDrawSetString(TextRace[10], ScoreText);  
        }
    }
    return 
1;

Scripts:

https://sampforum.blast.hk/showthread.php?tid=462892 (by knackworst)
http://forum.sa-mp.com/showpost.php?...2&postcount=44 (by RyDeR`)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)