31.08.2014, 17:16
This command looks fine to me, but clearly I am missing something. It prints up to 5 and then stops. What's wrong with it?
pawn Код:
CMD:radar(playerid, params[])
{
if(IsPlayerPolice(playerid))
{
new string[64];
new vehicleid = GetNearestVehicle(playerid, 30.0);
print("1");
new Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, final_speed_int;
if(vehicleid != 0)
{
print("2");
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
print("3");
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*90;
print("4");
final_speed_int = floatround(final_speed,floatround_round);
print("5");
format(string, sizeof(string), "(RADAR) %s: %i mph", GetVehicleName(vehicleid), final_speed_int);
print("6");
SendClientMessage(playerid, COLOR_YELLOW, string);
print("7");
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "(RADAR) No vehicles in range.");
}
}
return 1;
}
stock GetNearestVehicle(playerid, Float:range)
{
new Float:p_X;
new Float:p_Y;
new Float:p_Z;
new Float:Distance;
new Float:vehdistance = range +1;
new nearestveh;
GetPlayerPos(playerid, p_X, p_Y, p_Z);
for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
{
Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
if(Distance <= range && Distance <= vehdistance)
{
nearestveh = vehicleid;
vehdistance = Distance;
}
}
return nearestveh;
}
stock GetVehicleName(vehicleid)
{
new string[24];
format(string,sizeof(string),"%s",vehNames[GetVehicleModel(vehicleid) - 400]);
return string;
}