Sim, essa funзгo tem no include uf. Mas nгo te aconselho pois ela utiliza uma data de stocks.
Eu usei desta forma hб uns tempos, contudo ela nгo estб perfeita e alйm do mais nгo estб optimizada. Tambйm nгo foi full tested.
pawn Код:
stock Float:GetDistanceBetwinPoint(p1, Float:x2, Float:y2, Float:z2) //Coole[AG] gave me from some script
{
new Float:XX, Float:YY, Float:ZZ;
GetPlayerPos(p1, XX, YY, ZZ);
return floatsqroot(floatpower(floatabs(floatsub(x2,XX)),2)+floatpower(floatabs(floatsub(y2,YY)),2)+floatpower(floatabs(floatsub(z2,ZZ)),2));
}
stock GetClosestVehicle(playerid) //Coole[AG] gave me from some script
{
new car, Float:ang;
car = -1;
ang = 9999.9999;
for(new i = 0; i < MAX_PLAYERS; i++)
for(new v = 0; v < MAX_VEHICLES; v++)
{
#define INVALID_ID (0xFFFF) //65535
if(!IsPlayerConnected(i) && v == INVALID_ID) continue;
if(!IsPlayerInVehicle(i, v))
{
new Float:X, Float:Y, Float:Z;
GetVehiclePos(v, X, Y, Z);
if(ang > GetDistanceBetwinPoint(playerid, X, Y, Z))
{
ang = GetDistanceBetwinPoint(playerid, X, Y, Z);
car = v;
}
}
}
return car;
}
Para usares й simplesmente:
pawn Код:
PutPlayerInVehicle(playerid, GetClosestVehicle(playerid), seatid);
Seat ids:
0 - Driver
1 - Front Passenger
2 - Back left passenger
3 - Back right passenger
4+ - Passenger seats (coach etc.)