tankstellen werden nicht erstellt

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
  • meine tankstellen werden irgentwie nicht geladen...
    ich bin noch änfänger ich mysql ich hoffe um hilfe
    ich habe mysql_log(1); in OnGameModeInit aber es ist nirgens ein logfile


    Loadtanke:

    public LoadTanke(){
    for(new t; t<MAX_TANKE; t++){
    new query[60 + MAX_PLAYER_NAME];
    mysql_format(mycon,query, sizeof(query), "SELECT * FROM `Tankstellen` WHERE `TankID` = '%e'",t);
    cache_get_field_content(0,"Name",TankInfo[t][tName]),cache_get_field_content(0,"oName",TankInfo[t][oName]),TankInfo[t][tX] = cache_get_field_content_float(0,"PosX");
    TankInfo[t][tY] = cache_get_field_content_float(0,"PosY"),TankInfo[t][tZ] = cache_get_field_content_float(0,"PosZ"),TankInfo[t][Preis] = cache_get_field_content_int(0,"Preis");
    TankInfo[t][sPreis] = cache_get_field_content_int(0,"Spritpreis"),TankInfo[t][Tankgeld] = cache_get_field_content_int(0,"Tankgeld");
    switch(cache_get_field_content_int(0,"Owned")){
    case 0: TankInfo[t][Owned] = false;
    case 1: TankInfo[t][Owned] = true;
    }
    if(TankInfo[t][Owned] == false){
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nPreis: %d\nTankstelle zu verkaufen!\nBenutze /tanke",t,TankInfo[t][tName],TankInfo[t][Preis]);
    TankLabel[t] = Create3DTextLabel(string,Türkis,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    else {
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nBesitzer: %s\nSpritpreis: %d\nBenutze /tanken",t,TankInfo[t][tName],TankInfo[t][oName],TankInfo[t][sPreis]);
    TankLabel[t] = Create3DTextLabel(string,Rot,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    }
    return 1;
    }

  • Habe es momentan so:



    Func LoadTanke(){
    for(new t; t<MAX_TANKE; t++){
    new query[60 + MAX_PLAYER_NAME];
    mysql_format(mycon,query, sizeof(query), "SELECT * FROM `Tankstellen` WHERE `TankID` = '%i'",t);
    cache_get_field_content(0,"Name",TankInfo[t][tName]),cache_get_field_content(0,"oName",TankInfo[t][oName]),TankInfo[t][tX] = cache_get_field_content_float(0,"PosX");
    TankInfo[t][tY] = cache_get_field_content_float(0,"PosY"),TankInfo[t][tZ] = cache_get_field_content_float(0,"PosZ"),TankInfo[t][Preis] = cache_get_field_content_int(0,"Preis");
    TankInfo[t][sPreis] = cache_get_field_content_int(0,"Spritpreis"),TankInfo[t][Tankgeld] = cache_get_field_content_int(0,"Tankgeld");
    switch(cache_get_field_content_int(0,"Owned")){
    case 0: TankInfo[t][Owned] = false;
    case 1: TankInfo[t][Owned] = true;
    }
    if(TankInfo[t][Owned] == false){
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nPreis: %d\nTankstelle zu verkaufen!\nBenutze /tanke",t,TankInfo[t][tName],TankInfo[t][Preis]);
    TankLabel[t] = Create3DTextLabel(string,Türkis,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    else {
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nBesitzer: %s\nSpritpreis: %d\nBenutze /tanken",t,TankInfo[t][tName],TankInfo[t][oName],TankInfo[t][sPreis]);
    TankLabel[t] = Create3DTextLabel(string,Rot,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    }
    return 1;
    }



    Danke das du mir hilfst, währe nett wenn du mir eine PN schreibst wenn du bereit bist :)


    PS: Hhi Bayern hat Ferien ^^

  • Zitat

    mysql_format(mycon,query, sizeof(query), "SELECT * FROM `Tankstellen` WHERE `TankID` = '%i'",t);
    cache_get_field_content(0,"Name",TankInfo[t][tName]),cache_get_field_content(0,"oName",TankInfo[t][oName]),TankInfo[t][tX] = cache_get_field_content_float(0,"PosX");


    Meinst zwischen diesen beiden Zeilen fehlt nicht mindestens 1 Funktionsaufruf ?
    Du solltest zumindest mal dein SQL Kommando an den MySQL Server senden bevor du versuchst imaginäre Ergebnisse zu verarbeiten.

  • es Funktioniert nicht...


    habe es jetzt so



    Func LoadTanke(){
    for(new t; t<MAX_TANKE; t++){
    new query[60 + MAX_PLAYER_NAME];
    mysql_format(mycon,query, sizeof(query), "SELECT * FROM `Tankstellen` WHERE `TankID` = '%i'",t);
    mysql_tquery(mycon,query,"","");
    cache_get_field_content(0,"Name",TankInfo[t][tName]),cache_get_field_content(0,"oName",TankInfo[t][oName]),TankInfo[t][tX] = cache_get_field_content_float(0,"PosX");
    TankInfo[t][tY] = cache_get_field_content_float(0,"PosY"),TankInfo[t][tZ] = cache_get_field_content_float(0,"PosZ"),TankInfo[t][Preis] = cache_get_field_content_int(0,"Preis");
    TankInfo[t][sPreis] = cache_get_field_content_int(0,"Spritpreis"),TankInfo[t][Tankgeld] = cache_get_field_content_int(0,"Tankgeld");
    switch(cache_get_field_content_int(0,"Owned")){
    case 0: TankInfo[t][Owned] = false;
    case 1: TankInfo[t][Owned] = true;
    }
    printf("TankID: %i, Name: %s, oName: %s, Owned: %d",t,TankInfo[t][tName],TankInfo[t][oName],TankInfo[t][Owned]);
    if(TankInfo[t][Owned] == false){
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nPreis: %d\nTankstelle zu verkaufen!\nBenutze /tanke",t,TankInfo[t][tName],TankInfo[t][Preis]);
    TankLabel[t] = Create3DTextLabel(string,Türkis,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    else {
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nBesitzer: %s\nSpritpreis: %d\nBenutze /tanken",t,TankInfo[t][tName],TankInfo[t][oName],TankInfo[t][sPreis]);
    TankLabel[t] = Create3DTextLabel(string,Rot,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    }
    return 1;
    }


    serverlog sagt das:

    Spoiler anzeigen
    [15:40:27] TankID: 0, Name: , oName: , Owned: 0
    [15:40:27] TankID: 1, Name: , oName: , Owned: 0
    [15:40:27] TankID: 2, Name: , oName: , Owned: 0
    [15:40:27] TankID: 3, Name: , oName: , Owned: 0
    [15:40:27] TankID: 4, Name: , oName: , Owned: 0
    [15:40:27] TankID: 5, Name: , oName: , Owned: 0
    [15:40:27] TankID: 6, Name: , oName: , Owned: 0
    [15:40:27] TankID: 7, Name: , oName: , Owned: 0
    [15:40:27] TankID: 8, Name: , oName: , Owned: 0
    [15:40:27] TankID: 9, Name: , oName: , Owned: 0
    [15:40:27] TankID: 10, Name: , oName: , Owned: 0
    [15:40:27] TankID: 11, Name: , oName: , Owned: 0
    [15:40:27] TankID: 12, Name: , oName: , Owned: 0
    [15:40:27] TankID: 13, Name: , oName: , Owned: 0
    [15:40:27] TankID: 14, Name: , oName: , Owned: 0
    [15:40:27] TankID: 15, Name: , oName: , Owned: 0
    [15:40:27] TankID: 16, Name: , oName: , Owned: 0

  • Du benutzt so wie es aussieht eine Version > 7 von BlueG's MySQL Plugin.
    Es wird aber nur noch ausschließlich die "Threaded Methode" angeboten,weshalb dein Code nicht funktionieren kann. Schau dich mal im Tutorial Bereich dieses Forums um und such nach "mysql thread" oder schau in das Release Thema des Plugins. Dort findest du, wie diese Methode funktioniert.


    //Edit: Ich benutzt weder die Version des Plugins wie du ( benutze nur 7 ) , noch habe ich Ahnung wie seit Version 7 sich die Funktionen verändert habe etc.

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • ich hatte es mit diesem Tutorial gemacht


    [ SCRIPTING ] MySQL Registersystem [BlueG R8+ (R26)]


    ich bin anfänger in mysql, trotzdem möchte ich mein ganzes script auf mysql schreiben...
    wenn ich diesen abteil schaffe, wird der rest (haus, bizsystem) einfacher sein...
    ich bin nicht so gut in englisch, auserdem verstehe ich es nicht richtig wie er es hat
    ich habe bisher nur das oben angegebene tutorial zu dieser version gefunden

  • Bei deinem format in der 4. Zeile, es gibt kein %e im format, dass muss %i oder %d heißen ^^


    mfg. :thumbup:


    Er benutzt mysql_format, dort gibt es %e.



    [...]
    ich habe mysql_log(1); in OnGameModeInit aber es ist nirgens ein logfile


    :cursing::cursing::cursing:
    mysql_log != mysql_debug!!!!!
    Benutze entweder

    Code
    mysql_log(); //loggt Warnungen und Errors

    oder

    Code
    mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); //loggt Warnungen, Errors und Debug-Nachrichten



    Hier ist der korrekte Code, die Kommentare sollten dir etwas helfen es zu verstehen:

    public OnGameModeInit()
    {
    //...
    mysql_tquery(mycon, "SELECT * FROM `Tankstellen`", "LoadTanke", ""); //sendet die Query, diese wählt alle Daten aus der Tabelle und ruft dann "LoadTanke" mit dem Ergebnis auf
    //...
    return 1;
    }


    forward LoadTanke();
    public LoadTanke() {
    new Rows = cache_num_rows(mycon); //Anzahl der Tankstellen bzw. Zeilen in der Tabelle
    for(new t; t < Rows; t++) { //hier gehen wir durch jede Zeile durch
    cache_get_field_content(t,"Name", TankInfo[t][tName], mycon, 64);
    cache_get_field_content(t,"oName", TankInfo[t][oName], mycon, 64);
    TankInfo[t][tX] = cache_get_field_content_float(t, "PosX");
    TankInfo[t][tY] = cache_get_field_content_float(t, "PosY");
    TankInfo[t][tZ] = cache_get_field_content_float(t, "PosZ");
    TankInfo[t][Preis] = cache_get_field_content_int(t, "Preis");
    TankInfo[t][sPreis] = cache_get_field_content_int(t, "Spritpreis");
    TankInfo[t][Tankgeld] = cache_get_field_content_int(t, "Tankgeld");
    /*switch(cache_get_field_content_int(t, "Owned")){
    case 0: TankInfo[t][Owned] = false;
    case 1: TankInfo[t][Owned] = true;
    }*/
    //das kann man wie folgt schreiben:
    TankInfo[t][Owned] = (cache_get_field_content_int(t, "Owned") == 1); //wenn "Owned" (aus der Tabelle) gleich 1, dann TankInfo[t][Owned] == true, ansonsten false
    if(TankInfo[t][Owned] == false) {
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nPreis: %d\nTankstelle zu verkaufen!\nBenutze /tanke",t,TankInfo[t][tName],TankInfo[t][Preis]);
    TankLabel[t] = Create3DTextLabel(string,Türkis,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    else {
    new string[128];
    format(string,sizeof(string),"[Tankstellen ID: %d]\nName: %s\nBesitzer: %s\nSpritpreis: %d\nBenutze /tanken",t,TankInfo[t][tName],TankInfo[t][oName],TankInfo[t][sPreis]);
    TankLabel[t] = Create3DTextLabel(string,Rot,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],10,0);
    AddStaticPickup(1272,2,TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],0);
    }
    }
    return 1;
    }


  • super, danke
    aber nun werden sie nicht gespeichert...


    Speichercode:

    Func SaveTanke(){
    for(new t; t<MAX_TANKE; t++){
    new query[500 + MAX_PLAYER_NAME];
    mysql_format(mycon,query, sizeof(query), "UPDATE `Tankstellen` SET `Name` = '%e', `Owned` = %d, `oName` = '%e', `PosX` = '%f', `PosY` = '%f', `PosZ` = '%f', `Preis` = '%d', `Spritpreis` = '%d' `Tankgeld` = '%d' WHERE `TankID` = '%i'",
    TankInfo[t][tName],TankInfo[t][Owned],TankInfo[t][oName],TankInfo[t][tX],TankInfo[t][tY],TankInfo[t][tZ],TankInfo[t][Preis],TankInfo[t][sPreis],TankInfo[t][Tankgeld],t);
    mysql_tquery(mycon,query,"","");
    }
    return 1;
    }


    und bei



    new Rows = cache_num_rows(mycon);
    for(new t; t < Rows; t++) {


    kommt ein error
    error 017: undefined symbol "cache_num_rows"


    ich hoffe du hilfst mir nochmal :)

  • Dein erstes Problem:
    stock SaveTanke()
    {
    for(new t; t<MAX_TANKE; t++) {
    new query[500/* + MAX_PLAYER_NAME*/]; //die 24 Zeichen kannst du dir auch sparen
    mysql_format(mycon, query, sizeof(query), "UPDATE `Tankstellen` SET `Name` = '%e', `Owned` = %d, `oName` = '%e', `PosX` = '%f', `PosY` = '%f', `PosZ` = '%f', `Preis` = '%d', `Spritpreis` = '%d' `Tankgeld` = '%d' WHERE `TankID` = '%i'",
    TankInfo[t][tName],
    TankInfo[t][Owned],
    TankInfo[t][oName],
    TankInfo[t][tX], TankInfo[t][tY], TankInfo[t][tZ],
    TankInfo[t][Preis], TankInfo[t][sPreis],
    TankInfo[t][Tankgeld],
    t //du kannst hier nicht einfach "t" hinklatschen, jede Zeile in der Tabelle hat
    //ihren eigenen Index. Du musst vorher in "LoadTanke" das "ID"-Feld aus der
    //Tabelle in eine Variable, wie z.B. "TankInfo[t][ID]" speichern und diese hier
    //anstelle von diesem "t" benutzen
    );
    mysql_tquery(mycon, query, "", "");
    }
    return 1;
    }


    Dein zweites Problem:
    cache_num_rows gibt es erst seit R33. Entweder du upgradest auf R33 oder du erstetzt new Rows = cache_num_rows(mycon); mit
    new Rows, Fields;
    cache_get_data(Rows, Fields, mycon);

  • //du kannst hier nicht einfach "t" hinklatschen, jede Zeile in der Tabelle hat
    //ihren eigenen Index. Du musst vorher in "LoadTanke" das "ID"-Feld aus der
    //Tabelle in eine Variable, wie z.B. "TankInfo[t][ID]" speichern und diese hier
    //anstelle von diesem "t" benutzen


    und wie soll ich das dann machen?
    beim laden mache ich es ja auch mit t und es funktioniert, oder?