Also, mein Tacho(Textdraw) wird angezeigt und sachen wie, schaden, motor(an/aus), etc. wird richtig angezeigt nur die geschwindigkeit nicht. Sie springt auf einen Wert und ist danach sofort wieder 0. Woran liegt das?
Code:
Textdraw:
new Text:TachoBox;
new Text:TachoVar[MAX_PLAYERS];//TachoMotor
new Text:TachoVar[MAX_PLAYERS];//TachoMotor
OnGameModeInit()
{
/****************************Tacho****************************/
//Tacho Textdraw - Box//
TachoBox = TextDrawCreate(495.333312, 438.051116, "usebox");
TextDrawLetterSize(TachoBox, 0.000000, -6.621851);
TextDrawTextSize(TachoBox, 621.111083, 0.000000);
TextDrawAlignment(TachoBox, 1);
TextDrawColor(TachoBox, 0);
TextDrawUseBox(TachoBox, true);
TextDrawBoxColor(TachoBox, 102);
TextDrawSetShadow(TachoBox, 0);
TextDrawSetOutline(TachoBox, 0);
TextDrawFont(TachoBox, 0);
for(new i=0; i<MAX_PLAYERS; i++)
{
//Tacho Textdraw - Motor//
TachoVar[i] = TextDrawCreate(496.888763, 382.791198, "Motor: ---~n~Km / H: ---~n~Schaden: ---~n~Liter: ---~n~");
TextDrawLetterSize(TachoVar[i], 0.401111, 1.236621);
TextDrawAlignment(TachoVar[i], 1);
TextDrawColor(TachoVar[i], -1);
TextDrawSetShadow(TachoVar[i], 0);
TextDrawSetOutline(TachoVar[i], 1);
TextDrawBackgroundColor(TachoVar[i], 51);
TextDrawFont(TachoVar[i], 1);
TextDrawSetProportional(TachoVar[i], 1);
SetTimer("UpdateTacho",TACHOTIMER,1);
}
/******************TEXTDRAW ENDE******************/
}
{
/****************************Tacho****************************/
//Tacho Textdraw - Box//
TachoBox = TextDrawCreate(495.333312, 438.051116, "usebox");
TextDrawLetterSize(TachoBox, 0.000000, -6.621851);
TextDrawTextSize(TachoBox, 621.111083, 0.000000);
TextDrawAlignment(TachoBox, 1);
TextDrawColor(TachoBox, 0);
TextDrawUseBox(TachoBox, true);
TextDrawBoxColor(TachoBox, 102);
TextDrawSetShadow(TachoBox, 0);
TextDrawSetOutline(TachoBox, 0);
TextDrawFont(TachoBox, 0);
for(new i=0; i<MAX_PLAYERS; i++)
{
//Tacho Textdraw - Motor//
TachoVar[i] = TextDrawCreate(496.888763, 382.791198, "Motor: ---~n~Km / H: ---~n~Schaden: ---~n~Liter: ---~n~");
TextDrawLetterSize(TachoVar[i], 0.401111, 1.236621);
TextDrawAlignment(TachoVar[i], 1);
TextDrawColor(TachoVar[i], -1);
TextDrawSetShadow(TachoVar[i], 0);
TextDrawSetOutline(TachoVar[i], 1);
TextDrawBackgroundColor(TachoVar[i], 51);
TextDrawFont(TachoVar[i], 1);
TextDrawSetProportional(TachoVar[i], 1);
SetTimer("UpdateTacho",TACHOTIMER,1);
}
/******************TEXTDRAW ENDE******************/
}
Funktion:
public UpdateTacho()
{
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && !IsPlayerNPC(i))
{
new Float:Strecke, Float:Geschwindigkeit, Float:vhdhealth, vhd;
new String[264], MotorAnAus[5];
new engine,doors,bonnet,boot,objective,lights,alarm;
vhd = GetPlayerVehicleID(i);
GetVehicleParamsEx(vhd,engine,lights,alarm,doors,bonnet,boot,objective);
GetVehicleHealth(vhd,vhdhealth);
GetVehiclePos(vhd,X1[i],Y1[i],Z1[i]);
Strecke = floatsqroot(floatpower(floatabs(floatsub(X1[i],X2[i])),2)+ floatpower(floatabs(floatsub(Y1[i],Y2[i])),2)+ floatpower(floatabs(floatsub(Z1[i],Z2[i])),2));
Geschwindigkeit= Strecke / (TACHOTIMER/1000) *3.6;
if(engine == 1){MotorAnAus = "An";}
else{MotorAnAus = "Aus";}
format(String,sizeof String,"Motor: %s~n~Km/H: %d~n~Schaden: %d~n~Tank: %i",MotorAnAus,floatround(Geschwindigkeit),floatround(vhdhealth),-1);
TextDrawSetString(TachoVar[i],String);//changen
GetVehiclePos(vhd,X2[i],Y2[i],Z2[i]);
TextDrawShowForPlayer(i,TachoBox);
TextDrawShowForPlayer(i,TachoVar[i]);
}
else
{
TextDrawHideForPlayer(i,TachoBox);
TextDrawHideForPlayer(i,TachoVar[i]);
}
}
return 1;
}
{
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && !IsPlayerNPC(i))
{
new Float:Strecke, Float:Geschwindigkeit, Float:vhdhealth, vhd;
new String[264], MotorAnAus[5];
new engine,doors,bonnet,boot,objective,lights,alarm;
vhd = GetPlayerVehicleID(i);
GetVehicleParamsEx(vhd,engine,lights,alarm,doors,bonnet,boot,objective);
GetVehicleHealth(vhd,vhdhealth);
GetVehiclePos(vhd,X1[i],Y1[i],Z1[i]);
Strecke = floatsqroot(floatpower(floatabs(floatsub(X1[i],X2[i])),2)+ floatpower(floatabs(floatsub(Y1[i],Y2[i])),2)+ floatpower(floatabs(floatsub(Z1[i],Z2[i])),2));
Geschwindigkeit= Strecke / (TACHOTIMER/1000) *3.6;
if(engine == 1){MotorAnAus = "An";}
else{MotorAnAus = "Aus";}
format(String,sizeof String,"Motor: %s~n~Km/H: %d~n~Schaden: %d~n~Tank: %i",MotorAnAus,floatround(Geschwindigkeit),floatround(vhdhealth),-1);
TextDrawSetString(TachoVar[i],String);//changen
GetVehiclePos(vhd,X2[i],Y2[i],Z2[i]);
TextDrawShowForPlayer(i,TachoBox);
TextDrawShowForPlayer(i,TachoVar[i]);
}
else
{
TextDrawHideForPlayer(i,TachoBox);
TextDrawHideForPlayer(i,TachoVar[i]);
}
}
return 1;
}