Textdraw speedo lag.
#1

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;
}
Reply
#2

Do you mean its not updating fast enough? If so you need to decrease the time on your speedometer update timer

example:

Код:
speedotimer[playerid] = SetTimerEx("Speedo",200,1,"i",playerid);
Change to
Код:
speedotimer[playerid] = SetTimerEx("Speedo",100,1,"i",playerid);
Reply
#3

Quote:
Originally Posted by guitarmandanny
Посмотреть сообщение
Do you mean its not updating fast enough? If so you need to decrease the time on your speedometer update timer

example:

Код:
speedotimer[playerid] = SetTimerEx("Speedo",200,1,"i",playerid);
Change to
Код:
speedotimer[playerid] = SetTimerEx("Speedo",100,1,"i",playerid);
Are you shure about this? How low can i have it so that it won't lag for players
Reply
#4

For speedometers I always use OnPlayerUpdate.
Reply
#5

Quote:
Originally Posted by ajwar
Посмотреть сообщение
Are you shure about this? How low can i have it so that it won't lag for players
Like Irinel says you can do it on player update which is normally a faster way of doing it but you can still do it with the timer, you can go as low as 1 millisecond
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)