08.02.2011, 23:17
Hello everyone
and a Timer OnGameModeInit for UpdateSpeed
BUT: when I take a car the speedometer show but when the timer will SetString it creat another TextDraw on the Old
and there is many TextDraws
HOW can I do for it show one TextDraw and it SetString without another one
AND if I exit car TextDraw will hidden !
Sorry for my bad English
I hope I'll find someone to solve it
Thanks as begin =)
pawn Код:
forward UpdateSpeed();
public UpdateSpeed()
{
new Float:vh;
new S_string[256];
new Float:Sp_x, Float:Sp_y, Float:Sp_z;
new Float:kmh_speed, kmh_speed_int;
new bool:HasSpeedo[MAX_PLAYERS];
for(new i=0; i<MAX_PLAYERS; i++)
{
new vehicleid; vehicleid = GetPlayerVehicleID(i);
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && Dash[i] == 1) //Dash = enable/disable Speedometer
{
if(HasSpeedo[i])
{
GetVehicleHealth(vehicleid, vh);
GetVehicleVelocity(vehicleid,Sp_x,Sp_y,Sp_z);
kmh_speed = floatsqroot(((Sp_x*Sp_x)+(Sp_y*Sp_y))+(Sp_z*Sp_z))*136.666667;
kmh_speed_int = floatround(kmh_speed,floatround_round);
format(S_string,256,"~g~Vehicle : ~w~%s ~n~ ~b~KM/H : ~w~%d ~n~~r~Vehicle Health:~w~ %.2f",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400],kmh_speed_int,vh);
TextDrawHideForPlayer(i, Speedo[i]);
TextDrawSetString(Speedo[i], S_string);
TextDrawShowForPlayer(i, Speedo[i]);
}
else
{
GetVehicleHealth(vehicleid, vh);
GetVehicleVelocity(vehicleid,Sp_x,Sp_y,Sp_z);
kmh_speed = floatsqroot(((Sp_x*Sp_x)+(Sp_y*Sp_y))+(Sp_z*Sp_z))*136.666667;
kmh_speed_int = floatround(kmh_speed,floatround_round);
format(S_string,256,"~g~Vehicle : ~w~%s ~n~ ~b~KM/H : ~w~%d ~n~~r~Vehicle Health:~w~ %.2f",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400],kmh_speed_int,vh);
Speedo[i] = TextDrawCreate(320.00, 370.00, S_string);
TextDrawSetOutline(Speedo[i], 1);
TextDrawFont(Speedo[i], 1);
TextDrawSetProportional(Speedo[i], 2);
TextDrawAlignment(Speedo[i], 2);
TextDrawSetShadow(Speedo[i],1);
TextDrawShowForPlayer(i, Speedo[i]);
HasSpeedo[i] = true;
}
}
}
}
BUT: when I take a car the speedometer show but when the timer will SetString it creat another TextDraw on the Old
and there is many TextDraws
HOW can I do for it show one TextDraw and it SetString without another one
AND if I exit car TextDraw will hidden !
Sorry for my bad English
I hope I'll find someone to solve it
Thanks as begin =)