21.06.2015, 18:46
@Dusan: No, and what is this?
Haven't you heard of IsValidVehicle? Yes, it's a real thing.
pawn Код:
new m = GetVehicleModel(vehicleid);
if(m == 0) return 0;
pawn Код:
#define FLOAT_INFINITY (Float:0x7F800000)
native IsValidVehicle(vehicleid);
stock GetPlayerNearestVehicle(playerid)
{
new v = -1, Float:d = FLOAT_INFINITY, Float:p[6], FLoat:tmp;
GetPlayerPos(playerid, p[0], p[1], p[2]);
p[0] -= p[3]; p[1] -= p[4]; p[2] -= p[5];
for(new i; i < MAX_VEHICLES; i++) if(IsValidVehicle(i)) {
GetVehiclePos(i, p[3], p[4], p[5]);
tmp = floatround(floatsqroot((p[0] * p[0]) + (p[1] * p[1]) + (p[2] * p[2])));
if(tmp < d) {
d = tmp;
v = i;
}
}
return IsValidVehicle(v) ? v : INVALID_VEHICLE_ID;
}