01.01.2015, 01:21
I got an little problem, when two players in the same range, and they both used a command, it will be bugged,
pawn Код:
public UpdateSpeed (vehid)
{
new id = GetVehicleInfrontID (vehid);
if (id < 0)
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
PlayerTextDrawSetString (i,RadarHud, "Speed:-");
PlayerTextDrawSetString (i,VehicleModel,"Car Model:-");
}
}
else
{
new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 187.666667, floatround_round);
for (new i = 0; i < MAX_PLAYERS; i++)
{
format (str, sizeof (str), "Speed: %d", speed);
PlayerTextDrawSetString (i,RadarHud, str);
format (str, sizeof (str), "Car Model: %s", VehicleModel22 [GetVehicleModel (id) - 400]);
PlayerTextDrawSetString (i,VehicleModel, str);
}
}
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerInVehicle (i, vehid))
{
PlayerTextDrawShow (i, RadarHud);
PlayerTextDrawShow (i, DashCamText);
PlayerTextDrawShow (i, VehicleModel);
}
}
return 1;
}
pawn Код:
CMD:dcam(playerid, params[])
{
if(DashCamActivated[playerid] == false)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehid = GetPlayerVehicleID (playerid);
if(IsACop(playerid))
{
if (VehRadarID [vehid] == -1) return 1;
{
CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
PlayerTextDrawShow (playerid,RadarHud);
PlayerTextDrawShow (playerid,VehicleModel);
PlayerTextDrawShow (playerid,DashCamText);
DashCamActivated[playerid] = true;
}
}
}
}
else
{
DashCamActivated[playerid] = false;
new vehid = GetPlayerVehicleID (playerid);
if(CheckingSpeed[vehid] > 0)
{
{
KillTimer (CheckingSpeed [vehid]);
CheckingSpeed [vehid] = -1;
PlayerTextDrawHide (playerid, RadarHud);
PlayerTextDrawHide (playerid, VehicleModel);
PlayerTextDrawHide (playerid, DashCamText);
}
}
}
return 1;
}