Cars werden nicht abgespeichert!

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
  • Wieso werden meine Cars und so nicht abgespeichert? Ich werde nichtmal in die Tabelle ingetragen oO


    Speichern

    Spoiler anzeigen
    stock SavePCars(playerid)
    {
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
    {
    if(GetPVarInt(playerid,"Eingeloggt") == 1)
    {
    mysql_SetString("PrivatCars", "Name", GetName(playerid), "Name", PlayerInfo[playerid][pName]);
    mysql_SetString("PrivatCars", "Autoname1", PrivatCar[playerid][1][CarName], "Name", PlayerInfo[playerid][pName]);
    mysql_SetString("PrivatCars", "Autoname2", PrivatCar[playerid][2][CarName], "Name", PlayerInfo[playerid][pName]);
    mysql_SetString("PrivatCars", "Autoname3", PrivatCar[playerid][3][CarName], "Name", PlayerInfo[playerid][pName]);
    mysql_SetString("PrivatCars", "Autoname4", PrivatCar[playerid][4][CarName], "Name", PlayerInfo[playerid][pName]);
    mysql_SetInt("PrivatCars", "modelid1", PrivatCar[playerid][1][modelid], "Name", PlayerInfo[playerid][pName]);
    mysql_SetInt("PrivatCars", "modelid2", PrivatCar[playerid][2][modelid], "Name", PlayerInfo[playerid][pName]);
    mysql_SetInt("PrivatCars", "modelid3", PrivatCar[playerid][3][modelid], "Name", PlayerInfo[playerid][pName]);
    mysql_SetInt("PrivatCars", "modelid4", PrivatCar[playerid][4][modelid], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarX1", PrivatCar[playerid][1][pcX], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarX2", PrivatCar[playerid][2][pcX], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarX3", PrivatCar[playerid][3][pcX], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarX4", PrivatCar[playerid][4][pcX], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarY1", PrivatCar[playerid][1][pcY], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarY2", PrivatCar[playerid][2][pcY], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarY3", PrivatCar[playerid][3][pcY], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarY4", PrivatCar[playerid][4][pcY], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarZ1", PrivatCar[playerid][1][pcZ], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarZ2", PrivatCar[playerid][2][pcZ], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarZ3", PrivatCar[playerid][3][pcZ], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarZ4", PrivatCar[playerid][4][pcZ], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarA1", PrivatCar[playerid][1][pcA], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarA2", PrivatCar[playerid][2][pcA], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarA3", PrivatCar[playerid][3][pcA], "Name", PlayerInfo[playerid][pName]);
    mysql_SetFloat("PrivatCars", "CarA4", PrivatCar[playerid][4][pcA], "Name", PlayerInfo[playerid][pName]);
    }
    }
    return 1;
    }


    Laden:

    Spoiler anzeigen
    stock LoadPCars(playerid)
    {
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
    {
    PrivatCar[playerid][][PlayerName] = mysql_GetString("accounts","Name","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][1][CarName] = mysql_GetString("accounts","Autoname1","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][2][CarName] = mysql_GetString("accounts","Autoname2","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][3][CarName] = mysql_GetString("accounts","Autoname3","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][4][CarName] = mysql_GetString("accounts","Autoname4","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][1][modelid] = mysql_GetInt("accounts","modelid1","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][2][modelid] = mysql_GetInt("accounts","modelid2","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][3][modelid] = mysql_GetInt("accounts","modelid3","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][4][modelid] = mysql_GetInt("accounts","modelid4","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][1][pcX] = mysql_GetFloat("accounts","CarX1","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][2][pcX] = mysql_GetFloat("accounts","CarX2","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][3][pcX] = mysql_GetFloat("accounts","CarX3","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][4][pcX] = mysql_GetFloat("accounts","CarX4","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][1][pcY] = mysql_GetFloat("accounts","CarY1","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][2][pcY] = mysql_GetFloat("accounts","CarY2","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][3][pcY] = mysql_GetFloat("accounts","CarY3","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][4][pcY] = mysql_GetFloat("accounts","CarY4","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][1][pcZ] = mysql_GetFloat("accounts","CarZ1","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][2][pcZ] = mysql_GetFloat("accounts","CarZ2","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][3][pcZ] = mysql_GetFloat("accounts","CarZ3","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][4][pcZ] = mysql_GetFloat("accounts","CarZ4","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][1][pcA] = mysql_GetFloat("accounts","CarA1","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][2][pcA] = mysql_GetFloat("accounts","CarA2","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][3][pcA] = mysql_GetFloat("accounts","CarA3","Name", PlayerInfo[playerid][pName]);
    PrivatCar[playerid][4][pcA] = mysql_GetFloat("accounts","CarA4","Name", PlayerInfo[playerid][pName]);
    }
    }


    Autokauf:

    Spoiler anzeigen
    case DIALOG_AUTOKAUF:
    {
    if(response)
    {
    for(new i=0; i<sizeof(SellCar); i++)
    {
    if(GetPlayerVehicleID(playerid)==SellCar[i][vehid])
    {
    if(PrivatCar[playerid][CarKey[playerid]][HaveKey] > 0)
    {
    Fehler(playerid,"Für diesen Schlüssel besitzt du bereits ein Fahrzeug. Benutze /carkey");
    return 1;
    }
    /*
    CarName[64],
    PlayerName[64],
    modelid,
    Float:pcX[4],
    Float:pcY[4],
    Float:pcZ[4],
    Float:pcA[4]*/
    new preis = SellCar[i][Preis];
    GivePlayerMoney(playerid,-preis);
    CreateVehicle(SellCar[i][modelid],553.5764,-1263.9396,16.9468,307.2815,1,1,60000);
    PrivatCar[playerid][CarKey[playerid]][CarName] = SellCar[i][CarName];
    PrivatCar[playerid][CarKey[playerid]][PlayerName] = GetName(playerid);
    PrivatCar[playerid][CarKey[playerid]][modelid] = SellCar[playerid][modelid];
    PrivatCar[playerid][CarKey[playerid]][pcX] = 553.5764;
    PrivatCar[playerid][CarKey[playerid]][pcY] = -1263.9396;
    PrivatCar[playerid][CarKey[playerid]][pcZ] = 16.9468;
    PrivatCar[playerid][CarKey[playerid]][pcA] = 307.2815;
    PrivatCar[playerid][CarKey[playerid]][HaveKey] = 1;
    SavePCars(playerid);
    RemovePlayerFromVehicle(playerid);
    formatEx(playerid,Gelb,"Du hast dir erfolgreich für %i$ einen %s gekauft",preis,SellCar[i][CarName]);
    return 1;
    }
    }
    }
    else
    {
    SendClientMessage(playerid,Grau,"Du hast den Kauf abgebrochen!");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    return 1;
    }

  • Weil bei den MySQL Stocks nur UPDATE drin ist nicht INSERT INTO.


    Mache dir ebend nen stock.


    /e
    Weiß nicht Ob es mit dem INSERT INTO geht aber hier der Stock mit String:

    stock mysql_SetString(Table[], Field[], Where[], Is[], To[])
    {
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    mysql_real_escape_string(To, To);
    format(query, 128, "SELECT * FROM `%s` WHERE `%s` = '%s'", Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows())//Update
    {
    format(query, 128, "UPDATE %s SET `%s` = '%s' WHERE `%s` = '%s'", Table, Field, To, Where, Is);
    mysql_query(query);
    }
    else //Insert
    {
    format(query, 128, "INSERT INTO %s (`%s`, `%s`) VALUES ('%s', '%s')", Table, Field, Where, To, Is);
    mysql_query(query);
    }
    mysql_free_result();
    return true;
    }


    /e2 Fehler gefixxt


    MFG Piet