15.06.2017, 23:00
(
Last edited by GSFBart; 15/06/2017 at 11:31 PM.
)
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?
Scripts:
https://sampforum.blast.hk/showthread.php?tid=462892 (by knackworst)
http://forum.sa-mp.com/showpost.php?...2&postcount=44 (by RyDeR`)
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], RaceIndex, sCPProgress[MAX_PLAYERS];
Foreach(i, MAX_PLAYERS)
{
if(JoinedRace[i] == true)
{
Foreach(j, MAX_PLAYERS)
{
if(JoinedRace[j] == true)
{
if(j != i)
{
if(CPProgress[i] < CPProgress[j])
{
sCPProgress[i] = CPProgress[i];
}
if(CPProgress[i] == CPProgress[j])
{
if((GetPlayerDistanceFromPoint(i, CPCoords[CPProgress[i]][0], CPCoords[CPProgress[i]][1], CPCoords[CPProgress[i]][2]) - 12)
< (GetPlayerDistanceFromPoint(j, CPCoords[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(pScoreRace, 0, RaceIndex);
new ScoreText[256] = "~n~";
for(new h; h < 5; ++h)
{
if(h < RaceIndex) format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~y~%s", ScoreText, h + 1, pName(pScoreRace[h][Race_PlayerID]));
else format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~r~~h~N/A", ScoreText, h + 1);
}
TextDrawSetString(TextRace[10], ScoreText);
}
}
return 1;
}
https://sampforum.blast.hk/showthread.php?tid=462892 (by knackworst)
http://forum.sa-mp.com/showpost.php?...2&postcount=44 (by RyDeR`)