Carsystem saved nichts usw.

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Guten Tag liebe Community,


    ich habe ein Scripting Problem bei einem AUtohaussystem/Autosystem.
    Wenn ich es kaufe wird es gespawnt und wenn ich es schrotte wirds auch respawnt.
    Aber: Das Tuning wird nicht gesaved. Und wenn ich offline gehe oder Serverrestart, wird das auto nicht wieder respawnt.
    Hier der Code:

    forward AutoKaufen(playerid,autoid);
    public AutoKaufen(playerid,autoid)
    {
    for(new i = 0; i < sizeof Buycars; i++)
    {
    if(GetPlayerVehicleID(playerid) == kaufauto[i])
    {
    for(new j = 0; j < sizeof Autohaus; j++)
    {
    if(!strcmp(Autohaus[j][Name],Buycars[i][Autohausname],true))
    {
    new Autodatei[100],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,autoid);
    new File: hFile = fopen(Autodatei, io_write);
    if (hFile)
    {
    new var[32];
    format(var, 32, "cID=0\n");fwrite(hFile, var);
    format(var, 32, "mID=%d\n",GetVehicleModel(kaufauto[i]));fwrite(hFile, var);
    format(var, 32, "posx=%.3f\n",Autohaus[j][spawnx]);fwrite(hFile, var);
    format(var, 32, "posy=%.3f\n",Autohaus[j][spawny]);fwrite(hFile, var);
    format(var, 32, "posz=%.3f\n",Autohaus[j][spawnz]);fwrite(hFile, var);
    format(var, 32, "posa=%.3f\n",Autohaus[j][spawna]);fwrite(hFile, var);
    format(var, 32, "Nitro=0\n");fwrite(hFile, var);
    format(var, 32, "Hydraulics=0\n");fwrite(hFile, var);
    format(var, 32, "Wheels=0\n");fwrite(hFile, var);
    format(var, 32, "Exhaust=0\n");fwrite(hFile, var);
    format(var, 32, "FrontBumper=0\n");fwrite(hFile, var);
    format(var, 32, "RearBumper=0\n");fwrite(hFile, var);
    format(var, 32, "Spoiler=0\n");fwrite(hFile, var);
    format(var, 32, "Roof=0\n");fwrite(hFile, var);
    format(var, 32, "Hood=0\n");fwrite(hFile, var);
    format(var, 32, "Lamps=0\n");fwrite(hFile, var);
    format(var, 32, "Paintjob=-1\n");fwrite(hFile, var);
    format(var, 32, "Farbe1=-1\n");fwrite(hFile, var);
    format(var, 32, "Farbe2=-1\n");fwrite(hFile, var);
    format(var, 32, "Preis=%d\n",Buycars[i][Preis]);fwrite(hFile, var);
    fclose(hFile);
    }
    RemovePlayerFromVehicle(playerid);
    TogglePlayerControllable(playerid,1);
    GivePlayerMoney(playerid,-Buycars[i][Preis]);
    Spielercar[playerid][autoid] = CreateVehicle(Buycars[i][mID],Autohaus[j][spawnx],Autohaus[j][spawny],Autohaus[j][spawnz],Autohaus[j][spawna],-1,-1,-1);
    OnPlayerCarLogin(playerid);
    }
    }
    }
    }
    return 1;
    }
    forward SavePlayerCars(playerid);
    public SavePlayerCars(playerid)
    {
    if(IsPlayerConnected(playerid))
    {
    for(new c = 0; c<MAX_PLAYER_CARS; c++)
    {
    if(GetPVarInt(playerid,"HatAuto")>0)
    {
    DestroyVehicle(Autos[playerid][code=c][cID]);
    new Autodatei[100],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,c);
    new File: hFile = fopen(Autodatei, io_write);
    if (hFile)
    {
    new var[32];
    format(var, 32, "cID=%d\n",Autos[playerid][code=c][cID]);fwrite(hFile, var);
    format(var, 32, "mID=%d\n",Autos[playerid][code=c][mID]);fwrite(hFile, var);
    format(var, 32, "HP=%d\n",Autos[playerid][code=c][HP]);fwrite(hFile, var);
    format(var, 32, "posx=%d\n",Autos[playerid][code=c][posx]);fwrite(hFile, var);
    format(var, 32, "posy=%d\n",Autos[playerid][code=c][posy]);fwrite(hFile, var);
    format(var, 32, "posz=%d\n",Autos[playerid][code=c][posz]);fwrite(hFile, var);
    format(var, 32, "posa=%d\n",Autos[playerid][code=c][posa]);fwrite(hFile, var);
    format(var, 32, "Abgeschlossen=%d\n",Autos[playerid][code=c][Abgeschlossen]);fwrite(hFile, var);
    format(var, 32, "Farbe1=%d\n",Autos[playerid][code=c][Farbe1]);fwrite(hFile, var);
    format(var, 32, "Farbe2=%d\n",Autos[playerid][code=c][Farbe2]);fwrite(hFile, var);
    format(var, 32, "Paintjob=%d\n",Autos[playerid][code=c][Paintjob]);fwrite(hFile, var);
    format(var, 32, "Spoiler=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],0));fwrite(hFile, var);
    format(var, 32, "Hood=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],1));fwrite(hFile, var);
    format(var, 32, "Roof=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],2));fwrite(hFile, var);
    format(var, 32, "Sideskirt=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],3));fwrite(hFile, var);
    format(var, 32, "Lamps=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],4));fwrite(hFile, var);
    format(var, 32, "Nitro=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],5));fwrite(hFile, var);
    format(var, 32, "Exhaust=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],6));fwrite(hFile, var);
    format(var, 32, "Wheels=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],7));fwrite(hFile, var);
    format(var, 32, "Stereo=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],8));fwrite(hFile, var);
    format(var, 32, "Hydraulics=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],9));fwrite(hFile, var);
    format(var, 32, "FrontBumper=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],10));fwrite(hFile, var);
    format(var, 32, "RearBumper=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],11));fwrite(hFile, var);
    format(var, 32, "VentRight=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],12));fwrite(hFile, var);
    format(var, 32, "VentLeft=%d\n",GetVehicleComponentInSlot(Spielercar[playerid][code=c],13));fwrite(hFile, var);
    fclose(hFile);
    }
    }
    }
    }
    return 1;
    }
    forward OnPlayerCarLogin(playerid);
    public OnPlayerCarLogin(playerid)
    {
    for(new x = 0; x < MAX_PLAYER_CARS; x++)
    {
    if(GetPVarInt(playerid,"HatAuto")>0)
    {
    new Autodatei[100],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,x);
    new File: UserFile = fopen(Autodatei, io_read);
    if (UserFile)
    {
    new key[256], val[ 256 ];
    new Data[ 256 ];
    while ( fread( UserFile , Data , sizeof( Data ) ) )
    {
    key = ini_GetKey(Data);
    if( strcmp( key , "cID" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][cID] = strval( val ); }
    if( strcmp( key , "mID" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][mID] = strval( val ); }
    if( strcmp( key , "HP" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][HP] = strval( val ); }
    if( strcmp( key , "posx" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][posx] = floatstr( val ); }
    if( strcmp( key , "posy" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][posy] = floatstr( val ); }
    if( strcmp( key , "posz" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][posz] = floatstr( val ); }
    if( strcmp( key , "posa" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][posa] = floatstr( val ); }
    if( strcmp( key , "Abgeschlossen" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Abgeschlossen] = strval( val ); }
    if( strcmp( key , "Farbe1" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Farbe1] = strval( val ); }
    if( strcmp( key , "Farbe2" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Farbe2] = strval( val ); }
    if( strcmp( key , "Paintjob" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Paintjob] = strval( val ); }
    if( strcmp( key , "Spoiler" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Spoiler] = strval( val ); }
    if( strcmp( key , "Hood" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Hood] = strval( val ); }
    if( strcmp( key , "Roof" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Roof] = strval( val ); }
    if( strcmp( key , "Sideskirt" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Sideskirt] = strval( val ); }
    if( strcmp( key , "Exhaust" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Exhaust] = strval( val ); }
    if( strcmp( key , "Nitro" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Nitro] = strval( val ); }
    if( strcmp( key , "Exhaust" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Exhaust] = strval( val ); }
    if( strcmp( key , "Wheels" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Wheels] = strval( val ); }
    if( strcmp( key , "Stereo" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Stereo] = strval( val ); }
    if( strcmp( key , "Hydraulics" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][Hydraulics] = strval( val ); }
    if( strcmp( key , "FrontBumper" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][FrontBumper] = strval( val ); }
    if( strcmp( key , "RearBumper" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][RearBumper] = strval( val ); }
    if( strcmp( key , "VentRight" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][VentRight] = strval( val ); }
    if( strcmp( key , "VentLeft" , true ) == 0 ) { val = ini_GetValue( Data ); Autos[playerid][x][VentLeft] = strval( val ); }
    fclose(UserFile);
    PlayerCarSpawn(playerid,x);
    }
    }
    }
    }
    return 1;
    }
    forward PlayerCarSpawn(playerid,Slot);
    public PlayerCarSpawn(playerid,Slot)
    {
    if(IsPlayerConnected(playerid))
    {
    Spielercar[playerid][Slot] = CreateVehicle(Autos[playerid][Slot][mID],Autos[playerid][Slot][posx],Autos[playerid][Slot][posy],Autos[playerid][Slot][posz],Autos[playerid][Slot][posa],Autos[playerid][Slot][Farbe1],Autos[playerid][Slot][Farbe1],false);
    //Spielercar[playerid][autoid] = CreateVehicle(Buycars[i][mID],Autohaus[j][spawnx],Autohaus[j][spawny],Autohaus[j][spawnz],Autohaus[j][spawna],-1,-1,-1);
    ChangeVehicleColor(Autos[playerid][Slot][cID],Autos[playerid][Slot][Farbe1],Autos[playerid][Slot][Farbe2]);
    if(Autos[playerid][Slot][Paintjob] >= 0) {ChangeVehiclePaintjob(Autos[playerid][Slot][cID],Autos[playerid][Slot][Paintjob]);}
    if(Autos[playerid][Slot][Nitro] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Nitro]);}
    if(Autos[playerid][Slot][Hydraulics] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Hydraulics]);}
    if(Autos[playerid][Slot][Wheels] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Wheels]);}
    if(Autos[playerid][Slot][Exhaust] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Exhaust]);}
    if(Autos[playerid][Slot][FrontBumper] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][FrontBumper]);}
    if(Autos[playerid][Slot][RearBumper] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][RearBumper]);}
    if(Autos[playerid][Slot][Spoiler] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Spoiler]);}
    if(Autos[playerid][Slot][Roof] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Roof]);}
    if(Autos[playerid][Slot][Hood] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Hood]);}
    if(Autos[playerid][Slot][VentRight] !=0) { AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][VentRight]); }
    if(Autos[playerid][Slot][VentLeft] !=0) { AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][VentLeft]); }
    if(Autos[playerid][Slot][Lamps] != 0) {AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Lamps]);}
    if(Autos[playerid][Slot][Sideskirt] !=0) { AddVehicleComponent(Autos[playerid][Slot][cID],Autos[playerid][Slot][Sideskirt]); }
    SetVehicleToRespawn(Spielercar[playerid][Slot]);


    }
    return 1;
    }


    Fals weiterer Code nötig ist, bitte drunterschreiben.
    Danke für helfende Leute :)


    MFG


    DerezZeD

  • Kann uns jemand dabei Helfen?


    finde den fehler selber nicht