Guten Tag
ich haben ein problem mit dem Fahrzeug system und zwar meine Tuning Teile laden nicht und
wenn der spieler den server velässt löscht der das auto nicht und dann wenn ich mich weider einlogge erstellt der noch mal ein fahrzeug.
Code:Wo das Fahrzeug geladen wird erstellt und so weiter.
Danke im vorraus an alle die drauf antoworten.
public OnPlayerCarLogin(playerid)
{
for(new x = 0; x < MaxVeh; x++)
{
if(!PlayerHaveCar[playerid][x])
{
new string2[128];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "/Autos/%s_Car_%d.ini", playername2,x);
new File: UserFile = fopen(string2, io_read);
if (UserFile)
{
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 , "Car_x" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Car_x] = floatstr( val ); }
if( strcmp( key , "Car_y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Car_y] = floatstr( val ); }
if( strcmp( key , "Car_z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Car_z] = floatstr( val ); }
if( strcmp( key , "Car_R" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Car_R] = 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 ); }
}
fclose(UserFile);
PlayerCarSpawn(playerid,x);
}
}
}
}
public PlayerCarSpawn(playerid,Slot)
{
if(IsPlayerConnected(playerid))
{
if(PlayerHaveCar[playerid][Slot])
{
PlayerCar[playerid][Slot][CarId] = CreateVehicle(PlayerCar[playerid][Slot][CarModel],PlayerCar[playerid][Slot][Car_x],PlayerCar[playerid][Slot][Car_y],PlayerCar[playerid][Slot][Car_z],PlayerCar[playerid][Slot][Car_R],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2],-1);
ChangeVehicleColor(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2]);
if(PlayerCar[playerid][Slot][CarPJ] >= 0) {ChangeVehiclePaintjob(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarPJ]);}
if(PlayerCar[playerid][Slot][CarNitro] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarNitro]);}
if(PlayerCar[playerid][Slot][CarHyd] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHyd]);}
if(PlayerCar[playerid][Slot][CarWheel] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarWheel]);}
if(PlayerCar[playerid][Slot][CarAusp] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarAusp]);}
if(PlayerCar[playerid][Slot][CarSideL] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideL]);}
if(PlayerCar[playerid][Slot][CarSideR] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideR]);}
if(PlayerCar[playerid][Slot][CarFB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarFB]);}
if(PlayerCar[playerid][Slot][CarRB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRB]);}
if(PlayerCar[playerid][Slot][CarSpoiler] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSpoiler]);}
if(PlayerCar[playerid][Slot][CarRoof] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRoof]);}
if(PlayerCar[playerid][Slot][CarHood] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHood]);}
if(PlayerCar[playerid][Slot][CarVents] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarVents]);}
if(PlayerCar[playerid][Slot][CarLamps] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarLamps]);}
new carid = PlayerCar[playerid][Slot][CarId];
new kennzeichen[32];
new LocationZone[MAX_ZONE_NAME];
GetPlayerCarZone(PlayerCar[playerid][Slot][CarId], LocationZone, MAX_ZONE_NAME);
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof playername);
format(kennzeichen,32, "{000000}%s %c %d", LocationZone, playername[0], carid);
SetVehicleNumberPlate(carid, kennzeichen);
}
}
}
public OnPlayerCarUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
for(new x=0;x<MaxVeh;x++)
{
if(PlayerHaveCar[playerid][x])
{
DestroyVehicle(PlayerCar[playerid][x][CarId]);
new string3[84];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Autos/%s_Car_%d.ini", 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, "Car_x=%.3f\n",PlayerCar[playerid][x][Car_x]);fwrite(hFile, var);
format(var, 32, "Car_y=%.3f\n",PlayerCar[playerid][x][Car_y]);fwrite(hFile, var);
format(var, 32, "Car_z=%.3f\n",PlayerCar[playerid][x][Car_z]);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",PlayerCar[playerid][x][Car_R]);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, "Preis=%d\n",PlayerCar[playerid][x][CarPreis]);fwrite(hFile, var);
fclose(hFile);
}
}
}
}
}
//onvehicle spawn
for(new playerid = 0;playerid <MAX_PLAYERS;playerid++)
{
for(new x=0;x<MaxVeh;x++)
{
if(IsPlayerConnected(playerid) && PlayerHaveCar[playerid][x])
{
if(vehicleid == PlayerCar[playerid][x][CarId])
{
SetTimerEx("CarTuning", 700, 0, "ii", playerid, x);
}
}
}
}
//Cartuning timer
public CarTuning(playerid,slot)
{
ChangeVehicleColor(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarC1],PlayerCar[playerid][slot][CarC2]);
if(PlayerCar[playerid][slot][CarPJ] >= 0) {ChangeVehiclePaintjob(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarPJ]);}
if(PlayerCar[playerid][slot][CarNitro] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarNitro]);}
if(PlayerCar[playerid][slot][CarHyd] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarHyd]);}
if(PlayerCar[playerid][slot][CarWheel] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarWheel]);}
if(PlayerCar[playerid][slot][CarAusp] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarAusp]);}
if(PlayerCar[playerid][slot][CarSideL] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarSideL]);}
if(PlayerCar[playerid][slot][CarSideR] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarSideR]);}
if(PlayerCar[playerid][slot][CarFB] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarFB]);}
if(PlayerCar[playerid][slot][CarRB] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarRB]);}
if(PlayerCar[playerid][slot][CarSpoiler] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarSpoiler]);}
if(PlayerCar[playerid][slot][CarRoof] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarRoof]);}
if(PlayerCar[playerid][slot][CarHood] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarHood]);}
if(PlayerCar[playerid][slot][CarVents] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarVents]);}
if(PlayerCar[playerid][slot][CarLamps] != 0) {AddVehicleComponent(PlayerCar[playerid][slot][CarId],PlayerCar[playerid][slot][CarLamps]);}
}
//Onvehicledeath --- Wenn das auto kaputt geht gehen auch die tuning teile weg ????????????
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
for(new x = 0; x < MaxVeh; x++)
{
if(IsPlayerConnected(playerid) && PlayerHaveCar[playerid][x])
{
if(vehicleid == PlayerCar[playerid][x][CarId])
{
DestroyVehicle(PlayerCar[playerid][x][CarId]);
PlayerCarSpawn(playerid,x);
}
}
}
}
Mfg.