07.09.2013, 22:00
Here's what I came up with, but I can't test it unfortunately
pawn Код:
stock GetPlayerPosition(playerid, raceid)
{
//We are going to count the amount of players in front of you
new index = 0; //Count the amount of players in front of you, set to 0 because if noone is infront it's index +1 -> you are first
new PlayerPos[MAX_PLAYERS];
for(new j = 0; j < MAX_PLAYERS; j++) //everyone
{
if(PInfo[j][Racing] == raceid) //who is in the race
{
if(j != playerid) // who is not the checked player
{
if(PInfo[playerid][RaceCheckpoint] < PInfo[j][RaceCheckpoint]) //who is in front of the player
{
index++; //for everyone who is in front of the player index goes ++
}
if(PInfo[playerid][RaceCheckpoint] == PInfo[j][RaceCheckpoint]) //who is in the same section as the player
{
new PlayerCheckPoint = PInfo[playerid][RaceCheckpoint];
new ElseCheckPoint = PInfo[j][RaceCheckpoint];
if(GetPlayerDistanceFromPoint(playerid, RaceInfo[raceid][checkpointx][PlayerCheckPoint]+1,RaceInfo[raceid][checkpointy][PlayerCheckPoint]+1, RaceInfo[raceid][checkpointz][PlayerCheckPoint]+1) > GetPlayerDistanceFromPoint(j, RaceInfo[raceid][checkpointx][ElseCheckPoint]+1, RaceInfo[raceid][checkpointy][ElseCheckPoint]+1, RaceInfo[raceid][checkpointz][ElseCheckPoint]+1))
{
index++;
}
}
}
}
}
PlayerPos[playerid] = index +1;
return PlayerPos[playerid];
}