05.02.2010, 03:57
Does Anyone Have A Radar Command That Would Allow The Police To Tell How Fast The Vehicles Are Going Around Them.
stock ClosestPlayerVehicleSpeed(playerid, &Float:speed, otherplayer=-1)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
new closest = -1, Float:dist = 200.0;
if(closest == otherplayer)
{
for(new pid=0; pid<GetMaxPlayers(); pid++)
{
if(!IsPlayerConnected(pid) || GetPlayerState != PLAYER_STATE_DRIVER || !IsPlayerInRangeOfPoint(pid,dist-1.0, X, Y, Z) || pid == playerid) continue;
//here we know we have someone closer
closese = pid;
new Float:pX, Float:Py, Float:Pz;
GetPlayerPos(pid, pX, Py, Pz);
distance = floatsqroot(floatpower(floatabs(pX-X),2)+floatpower(floatabs(pY-Y),2)+floatpower(floatabs(pZ-z),2));
}
}else if(IsPlayerConnected(pid) && GetPlayerState == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(otherplayer, dist, X, Y, Z) closest = otherplayer;
speed = GetVehicleVelocity(GetPlayerVehicleID(closest));
return closest;
}