Race Position
#1

I am looking for an effective way to check a players position in a race. Getting the racers position by increasing a variable upon every checkpoint they enter is not quite good enough as if there is more than one player at the same checkpoint they are both positioned as 1st for example.

I need a way of detecting who is closer to the last checkpoint or who has progressed furthest through the race.
I have looked through nearly every race script/tutorial/builder I could find but am still left without a decent answer.

I will be storing the racers position in a textdraw but that isn't the issue, any help is greatly appreciated.
Reply
#2

checking who is closest to a point:
pawn Код:
new ClosestID = INVALID_PLAYER_ID;
new Float:ClosestDis = 0;
for(new i; i < GetMaxPlayers(); i++)
{
if(ClosestID == INVALID_PLAYER_ID || GetPlayerDistanceToPoint(i, X, Y, Z) < ClosestDis)
{
ClosestID = i;
ClosestDis = GetPlayerDistanceToPoint(i, X, Y, Z);
}
}
and there is the function:
pawn Код:
stock GetPlayerDistanceToPoint(playerid, Float:X, Float:Y, Float:Z)
{
  new Float:XP,Float:YP,Float:ZP;
  GetPlayerPos(playerid,XP,YP,ZP);
  return (XP - X) + (YP - Y) + (ZP - Z);
}
Reply
#3

Quote:
Originally Posted by xDeadlyBoy
Посмотреть сообщение
checking who is closest to a point:
pawn Код:
new ClosestID = INVALID_PLAYER_ID;
new Float:ClosestDis = 0;
for(new i; i < GetMaxPlayers(); i++)
{
if(ClosestID == INVALID_PLAYER_ID || GetPlayerDistanceToPoint(i, X, Y, Z) < ClosestDis)
{
ClosestID = i;
ClosestDis = GetPlayerDistanceToPoint(i, X, Y, Z);
}
}
and there is the function:
pawn Код:
stock GetPlayerDistanceToPoint(playerid, Float:X, Float:Y, Float:Z)
{
  new Float:XP,Float:YP,Float:ZP;
  GetPlayerPos(playerid,XP,YP,ZP);
  return (XP - X) + (YP - Y) + (ZP - Z);
}
Thanks for the reply, not idealy what I was looking for though.

Quote:
Originally Posted by ******
Посмотреть сообщение
Check in the old YSI system, the YSI_races.own file had an experimental function for this, though I don't think I even massively tested/completed it, but it's a start.
YSI:Races looks quite handy actually in more than one way. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)