Hast recht
public TachoUpdate(playerid)
{
new Float:x,Float:y,Float:z;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vid = GetPlayerVehicleID(playerid);
//new carid = CarInfo[vid][ID];
GetVehicleHealth(vid, CarInfo[vid][Schaden]);
new TachoString2[256] ,TachoString[256], TachoString1[256], TachoString3[256], TachoString4[256];
new Float:X, Float:Y, Float:Z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), X, Y, Z);
new Float:geschwindigkeit = floatsqroot(X*X + Y*Y + Z*Z) * 100 * 2.5;
new km = KmZwichenLetzenPunkt(vid);
CarInfo[vid][KM] += km;
ZwichenKM[playerid] += km;
new Float:vhealth;
GetVehicleHealth(vid, vhealth);
new Float:prozent = (vhealth < 250.0) ? 100.0 : ((100.0 - (vhealth / 10.0)) * (4.0 / 3.0));
format(TachoString2,sizeof(TachoString2),"Km/h: %d", floatround(geschwindigkeit));
format(TachoString,25,"Tank: ~y~%d/%d",CarInfo[vid][Tankinhalt], CarInfo[vid][Tankvolumen]);
format(TachoString1,25,"CarID: ~y~%d",CarInfo[vid][IDname]);
format(TachoString3,25,"KM: ~y~%d",CarInfo[vid][KM]/500);
format(TachoString4,25,"Schaden: ~y~%d", floatround(prozent));
TextDrawSetString(Tacho2, TachoString2);
TextDrawShowForPlayer(playerid, Tacho2);
TextDrawSetString(Tacho,TachoString);
TextDrawShowForPlayer(playerid, Tacho);
TextDrawSetString(Tacho1,TachoString1);
TextDrawShowForPlayer(playerid, Tacho1);
TextDrawSetString(Tacho3,TachoString3);
TextDrawShowForPlayer(playerid, Tacho3);
TextDrawSetString(Tacho4,TachoString4);
TextDrawShowForPlayer(playerid, Tacho4);
GetVehiclePos(vid, x, y, z);
Xv[vid]=x;
Yv[vid]=y;
Zv[vid]=z;
if(ZwichenKM[playerid] >= CarInfo[vid][Verbrauch])
{
CarInfo[vid][Tankinhalt] -= 1;
ZwichenKM[playerid] = 0;
}
}
}
return 1;
}
Alles anzeigen
stock KmZwichenLetzenPunkt(vehicleid)
{
new Float:x2, Float:y2, Float:z2, Float:output;
GetVehiclePos(vehicleid, x2, y2, z2);
output = floatsqroot(floatpower(floatabs(floatsub(x2, Xv[vehicleid])), 2)+floatpower(floatabs(floatsub(y2, Yv[vehicleid])), 2)+floatpower(floatabs(floatsub(z2, Zv[vehicleid])), 2));
return floatround(output);
}
MFG, Mike