autos laden

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
  • getFreeCarID()
    {
    for(new i=0; i<sizeof(AutoInfo); i++)
    {
    if(AutoInfo[i] [Fahrzeugid]==0)return i;

    }
    return 0;
    }
    public OnPlayerCarsLoad(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(!num_rows)return 1;
    for(new i=0; i<num_rows; i++)
    {
    new id=getFreeCarID();
    AutoInfo[i] [model]=cache_get_field_content_int(i,"Besitzer",dbhandle);
    AutoInfo[i][Besitzer]=cache_get_field_content_int(i,"model",dbhandle);
    AutoInfo[i][c_x]=cache_get_field_content_float(i,"c_x",dbhandle);
    AutoInfo[i][c_y]=cache_get_field_content_float(i,"c_y",dbhandle);
    AutoInfo[i][c_z]=cache_get_field_content_float(i,"c_z",dbhandle);
    AutoInfo[i][c_r]=cache_get_field_content_float(i,"c_r",dbhandle);
    AutoInfo[id] [db_id]=cache_get_field_content_int(i,"id",dbhandle);
    AutoInfo[id][Fahrzeugid]=CreateVehicle(AutoInfo[i][model],AutoInfo[i][c_x],AutoInfo[i][c_y],AutoInfo[i][c_z],AutoInfo[i][c_r],-1,-1,-1);
    }
    return 1;
    }
    loadplayercars(playerid)
    {
    new query[128];
    format(query,sizeof(query),"SELECT * FROM Autos WHERE Besitzer='%i' ",sInfo[playerid] [db_id]);
    mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i"playerid);
    return 1;


    autos werden zwar in die db gespeichert aber werden nach server restart nicht aus der db geladen ich weiss leider auch nicht wo der fehler sein könnte

  • Beitrag von Blackshadowscript ()

    Dieser Beitrag wurde gelöscht, Informationen über den Löschvorgang sind nicht verfügbar.
  • Joker hier noch mal der ganze code der nach deiner Meinung gehen sollte:



    getFreeCarID()
    {
    for(new i=0; i<sizeof(AutoInfo); i++)
    {
    if(AutoInfo[i] [Fahrzeugid]==0)return i;

    }
    return 0;
    }
    public OnPlayerCarsLoad(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(!num_rows)return 1;
    for(new i=0; i<num_rows; i++)
    {
    new id=getFreeCarID();
    AutoInfo[id] [model]=cache_get_field_content_int(i,"Besitzer",dbhandle);
    AutoInfo[id][Besitzer]=cache_get_field_content_int(i,"model",dbhandle);
    AutoInfo[id][c_x]=cache_get_field_content_float(i,"c_x",dbhandle);
    AutoInfo[id][c_y]=cache_get_field_content_float(i,"c_y",dbhandle);
    AutoInfo[id][c_z]=cache_get_field_content_float(i,"c_z",dbhandle);
    AutoInfo[id][c_r]=cache_get_field_content_float(i,"c_r",dbhandle);
    AutoInfo[id] [db_id]=cache_get_field_content_int(i,"id",dbhandle);
    AutoInfo[id][Fahrzeugid]=CreateVehicle(AutoInfo[id][model],AutoInfo[id][c_x],AutoInfo[id][c_y],AutoInfo[id][c_z],AutoInfo[id][c_r],-1,-1,-1);
    }
    return 1;
    }
    loadplayercars(playerid)
    {
    new query[128];
    format(query,sizeof(query),"SELECT * FROM Autos WHERE Besitzer='%i' ",sInfo[playerid] [db_id]);
    mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i"playerid);
    return 1;
    }
    public OnPasswordResponse(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows==1) //Passwort richtig
    {
    sInfo[playerid][eingeloggt] = 1;
    SendClientMessage(playerid,helbau,"Du hast dich erfolgreich eingeloggt!");
    sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][Adminlevel] = cache_get_field_content_int(0,"Adminlevel",dbhandle);
    SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
    sInfo[playerid] [db_id] = cache_get_field_content_int(0,"id",dbhandle);
    loadplayercars(playerid);

    }
    else //Passwort falsch
    {


    }
    return 1;
    }


    es geht einfach nicht

  • getFreeCarID()
    {
    for(new i=0; i<sizeof(AutoInfo); i++)
    {
    if(AutoInfo[i][Fahrzeugid] == 0)return i;
    }
    return 0;
    }
    loadplayercars(playerid)
    {
    new query[128];
    format(query,sizeof(query),"SELECT * FROM Autos WHERE Besitzer='%i' ",sInfo[playerid] [db_id]);
    mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
    return 1;
    }
    public OnPlayerCarsLoad(playerid)
    {
    printf("OnPlayerCarsLoad playerid: %d",playerid);
    if(!cache_num_rows())return 1;
    printf("rows: %d",cache_num_rows());
    for(new i;i<cache_num_rows();i++)
    {
    new id = getFreeCarID();
    AutoInfo[id][model]=cache_get_field_content_int(i,"Besitzer",dbhandle);
    AutoInfo[id][Besitzer]=cache_get_field_content_int(i,"model",dbhandle);
    AutoInfo[id][c_x]=cache_get_field_content_float(i,"c_x",dbhandle);
    AutoInfo[id][c_y]=cache_get_field_content_float(i,"c_y",dbhandle);
    AutoInfo[id][c_z]=cache_get_field_content_float(i,"c_z",dbhandle);
    AutoInfo[id][c_r]=cache_get_field_content_float(i,"c_r",dbhandle);
    AutoInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle);
    AutoInfo[id][Fahrzeugid]=CreateVehicle(AutoInfo[id][model],AutoInfo[id][c_x],AutoInfo[id][c_y],AutoInfo[id][c_z],AutoInfo[id][c_r],-1,-1,-1);
    }
    return 1;
    }


    Was wird geprintet?

  • Ich habe dir hier doch zwei Prints eingebaut, kommt da nichts?
    public OnPlayerCarsLoad(playerid)
    {
    printf("OnPlayerCarsLoad playerid: %d",playerid);
    if(!cache_num_rows())return 1;
    printf("rows: %d",cache_num_rows());
    Wenn nicht, dann lasse dir mal die Query printen ( print(query); )

  • Mencent kannst du hiermit was anfangen?


    ----------------------------------
    [13:11:52] Blackshadowscript
    [13:11:52] ----------------------------------


    [13:11:52] Number of vehicle models: 0
    [13:11:52] num rows = 1
    [13:12:08] OnPlayerCarsLoad playerid: 0
    [13:12:08] rows: 2
    [13:12:13] [part] Blackshadow has left the server (0:1)
    [13:12:17] --- Server Shutting Down.
    [13:12:17] Der Server wurde beendet
    [13:12:17]


    [13:12:17] ===============================


    [13:12:17] sscanf plugin unloaded.


    [13:12:17] ===============================


    [13:12:17] plugin.mysql: Unloading plugin...
    [13:12:17] plugin.mysql: Plugin unloaded.



    lernen.p(640) : error 017: undefined symbol "i"
    lernen.p(641) : error 017: undefined symbol "i"
    lernen.p(642) : error 017: undefined symbol "i"
    lernen.p(643) : error 017: undefined symbol "i"
    lernen.p(644) : error 017: undefined symbol "i"
    lernen.p(645) : error 017: undefined symbol "i"
    lernen.p(646) : error 017: undefined symbol "i"

  • getFreeCarID()
    {
    for(new i=0; i<sizeof(AutoInfo); i++)
    {
    if(AutoInfo[i][Fahrzeugid] == 0)return i;
    }
    return 0;
    }
    loadplayercars(playerid)
    {
    new query[128];
    format(query,sizeof(query),"SELECT * FROM Autos WHERE Besitzer='%i' ",sInfo[playerid] [db_id]);
    mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
    return 1;
    }
    public OnPlayerCarsLoad(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(!num_rows)return 1;
    for(new i=0; i<num_rows; i++)
    {
    new id=getFreeCarID();
    AutoInfo[id] [model]=cache_get_field_content_int(i,"Besitzer",dbhandle);
    AutoInfo[id][Besitzer]=cache_get_field_content_int(i,"model",dbhandle);
    AutoInfo[id][c_x]=cache_get_field_content_float(i,"c_x",dbhandle);
    AutoInfo[id][c_y]=cache_get_field_content_float(i,"c_y",dbhandle);
    AutoInfo[id][c_z]=cache_get_field_content_float(i,"c_z",dbhandle);
    AutoInfo[id][c_r]=cache_get_field_content_float(i,"c_r",dbhandle);
    AutoInfo[id] [db_id]=cache_get_field_content_int(i,"id",dbhandle);
    AutoInfo[id][Fahrzeugid]=CreateVehicle(AutoInfo[id][model],AutoInfo[id][c_x],AutoInfo[id][c_y],AutoInfo[id][c_z],AutoInfo[id][c_r],-1,-1,-1);
    }
    return 1;
    }
    public OnPasswordResponse(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows==1) //Passwort richtig
    {
    sInfo[playerid][eingeloggt] = 1;
    SendClientMessage(playerid,helbau,"Du hast dich erfolgreich eingeloggt!");
    sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][Adminlevel] = cache_get_field_content_int(0,"Adminlevel",dbhandle);
    SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
    sInfo[playerid] [db_id] = cache_get_field_content_int(0,"id",dbhandle);
    loadplayercars(playerid);

    }
    else //Passwort falsch
    {


    }
    return 1;
    }

  • Zitat

    [13:20:37] [WARNING] CMySQLResult::GetRowDataByName - field not found ("c_x")
    [13:20:37] [ERROR] cache_get_field_content_float - invalid datatype


    In deiner Tabelle Autos scheinen diese Koordinaten-Felder nicht zu existieren.