Challenge FS
#1

Hey!

I'm creating a FS that you can challenge players like in the NeedForSpeed games, with vehicles.
It's nearly finished, but I have a big problem: I have a timer, that checks the range of challenger and the challenged player, but I dunno how to check when each player gets the lead.

Any ideas?

Nonameman
Reply
#2

GetDistanceBetweenPlayers. Im using it too for my Need For Speed Server.
Reply
#3

Quote:
Originally Posted by Iuri
Посмотреть сообщение
GetDistanceBetweenPlayers. Im using it too for my Need For Speed Server.
Thanks, but the main problem is to get who leads, when should I set the other player to leader?
Reply
#4

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.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)