Mysql speichert nicht richtig..

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
  • Hey habe Problem immernoch mit mysql-.-
    es wird einfach nicht gespeichert... was ist daran bitte falsch??


    Wo das Car erstellt wird

    if(dialogid == DIALOG_FBUY)
    {
    new fraktion;
    if(PlayerInfo[playerid][pMember] > 0) fraktion = PlayerInfo[playerid][pMember];
    if(PlayerInfo[playerid][pLeader] > 0) fraktion = PlayerInfo[playerid][pLeader];
    new veh = GetPlayerVehicleID(playerid);
    new model = GetVehicleModel(veh);
    if(response == 1)
    {
    if(FraktionsKasse[fraktion] > fpreis[playerid] -1)
    {
    new fc = FreeFrakCheck();
    if(FCInfo[fc][Model] <= 400 || FCInfo[fc][Model] >= 611)
    {
    FCInfo[fc][Model] = model;
    FCInfo[fc][fcX] = 1336.2618;
    FCInfo[fc][fcY] = -1801.3894;
    FCInfo[fc][fcZ] = 13.1913;
    FCInfo[fc][fcA] = 91.5898;
    if(model == 487 || model == 469)// hier heli
    {
    FCInfo[fc][fcX] = 1330.5385;
    FCInfo[fc][fcY] = -1820.5681;
    FCInfo[fc][fcZ] = 13.5771;
    FCInfo[fc][fcA] = 39.7293;
    }
    FCInfo[fc][Kosten] = fpreis[playerid]/2;
    FCInfo[fc][Color1] = -1;
    FCInfo[fc][Color2] = -1;
    FCInfo[fc][Fraktion] = PlayerInfo[playerid][pLeader];
    FCInfo[fc][Carid] = CreateVehicle(FCInfo[fc][Model],FCInfo[fc][fcX],FCInfo[fc][fcY],FCInfo[fc][fcZ],FCInfo[fc][fcA],FCInfo[fc][Color1],FCInfo[fc][Color2],-1);
    PutPlayerInVehicle(playerid,FCInfo[fc][Carid],0);
    SetVehicleNumberPlate(FCInfo[fc][Carid],FraktionsName(playerid));
    UnFreezePlayer(playerid);
    FraktionsKasse[fraktion] = FraktionsKasse[fraktion]-FCInfo[fc][Kosten];
    new query[128];
    format(query,sizeof(query),"INSERT INTO frakcar (id) VALUES ('%d')",fc);
    mysql_query ( query );
    mysql_free_result();
    SaveFracCar();
    return true;
    }
    fc++;
    }
    else
    {
    new string[264];
    format(string,sizeof(string),"Deine Fraktion hat nicht genug Geld für das Auto. (Auto: %d$ - Fraktion: %d$)",fpreis[playerid],FraktionsKasse[fraktion]);
    SendClientMessage(playerid,Rot,string);
    UnFreezePlayer(playerid); RemovePlayerFromVehicle(playerid);
    }
    }
    if(response == 0)
    {
    RemovePlayerFromVehicle(playerid);
    UnFreezePlayer(playerid);
    SendClientMessage(playerid,Rot,"Du hast den Kauf abgebrochen.");
    }
    }


    Speichern Stock

    stock SaveFracCar()
    {
    new query[1024];
    for(new idx;idx<MAX_FRACTION_CARS; idx++)
    {
    if(FCInfo[idx][Model] >= 400 && FCInfo[idx][Model] <= 611)
    {
    new Float:X,Float:Y,Float:Z,Float:A;
    GetVehiclePos(idx,X,Y,Z);
    GetVehicleZAngle(idx,A);
    FCInfo[idx][fcX] = X;
    FCInfo[idx][fcY] = Y;
    FCInfo[idx][fcZ] = Z;
    FCInfo[idx][fcA] = A;
    format(query,sizeof(query),"UPDATE `frakcar` SET `Kennzeichen` = '%s', `PosX` = '%f' ,`PosY` = '%f' ,`PosZ` = '%f' ,`PosA` = '%f',`Farbe 1` = '%d',`Farbe 2` = '%d',`Fraktion` = '%d',`Carid` = '%d',`Kosten` = '%d' WHERE `id` = '%d'",
    FCInfo[idx][Kennzeichen],FCInfo[idx][Model], FCInfo[idx][fcX], FCInfo[idx][fcY], FCInfo[idx][fcZ], FCInfo[idx][fcA], FCInfo[idx][Color1], FCInfo[idx][Color2], FCInfo[idx][Fraktion], FCInfo[idx][Carid],FCInfo[idx][Kosten], idx);
    mysql_query(query);
    print("FraktionsCars gespeichert!");
    }
    }
    return 1;
    }


    Bitte help!!

  • Klappt immernochnicht


    /e
    es wird auch nicht geladen... erstellt..



    stock LoadFracCar()
    {
    new val[128],query[256];
    for(new idx;idx<MAX_FRACTION_CARS; idx++)
    {
    format(query, sizeof(query), "SELECT * FROM `frakcar` WHERE `id` = %d", idx);
    mysql_query(query);
    mysql_store_result();
    if(mysql_retrieve_row())
    {
    mysql_fetch_field_row(val, "Kennzeichen");
    format(FCInfo[idx][Kennzeichen], 16, val);

    mysql_fetch_field_row(val,"Model");
    format(FCInfo[idx][Model], 16, val);


    mysql_fetch_field_row(val,"PosX");
    FCInfo[idx][fcX] = floatstr(val);


    mysql_fetch_field_row(val,"PosY");
    FCInfo[idx][fcY] = floatstr(val);


    mysql_fetch_field_row(val,"PosZ");
    FCInfo[idx][fcZ] = floatstr(val);


    mysql_fetch_field_row(val,"PosA");
    FCInfo[idx][fcA] = floatstr(val);


    mysql_fetch_field_row(val,"Farbe 1");
    format(FCInfo[idx][Color1], 16, val);


    mysql_fetch_field_row(val,"Farbe 2");
    format(FCInfo[idx][Color2], 16, val);


    mysql_fetch_field_row(val,"Fraktion");
    format(FCInfo[idx][Fraktion], 26, val);

    mysql_fetch_field_row(val,"Carid");
    format(FCInfo[idx][Carid], 16, val);

    mysql_fetch_field_row(val,"Kosten");
    format(FCInfo[idx][Kosten], 16, val);
    }
    mysql_free_result();
    if(FCInfo[idx][Model] >= 400 && FCInfo[idx][Model] <= 611)
    {
    FCInfo[idx][Carid] = CreateVehicle(FCInfo[idx][Model],FCInfo[idx][fcX],FCInfo[idx][fcY],FCInfo[idx][fcZ],FCInfo[idx][fcA],FCInfo[idx][Color1],FCInfo[idx][Color2], -1);
    SetVehicleNumberPlate(FCInfo[idx][Carid], FCInfo[idx][Kennzeichen]);
    SetVehicleToRespawn(FCInfo[idx][Carid]);
    }
    }
    }


  • Code
    [15:10:00] FraktionsCars gespeichert!
  • Hier erstellt er ja die Zeile mit der ID 0:

    SQL
    CMySQLHandler::Query(INSERT INTO `frakcar` (`id`) VALUES ('0')) - Successfully executed.


    Und hier möchte er das alles bei ID 200 eintragen

    SQL
    CMySQLHandler::Query(UPDATE `frakcar` SET `Kennzeichen` = '', `PosX` = '0.000000' ,`PosY` = '0.000000' ,`PosZ` = '0.000000' ,`PosA` = '0.000000',`Farbe 1` = '0',`Farbe 2` = '-1',`Fraktion` = '-1',`Carid` = '3',`Kosten` = '128' WHERE `id` = '200') - Successfully executed.


    Also liegt dort wahrscheinlich irgendwo dein Fehler.



    Hat er denn in der Datenbank auch eine neue Zeile erstellt? - Auch wenn diese leer geblieben ist.

  • Wenn die Zeile erstellt wird dann liegt es ganz sicher an deinem Stock "SaveFracCar()"
    Dort musst du am besten Ansetzen, da ich denke, dass nicht nur die ID nicht ganz stimmen kann,
    wenn ich mir das so anschaue..

    SQL
    CMySQLHandler::Query(UPDATE `frakcar` SET `Kennzeichen` = '', `PosX` = '0.000000' ,`PosY` = '0.000000' ,`PosZ` = '0.000000' ,`PosA` = '0.000000',`Farbe 1` = '0',`Farbe 2` = '-1',`Fraktion` = '-1',`Carid` = '3',`Kosten` = '128' WHERE `id` = '200') - Successfully executed.
  • Super! Danke! es geht!
    aber eine sache währe da noch...
    es wird nicht geladen..



    stock LoadFracCar()
    {
    new val[128],query[256];
    for(new idx;idx<MAX_FRACTION_CARS; idx++)
    {
    format(query, sizeof(query), "SELECT * FROM `frakcar` WHERE `id` = %d", idx);
    mysql_query(query);
    mysql_store_result();
    if(mysql_retrieve_row())
    {
    mysql_fetch_field_row(val, "Kennzeichen");
    format(FCInfo[idx][Kennzeichen], 16, val);

    mysql_fetch_field_row(val,"Model");
    format(FCInfo[idx][Model], 16, val);


    mysql_fetch_field_row(val,"PosX");
    FCInfo[idx][fcX] = floatstr(val);


    mysql_fetch_field_row(val,"PosY");
    FCInfo[idx][fcY] = floatstr(val);


    mysql_fetch_field_row(val,"PosZ");
    FCInfo[idx][fcZ] = floatstr(val);


    mysql_fetch_field_row(val,"PosA");
    FCInfo[idx][fcA] = floatstr(val);


    mysql_fetch_field_row(val,"Farbe 1");
    format(FCInfo[idx][Color1], 16, val);


    mysql_fetch_field_row(val,"Farbe 2");
    format(FCInfo[idx][Color2], 16, val);


    mysql_fetch_field_row(val,"Fraktion");
    format(FCInfo[idx][Fraktion], 26, val);

    mysql_fetch_field_row(val,"Carid");
    format(FCInfo[idx][Carid], 16, val);

    mysql_fetch_field_row(val,"Kosten");
    format(FCInfo[idx][Kosten], 16, val);
    }
    mysql_free_result();
    if(FCInfo[idx][Model] >= 400 && FCInfo[idx][Model] <= 611)
    {
    FCInfo[idx][Carid] = CreateVehicle(FCInfo[idx][Model],FCInfo[idx][fcX],FCInfo[idx][fcY],FCInfo[idx][fcZ],FCInfo[idx][fcA],FCInfo[idx][Color1],FCInfo[idx][Color2], -1);
    SetVehicleNumberPlate(FCInfo[idx][Carid], FCInfo[idx][Kennzeichen]);
    SetVehicleToRespawn(FCInfo[idx][Carid]);
    }
    }
    }


    Bitte help! :D

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • Also es liegt nicht an der ID...
    es wird auch geladen..


    Mysql Log:

  • format(debugmsg,sizeof(debugmsg),"CreateVehicle(%d,%f,FCInfo[idx][fcY],FCInfo[idx][fcZ],FCInfo[idx][fcA],FCInfo[idx][Color1],FCInfo[idx][Color2], -1)",FCInfo[idx][Model],FCInfo[idx][fcX], usw ..
    print(debugmsg)


    So kannst du kontrollieren, ob alle Variablen richtig angkommen

  • Es wird irgentwie nichtmal ausgeführt...
    unter OnGameModeInit ist LoadFracCars();



    stock LoadFracCar()
    {
    new val[128],query[256];
    for(new idx;idx<MAX_FRACTION_CARS; idx++)
    {
    format(query, sizeof(query), "SELECT * FROM `frakcar` WHERE `id` = %d", idx);
    mysql_query(query);
    mysql_store_result();
    if(mysql_retrieve_row())
    {
    mysql_fetch_field_row(val, "Kennzeichen");
    format(FCInfo[idx][Kennzeichen], 16, val);

    mysql_fetch_field_row(val,"Model");
    format(FCInfo[idx][Model], 16, val);


    mysql_fetch_field_row(val,"PosX");
    FCInfo[idx][fcX] = floatstr(val);


    mysql_fetch_field_row(val,"PosY");
    FCInfo[idx][fcY] = floatstr(val);


    mysql_fetch_field_row(val,"PosZ");
    FCInfo[idx][fcZ] = floatstr(val);


    mysql_fetch_field_row(val,"PosA");
    FCInfo[idx][fcA] = floatstr(val);


    mysql_fetch_field_row(val,"Farbe 1");
    format(FCInfo[idx][Color1], 16, val);


    mysql_fetch_field_row(val,"Farbe 2");
    format(FCInfo[idx][Color2], 16, val);


    mysql_fetch_field_row(val,"Fraktion");
    format(FCInfo[idx][Fraktion], 26, val);

    mysql_fetch_field_row(val,"Carid");
    format(FCInfo[idx][Carid], 16, val);

    mysql_fetch_field_row(val,"Kosten");
    format(FCInfo[idx][Kosten], 16, val);

    FCInfo[idx][Carid] = CreateVehicle(FCInfo[idx][Model],FCInfo[idx][fcX],FCInfo[idx][fcY],FCInfo[idx][fcZ],FCInfo[idx][fcA],FCInfo[idx][Color1],FCInfo[idx][Color2], -1);
    SetVehicleNumberPlate(FCInfo[idx][Carid], FCInfo[idx][Kennzeichen]);
    SetVehicleToRespawn(FCInfo[idx][Carid]);
    print("Fraktionsfahrzeuge Geladen!");
    }
    mysql_free_result();
    }
    }


  • format(FCInfo[idx][Model], 16, val);
    format(FCInfo[idx][Color1], 16, val);
    format(FCInfo[idx][Color2], 16, val);
    format(FCInfo[idx][Fraktion], 26, val);
    format(FCInfo[idx][Carid], 16, val);
    format(FCInfo[idx][Kosten], 16, val);

    fällt dir was auf? Versuchs mal mit strval :D
    FCInfo[idx][Model] = strval(val); //etc.

  • Geht immernochnicht -.-



    stock LoadFracCar()
    {
    new val[128],query[256];
    for(new idx;idx<MAX_FRACTION_CARS; idx++)
    {
    format(query, sizeof(query), "SELECT * FROM `frakcar` WHERE `id` = %d", idx);
    mysql_query(query);
    mysql_store_result();
    if(mysql_retrieve_row())
    {
    mysql_fetch_field_row(val,"Kennzeichen");
    FCInfo[idx][Kennzeichen] = strval(val);


    mysql_fetch_field_row(val,"Model");
    FCInfo[idx][Model] = strval(val);


    mysql_fetch_field_row(val,"PosX");
    FCInfo[idx][fcX] = strval(val);


    mysql_fetch_field_row(val,"PosY");
    FCInfo[idx][fcY] = strval(val);


    mysql_fetch_field_row(val,"PosZ");
    FCInfo[idx][fcZ] = strval(val);


    mysql_fetch_field_row(val,"PosA");
    FCInfo[idx][fcA] = strval(val);


    mysql_fetch_field_row(val,"Farbe 1");
    FCInfo[idx][Color1] = strval(val);


    mysql_fetch_field_row(val,"Farbe 2");
    FCInfo[idx][Color2] = strval(val);


    mysql_fetch_field_row(val,"Fraktion");
    FCInfo[idx][Fraktion] = strval(val);


    mysql_fetch_field_row(val,"Carid");
    FCInfo[idx][Carid] = strval(val);


    mysql_fetch_field_row(val,"Kosten");
    FCInfo[idx][Kosten] = strval(val);


    FCInfo[idx][Carid] = CreateVehicle(FCInfo[idx][Model],FCInfo[idx][fcX],FCInfo[idx][fcY],FCInfo[idx][fcZ],FCInfo[idx][fcA],FCInfo[idx][Color1],FCInfo[idx][Color2], -1);
    SetVehicleNumberPlate(FCInfo[idx][Carid], FCInfo[idx][Kennzeichen]);
    SetVehicleToRespawn(FCInfo[idx][Carid]);
    print("Fraktionsfahrzeuge Geladen!");
    }
    mysql_free_result();
    }
    }