Okay so it works kinda simple. First, you make a new variable for all the players and a normal variable( e.g:
pawn Код:
new Challenger[MAX_PLAYERS] = INVALID_PLAYER_ID;
new RaceLeader = INVALID_PLAYER_ID;
, then a command to invite someone to race.Do
pawn Код:
Challenger[playerid] = giveplayerid;
Challenger[giveplayerid] = playerid;
when the command is executed.
In case if the opponent accepts, just set a timer for a countdown. If he refuses, add:
pawn Код:
Challenger[Challenger[playerid]] = INVALID_PLAYER_ID;
Challenger[playerid] = INVALID_PLAYER_ID;
Now let's go to the lead...
pawn Код:
new Float: Distance = GetDistanceBetweenPlayers(Challenger[playerid],playerid);
if(Distance > Float:Distance)
{
RaceLeader = Challenger[playerid];
new string[56],pName[MAX_PLAYER_NAME];
GetPlayerName(Challenger[playerid],pName,sizeof(pName));
format(string,sizeof(string)," %s is in the lead.",pName));
SendClientMessage(playerid,colour,string);
SendClientMessage(Challenger[playerid],colour," You are in the lead.");
}
else if(Distance < Float:Distance)
{
RaceLeader = playerid;
new string[56],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string)," %s is in the lead.",pName));
SendClientMessage(Challenger[playerid],colour,string);
SendClientMessage(colour,playerid," You are in the lead.");
}
Just be sure to change the
Float: Distance and the
colour, and to set an
INVALID_PLAYER_ID for all the new created variables.