Schaden vom Auto Speichern

  • Schaden vom Auto Speichern

    Hallo ich bräuchte mal eure Hilfe undzwar wie ich Schaden vom Fahrzeug Privat Car Speichere und Lade?

    Ich denke das Ganze Funktioniert mit GetVehicleHealth aber ich bin mir grad nicht sicher wie genau?


    Speicherung

    PAWN-Quellcode

    1. format(dateiname, sizeof(dateiname), "%s.car", playername);
    2. new File: CarFile = fopen(dateiname, io_write);
    3. format(var, 256, "AH_Typ=%i\n", Carlist[playerid][Typ]); fwrite(CarFile, var);
    4. format(var, 256, "AH_X=%f\n", Carlist[playerid][XX]); fwrite(CarFile, var);
    5. format(var, 256, "AH_Y=%f\n", Carlist[playerid][YY]); fwrite(CarFile, var);
    6. format(var, 256, "AH_Z=%f\n", Carlist[playerid][ZZ]); fwrite(CarFile, var);
    7. format(var, 256, "AH_Rot=%f\n", Carlist[playerid][Rotation]); fwrite(CarFile, var);
    8. format(var, 256, "AH_Status=%i\n", Carlist[playerid][Status]); fwrite(CarFile, var);
    9. format(var, 256, "AH_Lock=%i\n", Carlist[playerid][Lock]); fwrite(CarFile, var);
    10. format(var, 256, "AH_Paintjob=%i\n", Carlist[playerid][Paintjob]); fwrite(CarFile, var);
    11. format(var, 256, "AH_Farbe1=%i\n", Carlist[playerid][Farbe1]); fwrite(CarFile, var);
    12. format(var, 256, "AH_Farbe2=%i\n", Carlist[playerid][Farbe2]); fwrite(CarFile, var);
    13. format(var, 256, "AH_mod1=%i\n", Carlist[playerid][mod1]); fwrite(CarFile, var);
    14. format(var, 256, "AH_mod2=%i\n", Carlist[playerid][mod2]); fwrite(CarFile, var);
    15. format(var, 256, "AH_mod3=%i\n", Carlist[playerid][mod3]); fwrite(CarFile, var);
    16. format(var, 256, "AH_mod4=%i\n", Carlist[playerid][mod4]); fwrite(CarFile, var);
    17. format(var, 256, "AH_mod5=%i\n", Carlist[playerid][mod5]); fwrite(CarFile, var);
    18. format(var, 256, "AH_mod6=%i\n", Carlist[playerid][mod6]); fwrite(CarFile, var);
    19. format(var, 256, "AH_mod7=%i\n", Carlist[playerid][mod7]); fwrite(CarFile, var);
    20. format(var, 256, "AH_mod8=%i\n", Carlist[playerid][mod8]); fwrite(CarFile, var);
    21. format(var, 256, "AH_mod9=%i\n", Carlist[playerid][mod9]); fwrite(CarFile, var);
    22. format(var, 256, "AH_mod10=%i\n", Carlist[playerid][mod10]); fwrite(CarFile, var);
    23. format(var, 256, "AH_mod11=%i\n", Carlist[playerid][mod11]); fwrite(CarFile, var);
    24. format(var, 256, "AH_mod12=%i\n", Carlist[playerid][mod12]); fwrite(CarFile, var);
    25. format(var, 256, "AH_mod13=%i\n", Carlist[playerid][mod13]); fwrite(CarFile, var);
    26. format(var, 256, "AH_mod14=%i\n", Carlist[playerid][mod14]); fwrite(CarFile, var);
    27. format(var, 256, "AH_mod15=%i\n", Carlist[playerid][mod15]); fwrite(CarFile, var);
    28. format(var, 256, "AH_mod16=%i\n", Carlist[playerid][mod16]); fwrite(CarFile, var);
    29. format(var, 256, "AH_mod17=%i\n", Carlist[playerid][mod17]); fwrite(CarFile, var);
    Alles anzeigen



    Wird Geladen

    PAWN-Quellcode

    1. while ( fread( CarFile , Data , sizeof( Data ) ) )
    2. {
    3. key = ini_GetKey(Data);
    4. if(strcmp(key,"AH_Typ",true)==0) { Carlist[playerid][Typ]=strval(ini_GetValue(Data)); }
    5. else if(strcmp(key,"AH_X",true)==0) { Carlist[playerid][XX]=floatstr(ini_GetValue(Data)); }
    6. else if(strcmp(key,"AH_Y",true)==0) { Carlist[playerid][YY]=floatstr(ini_GetValue(Data)); }
    7. else if(strcmp(key,"AH_Z",true)==0) { Carlist[playerid][ZZ]=floatstr(ini_GetValue(Data)); }
    8. else if(strcmp(key,"AH_Rot",true)==0) { Carlist[playerid][Rotation]=floatstr(ini_GetValue(Data)); }
    9. else if(strcmp(key,"AH_Status",true)==0) { Carlist[playerid][Status]=strval(ini_GetValue(Data)); }
    10. else if(strcmp(key,"AH_Lock",true)==0) { Carlist[playerid][Lock]=strval(ini_GetValue(Data)); }
    11. else if(strcmp(key,"AH_Paintjob",true)==0) { Carlist[playerid][Paintjob]=strval(ini_GetValue(Data)); }
    12. else if(strcmp(key,"AH_Farbe1",true)==0) { Carlist[playerid][Farbe1]=strval(ini_GetValue(Data)); }
    13. else if(strcmp(key,"AH_Farbe2",true)==0) { Carlist[playerid][Farbe2]=strval(ini_GetValue(Data)); }
    14. else if(strcmp(key,"AH_mod1",true)==0) { Carlist[playerid][mod1]=strval(ini_GetValue(Data)); }
    15. else if(strcmp(key,"AH_mod2",true)==0) { Carlist[playerid][mod2]=strval(ini_GetValue(Data)); }
    16. else if(strcmp(key,"AH_mod3",true)==0) { Carlist[playerid][mod3]=strval(ini_GetValue(Data)); }
    17. else if(strcmp(key,"AH_mod4",true)==0) { Carlist[playerid][mod4]=strval(ini_GetValue(Data)); }
    18. else if(strcmp(key,"AH_mod5",true)==0) { Carlist[playerid][mod5]=strval(ini_GetValue(Data)); }
    19. else if(strcmp(key,"AH_mod6",true)==0) { Carlist[playerid][mod6]=strval(ini_GetValue(Data)); }
    20. else if(strcmp(key,"AH_mod7",true)==0) { Carlist[playerid][mod7]=strval(ini_GetValue(Data)); }
    21. else if(strcmp(key,"AH_mod8",true)==0) { Carlist[playerid][mod8]=strval(ini_GetValue(Data)); }
    22. else if(strcmp(key,"AH_mod9",true)==0) { Carlist[playerid][mod9]=strval(ini_GetValue(Data)); }
    23. else if(strcmp(key,"AH_mod10",true)==0) { Carlist[playerid][mod10]=strval(ini_GetValue(Data)); }
    24. else if(strcmp(key,"AH_mod11",true)==0) { Carlist[playerid][mod11]=strval(ini_GetValue(Data)); }
    25. else if(strcmp(key,"AH_mod12",true)==0) { Carlist[playerid][mod12]=strval(ini_GetValue(Data)); }
    26. else if(strcmp(key,"AH_mod13",true)==0) { Carlist[playerid][mod13]=strval(ini_GetValue(Data)); }
    27. else if(strcmp(key,"AH_mod14",true)==0) { Carlist[playerid][mod14]=strval(ini_GetValue(Data)); }
    28. else if(strcmp(key,"AH_mod15",true)==0) { Carlist[playerid][mod15]=strval(ini_GetValue(Data)); }
    29. else if(strcmp(key,"AH_mod16",true)==0) { Carlist[playerid][mod16]=strval(ini_GetValue(Data)); }
    30. else if(strcmp(key,"AH_mod17",true)==0) { Carlist[playerid][mod17]=strval(ini_GetValue(Data)); }
    31. }
    Alles anzeigen


    Mein Facebook Profil: Klick mich [FACEBOOK]

    Youtube Kanal: Klick mich [YOUTUBE]

    Skype: Klick mich "SKYPE"

    Windows Live: lala16@hotmail.de


    Role of German Mein Server.

    Server ip: Noch im Aufbau (0.1 Alpha)

    Forum: kommt rog-reallife.de/

    Role of German befindet sich derzeit noch in der Entwicklung es handelt sich um ein Komplett Selfmade was in Richtung Life of German geht




    #Server Trailer #1


    Video entfernt


    Xbox 360

    Steam : Ronny19



    Meine Werke könnt ihr hier auf Mein Profil Finden Klick hier im meine Werke zu sehen



  • Naja...so:

    PAWN-Quellcode

    1. //Oben einfügen:
    2. new Float:h;
    3. GetVehicleHealth(vehicleid,h);
    4. format(var, 256, "CarHealth=%f\n", h); fwrite(CarFile, var);
    5. //Unten einfügen:
    6. else if(strcmp(key,"CarHealth",true)==0) { SetVehicleHealth(vehicleid,floatstr(ini_GetValue(Data))); }


    oder speichere die Werte noch zwischen ;)

    mfg. :thumbup:


    Leute, lernt scripten und versucht mal lieber etwas selber zu schreiben, als es aus einem GF zu kopieren. X/
  • Kaliber schrieb:

    Naja...so:

    PAWN-Quellcode

    1. //Oben einfügen:
    2. new Float:h;
    3. GetVehicleHealth(vehicleid,h);
    4. format(var, 256, "CarHealth=%f\n", h); fwrite(CarFile, var);
    5. //Unten einfügen:
    6. else if(strcmp(key,"CarHealth",true)==0) { SetVehicleHealth(vehicleid,floatstr(ini_GetValue(Data))); }


    oder speichere die Werte noch zwischen ;)

    mfg. :thumbup:



    Danke aber Es Speichert nicht?


    Mein Facebook Profil: Klick mich [FACEBOOK]

    Youtube Kanal: Klick mich [YOUTUBE]

    Skype: Klick mich "SKYPE"

    Windows Live: lala16@hotmail.de


    Role of German Mein Server.

    Server ip: Noch im Aufbau (0.1 Alpha)

    Forum: kommt rog-reallife.de/

    Role of German befindet sich derzeit noch in der Entwicklung es handelt sich um ein Komplett Selfmade was in Richtung Life of German geht




    #Server Trailer #1


    Video entfernt


    Xbox 360

    Steam : Ronny19



    Meine Werke könnt ihr hier auf Mein Profil Finden Klick hier im meine Werke zu sehen



  • Kaliber schrieb:

    Ronny17 schrieb:

    Danke aber Es Speichert nicht?

    ...wie hast du es denn eingefügt? :huh:





    Wenn es geladen wird

    PAWN-Quellcode

    1. if (fexist(dateiname))
    2. {
    3. new File: CarFile = fopen(dateiname, io_read);
    4. if ( CarFile )
    5. {
    6. new key[ 256 ];
    7. new Data[ 256 ];
    8. while ( fread( CarFile , Data , sizeof( Data ) ) )
    9. {
    10. new vehicleid = GetPlayerVehicleID(playerid);
    11. key = ini_GetKey(Data);
    12. if(strcmp(key,"AH_Typ",true)==0) { Carlist[playerid][Typ]=strval(ini_GetValue(Data)); }
    13. else if(strcmp(key,"AH_X",true)==0) { Carlist[playerid][XX]=floatstr(ini_GetValue(Data)); }
    14. else if(strcmp(key,"AH_Y",true)==0) { Carlist[playerid][YY]=floatstr(ini_GetValue(Data)); }
    15. else if(strcmp(key,"AH_Z",true)==0) { Carlist[playerid][ZZ]=floatstr(ini_GetValue(Data)); }
    16. else if(strcmp(key,"AH_Rot",true)==0) { Carlist[playerid][Rotation]=floatstr(ini_GetValue(Data)); }
    17. else if(strcmp(key,"AH_Status",true)==0) { Carlist[playerid][Status]=strval(ini_GetValue(Data)); }
    18. else if(strcmp(key,"AH_Lock",true)==0) { Carlist[playerid][Lock]=strval(ini_GetValue(Data)); }
    19. else if(strcmp(key,"AH_Paintjob",true)==0) { Carlist[playerid][Paintjob]=strval(ini_GetValue(Data)); }
    20. else if(strcmp(key,"AH_Farbe1",true)==0) { Carlist[playerid][Farbe1]=strval(ini_GetValue(Data)); }
    21. else if(strcmp(key,"AH_Farbe2",true)==0) { Carlist[playerid][Farbe2]=strval(ini_GetValue(Data)); }
    22. else if(strcmp(key,"AH_mod1",true)==0) { Carlist[playerid][mod1]=strval(ini_GetValue(Data)); }
    23. else if(strcmp(key,"AH_mod2",true)==0) { Carlist[playerid][mod2]=strval(ini_GetValue(Data)); }
    24. else if(strcmp(key,"AH_mod3",true)==0) { Carlist[playerid][mod3]=strval(ini_GetValue(Data)); }
    25. else if(strcmp(key,"AH_mod4",true)==0) { Carlist[playerid][mod4]=strval(ini_GetValue(Data)); }
    26. else if(strcmp(key,"AH_mod5",true)==0) { Carlist[playerid][mod5]=strval(ini_GetValue(Data)); }
    27. else if(strcmp(key,"AH_mod6",true)==0) { Carlist[playerid][mod6]=strval(ini_GetValue(Data)); }
    28. else if(strcmp(key,"AH_mod7",true)==0) { Carlist[playerid][mod7]=strval(ini_GetValue(Data)); }
    29. else if(strcmp(key,"AH_mod8",true)==0) { Carlist[playerid][mod8]=strval(ini_GetValue(Data)); }
    30. else if(strcmp(key,"AH_mod9",true)==0) { Carlist[playerid][mod9]=strval(ini_GetValue(Data)); }
    31. else if(strcmp(key,"AH_mod10",true)==0) { Carlist[playerid][mod10]=strval(ini_GetValue(Data)); }
    32. else if(strcmp(key,"AH_mod11",true)==0) { Carlist[playerid][mod11]=strval(ini_GetValue(Data)); }
    33. else if(strcmp(key,"AH_mod12",true)==0) { Carlist[playerid][mod12]=strval(ini_GetValue(Data)); }
    34. else if(strcmp(key,"AH_mod13",true)==0) { Carlist[playerid][mod13]=strval(ini_GetValue(Data)); }
    35. else if(strcmp(key,"AH_mod14",true)==0) { Carlist[playerid][mod14]=strval(ini_GetValue(Data)); }
    36. else if(strcmp(key,"AH_mod15",true)==0) { Carlist[playerid][mod15]=strval(ini_GetValue(Data)); }
    37. else if(strcmp(key,"AH_mod16",true)==0) { Carlist[playerid][mod16]=strval(ini_GetValue(Data)); }
    38. else if(strcmp(key,"AH_mod17",true)==0) { Carlist[playerid][mod17]=strval(ini_GetValue(Data)); }
    39. else if(strcmp(key,"CarHealth",true)==0) { SetVehicleHealth(vehicleid,floatstr(ini_GetValue(Data))); }
    40. }
    41. }
    Alles anzeigen




    Wenn es gespeichert wird


    PAWN-Quellcode

    1. new File: CarFile = fopen(dateiname, io_write);
    2. format(var, 256, "AH_Typ=%i\n", Carlist[playerid][Typ]); fwrite(CarFile, var);
    3. format(var, 256, "AH_X=%f\n", Carlist[playerid][XX]); fwrite(CarFile, var);
    4. format(var, 256, "AH_Y=%f\n", Carlist[playerid][YY]); fwrite(CarFile, var);
    5. format(var, 256, "AH_Z=%f\n", Carlist[playerid][ZZ]); fwrite(CarFile, var);
    6. format(var, 256, "AH_Rot=%f\n", Carlist[playerid][Rotation]); fwrite(CarFile, var);
    7. format(var, 256, "AH_Status=%i\n", Carlist[playerid][Status]); fwrite(CarFile, var);
    8. format(var, 256, "AH_Lock=%i\n", Carlist[playerid][Lock]); fwrite(CarFile, var);
    9. format(var, 256, "AH_Paintjob=%i\n", Carlist[playerid][Paintjob]); fwrite(CarFile, var);
    10. format(var, 256, "AH_Farbe1=%i\n", Carlist[playerid][Farbe1]); fwrite(CarFile, var);
    11. format(var, 256, "AH_Farbe2=%i\n", Carlist[playerid][Farbe2]); fwrite(CarFile, var);
    12. format(var, 256, "AH_mod1=%i\n", Carlist[playerid][mod1]); fwrite(CarFile, var);
    13. format(var, 256, "AH_mod2=%i\n", Carlist[playerid][mod2]); fwrite(CarFile, var);
    14. format(var, 256, "AH_mod3=%i\n", Carlist[playerid][mod3]); fwrite(CarFile, var);
    15. format(var, 256, "AH_mod4=%i\n", Carlist[playerid][mod4]); fwrite(CarFile, var);
    16. format(var, 256, "AH_mod5=%i\n", Carlist[playerid][mod5]); fwrite(CarFile, var);
    17. format(var, 256, "AH_mod6=%i\n", Carlist[playerid][mod6]); fwrite(CarFile, var);
    18. format(var, 256, "AH_mod7=%i\n", Carlist[playerid][mod7]); fwrite(CarFile, var);
    19. format(var, 256, "AH_mod8=%i\n", Carlist[playerid][mod8]); fwrite(CarFile, var);
    20. format(var, 256, "AH_mod9=%i\n", Carlist[playerid][mod9]); fwrite(CarFile, var);
    21. format(var, 256, "AH_mod10=%i\n", Carlist[playerid][mod10]); fwrite(CarFile, var);
    22. format(var, 256, "AH_mod11=%i\n", Carlist[playerid][mod11]); fwrite(CarFile, var);
    23. format(var, 256, "AH_mod12=%i\n", Carlist[playerid][mod12]); fwrite(CarFile, var);
    24. format(var, 256, "AH_mod13=%i\n", Carlist[playerid][mod13]); fwrite(CarFile, var);
    25. format(var, 256, "AH_mod14=%i\n", Carlist[playerid][mod14]); fwrite(CarFile, var);
    26. format(var, 256, "AH_mod15=%i\n", Carlist[playerid][mod15]); fwrite(CarFile, var);
    27. format(var, 256, "AH_mod16=%i\n", Carlist[playerid][mod16]); fwrite(CarFile, var);
    28. format(var, 256, "AH_mod17=%i\n", Carlist[playerid][mod17]); fwrite(CarFile, var);
    29. format(var, 256, "CarHealth=%f\n", h); fwrite(CarFile, var);
    Alles anzeigen


    //EDIT was vergessen


    Mein Facebook Profil: Klick mich [FACEBOOK]

    Youtube Kanal: Klick mich [YOUTUBE]

    Skype: Klick mich "SKYPE"

    Windows Live: lala16@hotmail.de


    Role of German Mein Server.

    Server ip: Noch im Aufbau (0.1 Alpha)

    Forum: kommt rog-reallife.de/

    Role of German befindet sich derzeit noch in der Entwicklung es handelt sich um ein Komplett Selfmade was in Richtung Life of German geht




    #Server Trailer #1


    Video entfernt


    Xbox 360

    Steam : Ronny19



    Meine Werke könnt ihr hier auf Mein Profil Finden Klick hier im meine Werke zu sehen