Thank you for your time.
stock GetClosestVehicle(playerid)
{
new Float:p_X,
Float:p_Y,
Float:p_Z,
Float:Distance,
Float:PretendentDistance = 1000.0,
Pretendent = INVALID_VEHICLE_ID
;
GetPlayerPos(playerid, p_X, p_Y, p_Z);
foreach(new i : Vehicles)
{
Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
if(Distance <= PretendentDistance)
{
Pretendent = vehicleid;
PretendentDistance = Distance;
}
}
return Pretendent;
}
CMD:command(playerid, params[])
{
new i = GetClosestVehicle(playerid);
if(i != INVALID_VEHICLE_ID)
{
PutPlayerInVehicle(playerid, i, 0);
}
return 1;
}
|
Use this function:
Код:
stock GetClosestVehicle(playerid)
{
new Float:p_X,
Float:p_Y,
Float:p_Z,
Float:Distance,
Float:PretendentDistance = 1000.0,
Pretendent = INVALID_VEHICLE_ID
;
GetPlayerPos(playerid, p_X, p_Y, p_Z);
foreach(new i : Vehicles)
{
Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
if(Distance <= PretendentDistance)
{
Pretendent = vehicleid;
PretendentDistance = Distance;
}
}
return Pretendent;
}
Код:
CMD:command(playerid, params[])
{
new i = GetClosestVehicle(playerid);
if(i != INVALID_VEHICLE_ID)
{
PutPlayerInVehicle(playerid, i, 0);
}
return 1;
}
|