Challenge FS
#5

Quote:
Originally Posted by Iuri
Посмотреть сообщение
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.
Thanks.
I know how to check the distance between them, but with this you only check if they're close to each other, or not.
So you won't know who lead, just the lenght of their distance.
(if the distance is 5 between them, both of them can lead..)
Reply


Messages In This Thread
Challenge FS - by Nonameman - 11.01.2011, 19:24
Re: Challenge FS - by Iuri - 11.01.2011, 19:31
Re: Challenge FS - by Nonameman - 11.01.2011, 19:35
Re: Challenge FS - by Iuri - 11.01.2011, 19:51
Re: Challenge FS - by Nonameman - 12.01.2011, 14:13

Forum Jump:


Users browsing this thread: 1 Guest(s)