Moin, ich hab mir mal versucht nen Tach zu machen jedoch wird die Geschwindigkeit nicht richtig angezeigt(immer unter 20, auch beim infi usw.)
Whats wrong?
public UpdateTacho()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && !IsPlayerNPC(i))
{
new Float:Strecke, Float:Geschwindigkeit;
GetVehiclePos(GetPlayerVehicleID(i),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 / (TACHO_TIMER/1000)) * 3.6;
new String[50];
GetVehiclePos(GetPlayerVehicleID(i),X2[i],Y2[i],Z2[i]);
format(String,sizeof String,"Km/H: %d",floatround(Geschwindigkeit));
TextDrawSetString(TachoSpeed[i],String);
new engine,doors,bonnet,boot,objective,lights,alarm;
GetVehicleParamsEx(GetPlayerVehicleID(i),engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1){String = "Motor: An";}
else{String = "Motor: Aus";}
TextDrawSetString(TachoMotor[i],String);
new Float:vhdhealth;
GetVehicleHealth(GetPlayerVehicleID(i),vhdhealth);
format(String,sizeof String,"Schaden: %d",floatround(vhdhealth));
TextDrawSetString(TachoDmg[i],String);
TextDrawSetString(TachoStand[i],"Tank: n/al");
TextDrawShowForPlayer(i,TachoBox);
TextDrawShowForPlayer(i,TachoMotor[i]);
TextDrawShowForPlayer(i,TachoSpeed[i]);
TextDrawShowForPlayer(i,TachoDmg[i]);
TextDrawShowForPlayer(i,TachoStand[i]);
}
else
{
TextDrawHideForPlayer(i,TachoBox);
TextDrawHideForPlayer(i,TachoMotor[i]);
TextDrawHideForPlayer(i,TachoSpeed[i]);
TextDrawHideForPlayer(i,TachoDmg[i]);
TextDrawHideForPlayer(i,TachoStand[i]);
}
}
return 1;
}
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && !IsPlayerNPC(i))
{
new Float:Strecke, Float:Geschwindigkeit;
GetVehiclePos(GetPlayerVehicleID(i),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 / (TACHO_TIMER/1000)) * 3.6;
new String[50];
GetVehiclePos(GetPlayerVehicleID(i),X2[i],Y2[i],Z2[i]);
format(String,sizeof String,"Km/H: %d",floatround(Geschwindigkeit));
TextDrawSetString(TachoSpeed[i],String);
new engine,doors,bonnet,boot,objective,lights,alarm;
GetVehicleParamsEx(GetPlayerVehicleID(i),engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1){String = "Motor: An";}
else{String = "Motor: Aus";}
TextDrawSetString(TachoMotor[i],String);
new Float:vhdhealth;
GetVehicleHealth(GetPlayerVehicleID(i),vhdhealth);
format(String,sizeof String,"Schaden: %d",floatround(vhdhealth));
TextDrawSetString(TachoDmg[i],String);
TextDrawSetString(TachoStand[i],"Tank: n/al");
TextDrawShowForPlayer(i,TachoBox);
TextDrawShowForPlayer(i,TachoMotor[i]);
TextDrawShowForPlayer(i,TachoSpeed[i]);
TextDrawShowForPlayer(i,TachoDmg[i]);
TextDrawShowForPlayer(i,TachoStand[i]);
}
else
{
TextDrawHideForPlayer(i,TachoBox);
TextDrawHideForPlayer(i,TachoMotor[i]);
TextDrawHideForPlayer(i,TachoSpeed[i]);
TextDrawHideForPlayer(i,TachoDmg[i]);
TextDrawHideForPlayer(i,TachoStand[i]);
}
}
return 1;
}