Hey Leute. Ich wollte Fragen wie kann ich machen das es bei jedem Auto die Kilometer speichert. Sie sollen nach dem Restart auch da sein.
Hier mein Code:
#include <a_samp>
new Float:Xv[MAX_VEHICLES], Float:Yv[MAX_VEHICLES], Float:Zv[MAX_VEHICLES];
new Meters[MAX_VEHICLES];
forward KilometerTimer();
#define COLOR_COUNTER 0x00C0FFCC
//------------------------------------------------------------------------------
//=====FILTERSCRIPT=============================================================
//------------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Kilometerr");
print("--------------------------------------\n");
SetTimer("KilometerTimer", 1000, 1);
for(new i=0; i<MAX_VEHICLES; i++) {
Meters[i]=0;
SaveCoords(i);
}
return 1;
}
public KilometerTimer()
{
new string[256];
for(new i=0; i<MAX_VEHICLES; i++) {
Meters[i]+=GetDistanceToLastPoint(i);
format(string, 256, "~n~~n~~n~~n~~n~~n~~n~~y~Kilometer: ~r~%03d", Meters[i]/1000, Meters[i]/1609);
GameTextForVehiclePlayers(i, string, 3000, 3);
SaveCoords(i);
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
SaveCoords(vehicleid);
Meters[vehicleid]=0;
return 1;
}
//------------------------------------------------------------------------------
//=====STOCK====================================================================
//------------------------------------------------------------------------------
stock GameTextForVehiclePlayers(vehicleid, message[], time, style)
{
for(new a=0; a<MAX_PLAYERS; a++)
if (IsPlayerInVehicle(a, vehicleid)) GameTextForPlayer(a, message, time, style);
return 1;
}
stock GetDistanceToLastPoint(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);
}
stock SaveCoords(vehicleid)
{
new Float:X, Float:Y, Float:Z;
GetVehiclePos(vehicleid, X, Y, Z);
Xv[vehicleid]=X;
Yv[vehicleid]=Y;
Zv[vehicleid]=Z;
}
//edit
//edit