12.11.2012, 20:21
This speedo timer lags, what may be the problem?
pawn Код:
speedotimer[playerid] = SetTimerEx("Speedo",200,1,"i",playerid);
pawn Код:
public Speedo(i)
{
new iVehicleID = GetPlayerVehicleID(i),final_speed_int;
new s3[30],s4[30];
if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new model = GetVehicleModel(iVehicleID);
if(model ==510 || model==509 || model==481) return 1;
PlayerTextDrawShow(i, textdraws[Textdraw2][i]);
PlayerTextDrawShow(i, textdraws[Textdraw0][i]);
PlayerTextDrawShow(i, textdraws[Textdraw202][i]);
final_speed_int = floatround(GetVehicleSpeed(iVehicleID));
format(s3,30,"SPEED: %iKM/H", final_speed_int); // This Format Our Text Into What We See
format(s4,30,"FUEL: %iL", VehicleFuel[iVehicleID]); // This Format Our Text Into What We See
PlayerTextDrawSetString(i,textdraws[Textdraw0][i], s3); // This Changes The Value Of Our Textdraw To What We Formatted
PlayerTextDrawSetString(i,textdraws[Textdraw2][i], s4); // This Changes The Value Of Our Textdraw To What We Formatted
static string[16];
if(GetVehicleSpeed(iVehicleID) > 10)
{
vInfo[iVehicleID][vM] += floatround(floatdiv(GetVehicleSpeed(iVehicleID), 60.0));
}
if(vInfo[iVehicleID][vM] > 9)
{
vInfo[iVehicleID][vKM] += 1;
vInfo[iVehicleID][vM] = 0;
}
if(arrlen(vInfo[iVehicleID][vKM]) == 1)
{
format(string, 16, "0000%d~r~%d", vInfo[iVehicleID][vKM], vInfo[iVehicleID][vM]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKM]) == 2)
{
format(string, 16, "000%d~r~%d", vInfo[iVehicleID][vKM], vInfo[iVehicleID][vM]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKM]) == 3)
{
format(string, 16, "00%d~r~%d", vInfo[iVehicleID][vKM], vInfo[iVehicleID][vM]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKM]) == 4)
{
format(string, 16, "0%d~r~%d", vInfo[iVehicleID][vKM], vInfo[iVehicleID][vM]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKM]) == 5)
{
format(string, 16, "%d~r~%d", vInfo[iVehicleID][vKM], vInfo[iVehicleID][vM]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
return 1;
}
return 1;
}