Help Race Position
#1

how to know the position the player is in a race , using a variable that stores how many checkpoints they passed

someone ?

Код:
RaceCheckpoints[playerid]++;
Reply
#2

You need to loop through the players and check if those players are in the same race as the "playerid". If they are and the value of the variable you store the checkpoints is greater than the one of "playerid", increase it by 1. If they're in the same, get the distance to the next cp (won't work perfect if the race's track is about turning 180 degrees and go to the next cp) and if it's less than "playerid"'s one, increase it again. The returning value will be increased by 1 as well. I had written this one long time ago, but you can get the idea.
PHP код:
// JUST AN EXAMPLE:
GetPlayerRacePosition(playeridraceid)
{
    new
        
position,
        
cp;
        
    foreach(new 
Player)
    {
        if (
Player_RaceID[i] == raceid && != playerid)
        {
            if (
Player_RaceCP[i] > Player_RaceCP[playerid]) ++position;
            else if (
Player_RaceCP[i] == Player_RaceCP[playerid])
            {
                
cp Player_RaceCP[playerid] + 1;
                if (
GetPlayerDistanceFromPoint(iRace_CP[0][raceid][cp], Race_CP[1][raceid][cp], Race_CP[2][raceid][cp]) < GetPlayerDistanceFromPoint(playeridRace_CP[0][raceid][cp], Race_CP[1][raceid][cp], Race_CP[2][raceid][cp]))
                {
                    ++
position;
                }
            }
        }
    }
    return 
position 1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)