if(GPLon[vehid]==1) { if(Gas[vehid]<=100 || Gas[vehid]>=70) { format(string, sizeof(string), "~g~......"); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); PlayerTextDrawFont(playerid, SpeedometerText[playerid][3], 1); } else if(Gas[vehid]<70 || Gas[vehid]>=50) { format(string, sizeof(string), "~g~.....~w~."); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } else if(Gas[vehid]<50 || Gas[vehid]>=40) { format(string, sizeof(string), "~g~....~w~.."); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } else if(Gas[vehid]<40 || Gas[vehid]>=30) { format(string, sizeof(string), "~y~...~w~..."); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } else if(Gas[vehid]<30 || Gas[vehid]>=20) { format(string, sizeof(string), "~r~..~w~...."); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } else if(Gas[vehid]<20 || Gas[vehid]>=1) { format(string, sizeof(string), "~r~.~w~....."); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } else if(Gas[vehid]<=0) { format(string, sizeof(string), "~r~......"); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } } else { format(string, sizeof(string), "......"); PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string); PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0); PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]); PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1); PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00); } |
if(GPLon[vehid]==1)
{
if(Gas[vehid]<=100 || Gas[vehid]>=70)
{
format(string, sizeof(string), "~g~......");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
PlayerTextDrawFont(playerid, SpeedometerText[playerid][3], 1);
}
else if(Gas[vehid]<70 || Gas[vehid]>=50)
{
format(string, sizeof(string), "~g~.....~w~.");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
else if(Gas[vehid]<50 || Gas[vehid]>=40)
{
format(string, sizeof(string), "~g~....~w~..");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
else if(Gas[vehid]<40 || Gas[vehid]>=30)
{
format(string, sizeof(string), "~y~...~w~...");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
else if(Gas[vehid]<30 || Gas[vehid]>=20)
{
format(string, sizeof(string), "~r~..~w~....");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
else if(Gas[vehid]<20 || Gas[vehid]>=1)
{
format(string, sizeof(string), "~r~.~w~.....");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
else if(Gas[vehid]<=0)
{
format(string, sizeof(string), "~r~......");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
}
This is untested but this may help.
PHP код:
|
The whole block of code is essentially unnecessary because the only thing that changes is the amount of colored dots. Textdraw does not need to be reshown or recreated if the text is changed.
|
if(GPLon[vehid]==1)
{
if(Gas[vehid]<=100 || Gas[vehid]>=70)
{
format(string, sizeof(string), "~g~......");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
else if(Gas[vehid]<70 || Gas[vehid]>=50)
{
format(string, sizeof(string), "~g~.....~w~.");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
else if(Gas[vehid]<50 || Gas[vehid]>=40)
{
format(string, sizeof(string), "~g~....~w~..");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
else if(Gas[vehid]<40 || Gas[vehid]>=30)
{
format(string, sizeof(string), "~y~...~w~...");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
else if(Gas[vehid]<30 || Gas[vehid]>=20)
{
format(string, sizeof(string), "~r~..~w~....");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
else if(Gas[vehid]<20 || Gas[vehid]>=1)
{
format(string, sizeof(string), "~r~.~w~.....");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
else if(Gas[vehid]<=0)
{
format(string, sizeof(string), "~r~......");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
}
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
PlayerTextDrawFont(playerid, SpeedometerText[playerid][3], 1);
}
else
{
format(string, sizeof(string), "......");
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],string);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);
}
I'd say. Don't constantly show the textdraw, just set the string.
PHP код:
|
new gasText[16] = "......";
if(GPLon[vehid]==1)
{
switch(Gas[vehid])
{
case 0: gasText = "~r~......";
case 1..19: gasText = "~r~.~w~.....";
case 20..29: gasText = "~r~..~w~....";
case 30..39: gasText = "~y~...~w~...";
case 40..49: gasText = "~g~....~w~..";
case 50..69: gasText = "~g~.....~w~.";
case 70..100: gasText = "~g~......";
default: gasText = "Malfunction";
}
}
PlayerTextDrawSetString(playerid,SpeedometerText[playerid][3],gasText);
PlayerTextDrawTextSize(playerid,SpeedometerText[playerid][3], 522+(iValue*89/200), 0);
PlayerTextDrawShow(playerid,SpeedometerText[playerid][3]);
PlayerTextDrawUseBox(playerid,SpeedometerText[playerid][3], 1);
PlayerTextDrawBoxColor(playerid,SpeedometerText[playerid][3], 0xFFFFFF00);