Kennzeichen & Autokauf Problem

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 Abend Breadfish-Community,


    ich versuche derzeitig mein Autosystem von Dini auf MySQL umzuschreiben, letztens hatte Jeffry mir wegen dem Carkey System weitergeholfe weil ich da nicht weiter kam
    jedoch komme ich jetzt nicht beim Kennzeichen lade funktion weiter...


    Lade Funktion:

    Function OnPlayerCarLogin(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    for(new x = 0; x < num_rows; x++)
    {
    if(!Dtc_PlayerHaveCar[playerid][x])
    {
    Dtc_PlayerHaveCar[playerid][x] = 1;
    //Dtc_PlayerKey[playerid];
    PlayerCar[playerid][x][CarId] = cache_get_field_content_int(x,"CarId",dbhandle);
    PlayerCar[playerid][x][CarModel] = cache_get_field_content_int(x,"CarModel",dbhandle);
    PlayerCar[playerid][x][CarPos_x] = cache_get_field_content_float(x,"CarPos_x",dbhandle);
    PlayerCar[playerid][x][CarPos_y] = cache_get_field_content_float(x,"CarPos_y",dbhandle);
    PlayerCar[playerid][x][CarPos_z] = cache_get_field_content_float(x,"CarPos_z",dbhandle);
    PlayerCar[playerid][x][CarRotate] = cache_get_field_content_float(x,"CarRotate",dbhandle);
    PlayerCar[playerid][x][CarNitro] = cache_get_field_content_int(x,"CarNitro",dbhandle);
    PlayerCar[playerid][x][CarHyd] = cache_get_field_content_int(x,"CarHyd",dbhandle);
    PlayerCar[playerid][x][CarAusp] = cache_get_field_content_int(x,"CarAusp",dbhandle);
    PlayerCar[playerid][x][CarSideL] = cache_get_field_content_int(x,"CarSideL",dbhandle);
    PlayerCar[playerid][x][CarSideR] = cache_get_field_content_int(x,"CarSideR",dbhandle);
    PlayerCar[playerid][x][CarFB] = cache_get_field_content_int(x,"CarFB",dbhandle);
    PlayerCar[playerid][x][CarRB] = cache_get_field_content_int(x,"CarRB",dbhandle);
    PlayerCar[playerid][x][CarSpoiler] = cache_get_field_content_int(x,"CarSpoiler",dbhandle);
    PlayerCar[playerid][x][CarRoof] = cache_get_field_content_int(x,"CarRoof",dbhandle);
    PlayerCar[playerid][x][CarHood] = cache_get_field_content_int(x,"CarHood",dbhandle);
    PlayerCar[playerid][x][CarVents] = cache_get_field_content_int(x,"CarVents",dbhandle);
    PlayerCar[playerid][x][CarLamps] = cache_get_field_content_int(x,"CarLamps",dbhandle);
    PlayerCar[playerid][x][CarPJ] = cache_get_field_content_int(x,"CarPJ",dbhandle);
    PlayerCar[playerid][x][CarC1] = cache_get_field_content_int(x,"CarC1",dbhandle);
    PlayerCar[playerid][x][CarC2] = cache_get_field_content_int(x,"CarC2",dbhandle);
    PlayerCar[playerid][x][CarArrest] = cache_get_field_content_int(x,"CarArrest",dbhandle);
    PlayerCar[playerid][x][Plate] = cache_get_field_content(x,"Plate",dbhandle);
    printf("Kennzeichen: %s", PlayerCar[playerid][x][Plate]);
    PlayerCarSpawn(playerid,x);
    }
    }
    return 1;
    }


    Fehlermeldung:

    (70554) : error 035: argument type mismatch (argument 3)


    Zeile:

    PlayerCar[playerid][x][Plate] = cache_get_field_content(x,"Plate",dbhandle);


    ich verstehe nicht was habe ich bei "cache_get_field_content" falsch gemacht?



    Und mein 2. Problem wäre beim Autokauf...
    Sobald man sich ein Auto gekauft hat wird dies zwar in der Datenbank erstellt aber es wird nicht gespawnt..


    Kaufen:

    Function OnPlayerBuyCar(playerid,Model,Preis,Autohaus)
    {
    if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
    {
    CallRemoteFunction("M_GivePlayerMoney","id",playerid,-Preis);
    if(Autohaus == 2) //Billig Autohaus
    {
    SBizzInfo[1][sbTill] += Preis/4; //Billig Autohaus
    }
    if(Autohaus == 3) // luxus
    {
    SBizzInfo[0][sbTill] += Preis/4; // luxus
    }
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Du hast dir ein Auto gekauft.");


    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Gehe zu der KFZ Stelle und hole dir ein Kennzeichen.");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Fahre vorsichtig..Und denk an die StraßenVerkehrsOrdnung!");
    SetPlayerCheckpoint(playerid, 3.0, 618.7498, -1458.5891, 14.0340);
    CreateBox(playerid,"","Route ~r~gesetzt~w~...");
    SetParkPlatz(playerid,Autohaus);
    new name[MAX_PLAYER_NAME],query[500];
    GetPlayerName(playerid, name, sizeof name);

    format(query,sizeof(query),"INSERT INTO autos (Name,CarOwner,CarModel,CarPos_x,CarPos_y,CarPos_z,CarRotate,CarPreis) VALUES ('%s','%s','%d','%f','%f','%f','%f','%d')",
    name,name,Model,PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate],Preis);
    mysql_function_query(dbhandle,query,false,"OnPlayerCarLogin","i",playerid);
    }
    }


    Auto Spawn:

    Function PlayerCarSpawn(playerid,Slot)
    {
    if(IsPlayerConnected(playerid))
    {
    if(Dtc_PlayerHaveCar[playerid][Slot])
    {
    PlayerCar[playerid][Slot][CarId] = CreateVehicle(PlayerCar[playerid][Slot][CarModel],PlayerCar[playerid][Slot][CarPos_x],PlayerCar[playerid][Slot][CarPos_y],PlayerCar[playerid][Slot][CarPos_z],PlayerCar[playerid][Slot][CarRotate],PlayerCar[playerid][Slot]
    [CarC1],PlayerCar[playerid][Slot][CarC2], 60000);/*vehicle spawn*/
    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]);}
    if(Dtc_LockOnSpawn)
    {
    Dtc_Carlock[PlayerCar[playerid][Slot][CarId]] = 1;
    Dtc_LockCar(PlayerCar[playerid][Slot][CarId]);
    }
    new strings[15];


    SetVehicleNumberPlate(PlayerCar[playerid][Slot][CarId], strings);
    SetVehicleToRespawn(PlayerCar[playerid][Slot][CarId]);
    for(new x = 0; x < MaxVeh; x++)
    {
    PlayerCar[playerid][x][Plate] = strings;
    }
    }
    }
    }


    Auch nach dem Auto kaufen und dem Spawnen finde ich den fehler nicht...



    Ich hoffe ihr könnt mir weiterhelfen :)


    Vielen Dank für eure Hilfe im Vorraus!


    lg
    J0a9

  • Danke Red_Romeo für deine Schnelle Antwort :)


    Ich bekomme dennoch in der Zeile diesen Fehler:

    error 001: expected token: "]", but found "-identifier-"




    Function OnPlayerCarLogin(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    for(new x = 0; x < num_rows; x++)
    {
    if(!Dtc_PlayerHaveCar[playerid][x])
    {
    Dtc_PlayerHaveCar[playerid][x] = 1;
    //Dtc_PlayerKey[playerid];
    PlayerCar[playerid][x][CarId] = cache_get_field_content_int(x,"CarId",dbhandle);
    PlayerCar[playerid][x][CarModel] = cache_get_field_content_int(x,"CarModel",dbhandle);
    PlayerCar[playerid][x][CarPos_x] = cache_get_field_content_float(x,"CarPos_x",dbhandle);
    PlayerCar[playerid][x][CarPos_y] = cache_get_field_content_float(x,"CarPos_y",dbhandle);
    PlayerCar[playerid][x][CarPos_z] = cache_get_field_content_float(x,"CarPos_z",dbhandle);
    PlayerCar[playerid][x][CarRotate] = cache_get_field_content_float(x,"CarRotate",dbhandle);
    PlayerCar[playerid][x][CarNitro] = cache_get_field_content_int(x,"CarNitro",dbhandle);
    PlayerCar[playerid][x][CarHyd] = cache_get_field_content_int(x,"CarHyd",dbhandle);
    PlayerCar[playerid][x][CarAusp] = cache_get_field_content_int(x,"CarAusp",dbhandle);
    PlayerCar[playerid][x][CarSideL] = cache_get_field_content_int(x,"CarSideL",dbhandle);
    PlayerCar[playerid][x][CarSideR] = cache_get_field_content_int(x,"CarSideR",dbhandle);
    PlayerCar[playerid][x][CarFB] = cache_get_field_content_int(x,"CarFB",dbhandle);
    PlayerCar[playerid][x][CarRB] = cache_get_field_content_int(x,"CarRB",dbhandle);
    PlayerCar[playerid][x][CarSpoiler] = cache_get_field_content_int(x,"CarSpoiler",dbhandle);
    PlayerCar[playerid][x][CarRoof] = cache_get_field_content_int(x,"CarRoof",dbhandle);
    PlayerCar[playerid][x][CarHood] = cache_get_field_content_int(x,"CarHood",dbhandle);
    PlayerCar[playerid][x][CarVents] = cache_get_field_content_int(x,"CarVents",dbhandle);
    PlayerCar[playerid][x][CarLamps] = cache_get_field_content_int(x,"CarLamps",dbhandle);
    PlayerCar[playerid][x][CarPJ] = cache_get_field_content_int(x,"CarPJ",dbhandle);
    PlayerCar[playerid][x][CarC1] = cache_get_field_content_int(x,"CarC1",dbhandle);
    PlayerCar[playerid][x][CarC2] = cache_get_field_content_int(x,"CarC2",dbhandle);
    PlayerCar[playerid][x][CarArrest] = cache_get_field_content_int(x,"CarArrest",dbhandle);
    cache_get_field_content(x, "Plate", PlayerCar[playerid][x][Plate], dbhandle, sizeof(PlayerCar[playerid][x][Plate]);
    printf("Kennzeichen: %s", PlayerCar[playerid][x][Plate]);
    PlayerCarSpawn(playerid,x);
    }
    }
    return 1;
    }


    Ich finde gerade nicht den Klammerfehler...


    Lg
    J0a9

  • Da fehlt noch eine Klammer ')' zu, falls dann noch ein Fehler bekommst versuchs mal ohne sizeof.


    //e Grade gelesen das du den Klammer fehler nicht findest.. da hilft meine Antwort auch nicht x:
    Du hast die sizeof Klammer vergessen zu schließen.


    Ansonsten versuchs wie bereits erwäht ohne sizeof
    cache_get_field_content(x, "Plate", PlayerCar[playerid][x][Plate], dbhandle);

  • Ich hätte da evtl. eine Lösung bin mir aber nicht sicher ob sie funktioniert.


    Function OnPlayerBuyCar(playerid,Model,Preis,Autohaus)
    {
    if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
    {
    CallRemoteFunction("M_GivePlayerMoney","id",playerid,-Preis);
    if(Autohaus == 2) //Billig Autohaus
    {
    SBizzInfo[1][sbTill] += Preis/4; //Billig Autohaus
    }
    if(Autohaus == 3) // luxus
    {
    SBizzInfo[0][sbTill] += Preis/4; // luxus
    }
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Du hast dir ein Auto gekauft.");

    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Gehe zu der KFZ Stelle und hole dir ein Kennzeichen.");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Fahre vorsichtig..Und denk an die StraßenVerkehrsOrdnung!");
    SetPlayerCheckpoint(playerid, 3.0, 618.7498, -1458.5891, 14.0340);
    CreateBox(playerid,"","Route ~r~gesetzt~w~...");
    SetParkPlatz(playerid,Autohaus);
    new name[MAX_PLAYER_NAME],query[500];
    GetPlayerName(playerid, name, sizeof name);

    format(query,sizeof(query),"INSERT INTO autos (Name,CarOwner,CarModel,CarPos_x,CarPos_y,CarPos_z,CarRotate,CarPreis) VALUES ('%s','%s','%d','%f','%f','%f','%f','%d')",
    name,name,Model,PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate],Preis);
    mysql_function_query(dbhandle, query, true, "LoadSavedCar", "i", playerid);
    }
    }
    forward LoadSavedCar(playerid);
    public LoadSavedCar(playerid){
    new query[128];
    format(query, sizeof(query), "SELECT * FROM autos WHERE CarId = '%i'", cache_insert_id(dbhandle));
    mysql_function_query(dbhandle,query,false,"OnPlayerCarLogin","i",playerid);
    return 1;
    }


    //e1 Ich habe grade gesehen das du bei PlayerCarSpawn einen Slot übergibst, dies müsstest du dann hier auch noch anpassen.
    //e2 Habe grade etwas vertauscht :/

  • Ich habs Probiert funktioniert aber noch nicht...
    bin aber noch am versuchen weiter auszubauen in der Hoffnung das es klappt :D


    Wenn jmd ne andere Idee hat bitte schreiben xD



    //Edit:


    @Red_Romeo:
    Deine Funktion hat doch geklappt allerdings nur so:



    forward LoadSavedCar(playerid);
    public LoadSavedCar(playerid)
    {
    new query[128];
    format(query, sizeof(query), "SELECT * FROM autos");
    mysql_function_query(dbhandle,query,false,"OnPlayerCarLogin","i",playerid);
    return 1;
    }


    Ich habe "WHERE CarId = '%i'", cache_insert_id(dbhandle)" dies entfernt und nun geht das Einwandfrei!


    Danke für deine Hilfe!!!!


    Lg
    J0a9

  • 1. Ich hatte diese Schleife und diese Abfrage nicht beachtet.
    for(new x = 0; x < num_rows; x++)
    if(!Dtc_PlayerHaveCar[playerid][x])


    2. "SELECT * FROM autos"
    Das wird nicht gut gehen.. das funktioniert nur solange es nur ein Besitzer in der Datenbank gibt,
    also musst du zumindest den Besitz abfragen.


    3. Wenn du die CarId nicht brauchst kannst du es auch noch ein wenig kürzer schreiben.
    Function OnPlayerBuyCar(playerid,Model,Preis,Autohaus)
    {
    if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
    {
    CallRemoteFunction("M_GivePlayerMoney","id",playerid,-Preis);
    if(Autohaus == 2) //Billig Autohaus
    {
    SBizzInfo[1][sbTill] += Preis/4; //Billig Autohaus
    }
    if(Autohaus == 3) // luxus
    {
    SBizzInfo[0][sbTill] += Preis/4; // luxus
    }
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Du hast dir ein Auto gekauft.");

    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Gehe zu der KFZ Stelle und hole dir ein Kennzeichen.");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "*Fahre vorsichtig..Und denk an die StraßenVerkehrsOrdnung!");
    SetPlayerCheckpoint(playerid, 3.0, 618.7498, -1458.5891, 14.0340);
    CreateBox(playerid,"","Route ~r~gesetzt~w~...");
    SetParkPlatz(playerid,Autohaus);
    new name[MAX_PLAYER_NAME],query[500];
    GetPlayerName(playerid, name, sizeof name);

    format(query,sizeof(query),"INSERT INTO autos (Name,CarOwner,CarModel,CarPos_x,CarPos_y,CarPos_z,CarRotate,CarPreis) VALUES ('%s','%s','%d','%f','%f','%f','%f','%d')",
    name,name,Model,PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z],PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate],Preis);
    mysql_function_query(dbhandle, query, false, "", "");
    format(query, sizeof(query), "SELECT * FROM autos WHERE CarOwner = '%s'",name);
    mysql_function_query(dbhandle,query,true,"OnPlayerCarLogin","i",playerid);
    }
    }