ich habe folgenes Problem der schaden am Fahrzeug soll speichern und beim Connecten Laden
aber und da liegt mein Problem es Speichert und Läd einfach nicht
Danke im Vorraus
Code
enum dtc_PlayerCar
{
CarId,
CarOwner[MAX_PLAYER_NAME],
CarModel,
Float:CarPos_x,
Float:CarPos_y,
Float:CarPos_z,
Float:CarRotate,
CarNitro,
CarHyd,
CarWheel,
CarAusp,
CarSideL,
CarSideR,
CarFB,
CarRB,
CarSpoiler,
CarRoof,
CarHood,
CarVents,
CarLamps,
CarPJ,
CarC1,
CarC2,
CarArrest,
CarPreis,
Plate[15],
neon1,
neon3,
neon4,
neon5,
neon6,
neon7,
Float:CarHealth,
};
new PlayerCar[MAX_PLAYERS][MaxVeh][dtc_PlayerCar];
Function OnPlayerBuyCar(playerid,Model,Preis,Autohaus)//CARSYS
{
if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
{
CallRemoteFunction("M_GivePlayerMoney","id",playerid,-Preis);
if(Autohaus == 0)
{
AddToBizzTill(0,Preis/2);
}
else if(Autohaus == 2)
{
AddToBizzTill(0,Preis);
}
else if(Autohaus == 3)
{
AddToBizzTill(0,Preis/2);
}
else if(Autohaus == 4)
{
AddToBizzTill(0,Preis/10);
}
SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Du hast dir ein Auto gekauft.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Gehe zu einem Beamten und hole dir eine Erlaubnis für einen Kennzeichen.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Danach musst du in die Stadthalle, um ein Kennzeichen für 5000$ zu kaufen.");
PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
SetParkPlatz(playerid,Autohaus);
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/Autos/%s%d.dtcar", name,Dtc_PlayerKey[playerid]);
new File: hFile = fopen(str, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarId=0\n");fwrite(hFile, var);
format(var, 32, "CarModel=%d\n",Model);fwrite(hFile, var);
format(var, 32, "CarPos_x=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x]);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y]);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z]);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate]);fwrite(hFile, var);
format(var, 32, "CarNitro=0\n");fwrite(hFile, var);
format(var, 32, "CarHyd=0\n");fwrite(hFile, var);
format(var, 32, "CarWheel=0\n");fwrite(hFile, var);
format(var, 32, "CarAusp=0\n");fwrite(hFile, var);
format(var, 32, "CarSideL=0\n");fwrite(hFile, var);
format(var, 32, "CarSideR=0\n");fwrite(hFile, var);
format(var, 32, "CarFB=0\n");fwrite(hFile, var);
format(var, 32, "CarRB=0\n");fwrite(hFile, var);
format(var, 32, "CarSpoiler=0\n");fwrite(hFile, var);
format(var, 32, "CarRoof=0\n");fwrite(hFile, var);
format(var, 32, "CarHood=0\n");fwrite(hFile, var);
format(var, 32, "CarVents=0\n");fwrite(hFile, var);
format(var, 32, "CarLamps=0\n");fwrite(hFile, var);
format(var, 32, "CarPJ=-1\n");fwrite(hFile, var);
format(var, 32, "CarC1=-1\n");fwrite(hFile, var);
format(var, 32, "CarC2=-1\n");fwrite(hFile, var);
format(var, 32, "Preis=%d\n",Preis);fwrite(hFile, var);
format(var, 32, "Abgeschleppt=0\n");fwrite(hFile, var);
format(var, 32, "Plate=-NA-\n");fwrite(hFile, var);//Plate=XXX\n
format(var, 32, "Neon1=0\n");fwrite(hFile, var);
format(var, 32, "Neon2=0\n");fwrite(hFile, var);
format(var, 32, "Neon3=0\n");fwrite(hFile, var);
format(var, 32, "Neon4=0\n");fwrite(hFile, var);
format(var, 32, "Neon5=0\n");fwrite(hFile, var);
format(var, 32, "Neon6=0\n");fwrite(hFile, var);
format(var, 32, "CarHealth=1000\n");fwrite(hFile, var);
fclose(hFile);
}
OnPlayerCarLogin(playerid);
}
}
Function OnPlayerCarLogin(playerid)
{
for(new x = 0; x < MaxVeh; x++)
{
if(!Dtc_PlayerHaveCar[playerid][x])
{
new string2[128];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "/Autos/%s%d.dtcar", playername2,x);
new File: UserFile = fopen(string2, io_read);
if (UserFile)
{
Dtc_PlayerHaveCar[playerid][x] = 1;
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "CarId" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarId] = strval( val ); }
if( strcmp( key , "CarModel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarModel] = strval( val ); }
if( strcmp( key , "CarPos_x" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_x] = floatstr( val ); }
if( strcmp( key , "CarPos_y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_y] = floatstr( val ); }
if( strcmp( key , "CarPos_z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_z] = floatstr( val ); }
if( strcmp( key , "CarRotate" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRotate] = floatstr( val ); }
if( strcmp( key , "CarNitro" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarNitro] = strval( val ); }
if( strcmp( key , "CarHyd" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarHyd] = strval( val ); }
if( strcmp( key , "CarWheel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarWheel] = strval( val ); }
if( strcmp( key , "CarAusp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarAusp] = strval( val ); }
if( strcmp( key , "CarSideL" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSideL] = strval( val ); }
if( strcmp( key , "CarSideR" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSideR] = strval( val ); }
if( strcmp( key , "CarFB" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarFB] = strval( val ); }
if( strcmp( key , "CarRB" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRB] = strval( val ); }
if( strcmp( key , "CarSpoiler" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSpoiler] = strval( val ); }
if( strcmp( key , "CarRoof" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRoof] = strval( val ); }
if( strcmp( key , "CarHood" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarHood] = strval( val ); }
if( strcmp( key , "CarVents" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarVents] = strval( val ); }
if( strcmp( key , "CarLamps" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarLamps] = strval( val ); }
if( strcmp( key , "CarPJ" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPJ] = strval( val ); }
if( strcmp( key , "CarC1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarC1] = strval( val ); }
if( strcmp( key , "CarC2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarC2] = strval( val ); }
if( strcmp( key , "Preis" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPreis] = strval( val ); }
if( strcmp( key , "Abgeschleppt" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarArrest] = strval( val ); }
if( strcmp( key , "Plate" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Plate] = strval( val ); }
if( strcmp( key , "Neon1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][neon1] = strval( val ); }
if( strcmp( key , "Neon2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][neon7] = strval( val ); }
if( strcmp( key , "Neon3" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][neon3] = strval( val ); }
if( strcmp( key , "Neon4" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][neon4] = strval( val ); }
if( strcmp( key , "Neon5" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][neon5] = strval( val ); }
if( strcmp( key , "Neon6" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][neon6] = strval( val ); }
if( strcmp( key , "CarHealth" , true ) == 0 ) { val = ini_GetValue(Data); PlayerCar[playerid][x][CarHealth] = floatstr(val); }
}
fclose(UserFile);
PlayerCarSpawn(playerid,x);
if(PlayerCar[playerid][x][CarHealth] == 0.000000){PlayerCar[playerid][x][CarHealth] = 299.000000;}
SetVehicleHealth(PlayerCar[playerid][x][CarId],PlayerCar[playerid][x][CarHealth]);
}
}
}
}
Function OnPlayerCarUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
for(new x = 0; x < MaxVeh; x++)
{
if(Dtc_PlayerHaveCar[playerid][x])
{
DestroyVehicle(PlayerCar[playerid][x][CarId]);
Dtc_Carlock[PlayerCar[playerid][x][CarId]] = 0;
Dtc_LockCar(PlayerCar[playerid][x][CarId]);
new string3[128];
new Float:carhealth;
new playername3[MAX_PLAYER_NAME];
if(carhealth == 0.000000){carhealth = 299.000000;}
GetVehicleHealth(PlayerCar[playerid][x][CarId],carhealth);
printf("CarHeal Update : %f",PlayerCar[playerid][x][CarHealth]);
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Autos/%s%d.dtcar", playername3,x);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarId=%d\n",PlayerCar[playerid][x][CarId]);fwrite(hFile, var);
format(var, 32, "CarModel=%d\n",PlayerCar[playerid][x][CarModel]);fwrite(hFile, var);
format(var, 32, "CarPos_x=%.3f\n",PlayerCar[playerid][x][CarPos_x]);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",PlayerCar[playerid][x][CarPos_y]);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",PlayerCar[playerid][x][CarPos_z]);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",PlayerCar[playerid][x][CarRotate]);fwrite(hFile, var);
format(var, 32, "CarNitro=%d\n",PlayerCar[playerid][x][CarNitro]);fwrite(hFile, var);
format(var, 32, "CarHyd=%d\n",PlayerCar[playerid][x][CarHyd]);fwrite(hFile, var);
format(var, 32, "CarWheel=%d\n",PlayerCar[playerid][x][CarWheel]);fwrite(hFile, var);
format(var, 32, "CarAusp=%d\n",PlayerCar[playerid][x][CarAusp]);fwrite(hFile, var);
format(var, 32, "CarSideL=%d\n",PlayerCar[playerid][x][CarSideL]);fwrite(hFile, var);
format(var, 32, "CarSideR=%d\n",PlayerCar[playerid][x][CarSideR]);fwrite(hFile, var);
format(var, 32, "CarFB=%d\n",PlayerCar[playerid][x][CarFB]);fwrite(hFile, var);
format(var, 32, "CarRB=%d\n",PlayerCar[playerid][x][CarRB]);fwrite(hFile, var);
format(var, 32, "CarSpoiler=%d\n",PlayerCar[playerid][x][CarSpoiler]);fwrite(hFile, var);
format(var, 32, "CarRoof=%d\n",PlayerCar[playerid][x][CarRoof]);fwrite(hFile, var);
format(var, 32, "CarHood=%d\n",PlayerCar[playerid][x][CarHood]);fwrite(hFile, var);
format(var, 32, "CarVents=%d\n",PlayerCar[playerid][x][CarVents]);fwrite(hFile, var);
format(var, 32, "CarLamps=%d\n",PlayerCar[playerid][x][CarLamps]);fwrite(hFile, var);
format(var, 32, "CarPJ=%d\n",PlayerCar[playerid][x][CarPJ]);fwrite(hFile, var);
format(var, 32, "CarC1=%d\n",PlayerCar[playerid][x][CarC1]);fwrite(hFile, var);
format(var, 32, "CarC2=%d\n",PlayerCar[playerid][x][CarC2]);fwrite(hFile, var);
format(var, 32, "Abgeschleppt=%d\n",PlayerCar[playerid][x][CarArrest]);fwrite(hFile, var);
format(var, 32, "Plate=%s\n",PlayerCar[playerid][x][Plate]);fwrite(hFile, var);
format(var, 32, "Neon1=%i\n",PlayerCar[playerid][x][neon1]);fwrite(hFile, var);
format(var, 32, "Neon2=%i\n",PlayerCar[playerid][x][neon7]);fwrite(hFile, var);
format(var, 32, "Neon3=%i\n",PlayerCar[playerid][x][neon3]);fwrite(hFile, var);
format(var, 32, "Neon4=%i\n",PlayerCar[playerid][x][neon4]);fwrite(hFile, var);
format(var, 32, "Neon5=%i\n",PlayerCar[playerid][x][neon5]);fwrite(hFile, var);
format(var, 32, "Neon6=%i\n",PlayerCar[playerid][x][neon6]);fwrite(hFile, var);
format(var, 32, "CarHealth=%f\n",carhealth);fwrite(hFile, var);
fclose(hFile);
}
}
}
}
}
Alles anzeigen