PDA

View Full Version : speedo bug


ajwar
13/06/2012, 03:58 PM
Problem with speedometer. After som time it stops updating speedometer, textdraw starts dissapearing. Any way to optizime and fix this speedo?

if(newstate==PLAYER_STATE_DRIVER)
{
speedotimer[playerid] = SetTimerEx("Speedo",200,1,"i",playerid);
}












pawn Code:
public Speedo(i)
{

if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new iVehicleID = GetPlayerVehicleID(i);
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]);

GetVehicleVelocity(GetPlayerVehicleID(i), svx[i], svy[i], svz[i]); // This Saves Our Velocitys To Our Varibles
s10[i] = floatsqroot(((svx[i]*svx[i])+(svy[i]*svy[i]))+(svz[i]*svz[i]))*136.666667; // This Is Our Forumula ( I Don't Know How It Works )
s2[i] = floatround(s10[i],floatround_round); // This Rounds Our Output To The Nearest Whole Number
format(s3[i],30,"SPEED: %iKM/H", s2[i]); // This Format Our Text Into What We See
format(s4[i],30,"FUEL: %iL", VehicleFuel[GetPlayerVehicleID(i)]); // This Format Our Text Into What We See

static string[16];
if(GetVehicleSpeed(iVehicleID) > 10)
{
vInfo[iVehicleID][vMeter] += floatround(floatdiv(GetVehicleSpeed(iVehicleID), 60.0));
}
if(vInfo[iVehicleID][vMeter] > 9)
{
vInfo[iVehicleID][vKm] += 1;
vInfo[iVehicleID][vMeter] = 0;
}
if(arrlen(vInfo[iVehicleID][vKm]) == 1)
{
format(string, 16, "0000%d~r~%d", vInfo[iVehicleID][vKm], vInfo[iVehicleID][vMeter]);
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][vMeter]);
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][vMeter]);
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][vMeter]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKm]) == 5)
{
format(string, 16, "%d~r~%d", vInfo[iVehicleID][vKm], vInfo[iVehicleID][vMeter]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}

PlayerTextDrawSetString(i,textdraws[Textdraw0][i], s3[i]); // This Changes The Value Of Our Textdraw To What We Formatted
PlayerTextDrawSetString(i,textdraws[Textdraw2][i], s4[i]); // This Changes The Value Of Our Textdraw To What We Formatted
return 1;
}
return 1;
}