Problem mit Haus- & Bizsystem seit Umstellung auf MySQL R39-3

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
  • Hi,


    wie im Threadtitel beschrieben habe ich seit der Umstellung von MySQL R5 auf R39-3 einige Probleme mit meinem Haus-& Bizsystem.
    Die Daten werden zwar in die Tabelle geschrieben, doch nicht geladen.
    Dazu hier mein Code:



    case QuerySelectAllBiz:
    {
    cache_get_data(rows,fields);
    if(rows > MAX_BIZ) return 0;
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    //schreibt in Tabelle
    format(q,sizeof q,"SELECT * FROM `biz` WHERE `ID` = '%d'",rows);
    mysql_pquery(dbHandle, q, "OnQueryFinish", "sdd", q, QueryCallLoadBiz, playerid);
    }
    case QuerySelectAllHouse:
    {
    cache_get_data(rows,fields);
    if(rows > MAX_HAEUSER) return 0;
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    //schreibtr in Tabelle
    format(str,sizeof str,"SELECT * FROM `haeuser` WHERE `ID` = '%d'",rows);
    mysql_pquery(dbHandle, str, "OnQueryFinish", "sdd", str, QueryCallLoadHouse, playerid);
    }


    Hier der Code wo das ganze geladen wird:
    case QueryCallLoadHouse:
    {
    cache_get_data(rows,fields);
    if(rows > 0) {
    new ho;
    for(;ho<rows;ho++) {
    //if(ho==0){ho++;}
    cache_get_field_content(ho,"ID",result);
    HausInfo[ho][hID] = strval(result);
    cache_get_field_content(ho,"PosX",result);
    HausInfo[ho][hPosX] = floatstr(result);
    cache_get_field_content(ho,"PosY",result);
    HausInfo[ho][hPosY] = floatstr(result);
    cache_get_field_content(ho,"PosZ",result);
    HausInfo[ho][hPosZ] = floatstr(result);
    cache_get_field_content(ho,"Level",result);
    HausInfo[ho][hLevel] = strval(result);
    cache_get_field_content(ho,"Preis",result);
    HausInfo[ho][hPreis] = strval(result);
    cache_get_field_content(ho,"Besitzer",result);
    format(HausInfo[ho][hBesitzer],24,"%s",result);
    cache_get_field_content(ho,"Bought",result);
    HausInfo[ho][hBought] = strval(result);
    cache_get_field_content(ho,"Rooms",result);
    HausInfo[ho][hRooms] = strval(result);
    cache_get_field_content(ho,"InteriorID",result);
    HausInfo[ho][hInteriorID] = strval(result);
    cache_get_field_content(ho,"Interior",result);
    HausInfo[ho][hInterior] = strval(result);
    cache_get_field_content(ho,"IntX",result);
    HausInfo[ho][hIntX] = floatstr(result);
    cache_get_field_content(ho,"IntY",result);
    HausInfo[ho][hIntY] = floatstr(result);
    cache_get_field_content(ho,"IntZ",result);
    HausInfo[ho][hIntZ] = floatstr(result);
    cache_get_field_content(ho,"Locked",result);
    HausInfo[ho][hLocked] = strval(result);
    cache_get_field_content(ho,"Rentable",result);
    HausInfo[ho][hRentable] = strval(result);
    cache_get_field_content(ho,"RentPrice",result);
    HausInfo[ho][hRentPrice] = strval(result);
    cache_get_field_content(ho,"Renter1",result);
    format(HausInfo[ho][hRenter1],24,"%s",result);
    cache_get_field_content(ho,"Renter2",result);
    format(HausInfo[ho][hRenter2],24,"%s",result);
    cache_get_field_content(ho,"Renter3",result);
    format(HausInfo[ho][hRenter3],24,"%s",result);
    cache_get_field_content(ho,"Renter4",result);
    format(HausInfo[ho][hRenter4],24,"%s",result);
    cache_get_field_content(ho,"Renter5",result);
    format(HausInfo[ho][hRenter5],24,"%s",result);
    cache_get_field_content(ho,"Renter6",result);
    format(HausInfo[ho][hRenter6],24,"%s",result);
    HausInfo[ho][hVW] = HausInfo[ho][hID]+1;
    HausInfo[ho][hOutPickup] = CreatePickup(1318,1,HausInfo[ho][hIntX],HausInfo[ho][hIntY],HausInfo[ho][hIntZ],HausInfo[ho][hVW]);
    //Label und son mist erstellen
    HausInfo[ho][hCreated]=true;
    }
    }
    }
    case QueryCallLoadBiz:
    {
    cache_get_data(rows,fields);
    if(rows > 0) {
    new bi;
    for(;bi<rows;bi++) {
    //if(bi==0){bi++;}
    cache_get_field_content(bi,"ID",result);
    BizInfo[bi][bID] = strval(result);
    cache_get_field_content(bi,"PosX",result);
    BizInfo[bi][bPosX] = floatstr(result);
    cache_get_field_content(bi,"PosY",result);
    BizInfo[bi][bPosY] = floatstr(result);
    cache_get_field_content(bi,"PosZ",result);
    BizInfo[bi][bPosZ] = floatstr(result);
    cache_get_field_content(bi,"Level",result);
    BizInfo[bi][bLevel] = strval(result);
    cache_get_field_content(bi,"Preis",result);
    BizInfo[bi][bPreis] = strval(result);
    cache_get_field_content(bi,"Besitzer",result);
    format(BizInfo[bi][bID],24,"%s",result);
    cache_get_field_content(bi,"Bought",result);
    BizInfo[bi][bBought] = strval(result);
    cache_get_field_content(bi,"Typ",result);
    format(BizInfo[bi][bTyp],32,"%s",result);
    cache_get_field_content(bi,"Produkte",result);
    BizInfo[bi][bProds] = strval(result);
    cache_get_field_content(bi,"ProdukteBestellt",result);
    BizInfo[bi][bProdsBestellt] = strval(result);
    cache_get_field_content(bi,"InteriorID",result);
    BizInfo[bi][bInteriorID] = strval(result);
    cache_get_field_content(bi,"Interior",result);
    BizInfo[bi][bInterior] = strval(result);
    cache_get_field_content(bi,"IntX",result);
    BizInfo[bi][bIntX] = floatstr(result);
    cache_get_field_content(bi,"IntY",result);
    BizInfo[bi][bIntY] = floatstr(result);
    cache_get_field_content(bi,"IntZ",result);
    BizInfo[bi][bIntZ] = floatstr(result);
    cache_get_field_content(bi,"Locked",result);
    BizInfo[bi][bLocked] = strval(result);
    cache_get_field_content(bi,"Kasse",result);
    BizInfo[bi][bKasse] = strval(result);
    cache_get_field_content(bi,"Name",result);
    format(BizInfo[bi][bName],64,"%s",result);
    cache_get_field_content(bi,"Price",result);
    BizInfo[bi][bPrice] = strval(result);
    cache_get_field_content(bi,"MaxProdukte",result);
    BizInfo[bi][bMaxProds] = strval(result);
    BizInfo[bi][bVW] = bi+1;
    BizInfo[bi][bOutPickup] = CreatePickup(1318,1,BizInfo[bi][bIntX],BizInfo[bi][bIntY],BizInfo[bi][bIntZ],BizInfo[bi][bVW]);
    //Label und son mist erstellen
    BizInfo[bi][bLabel]=Create3DTextLabel(str,COLOR_AO,BizInfo[bi][bPosX],BizInfo[bi][bPosY],BizInfo[bi][bPosZ],13,0,1);
    BizInfo[bi][bOutLabel]=Create3DTextLabel("Verlassen:\n~k~~VEHICLE_ENTER_EXIT~ drücken",COLOR_RED,BizInfo[bi][bIntX],BizInfo[bi][bIntY],BizInfo[bi][bIntZ],7,BizInfo[bi][bVW],1);
    BizInfo[bi][bCreated]=true;
    }
    }
    }


    Warum klappt das nicht?


    lg
    Deagle
    Jeffry:

  • Wie rufst du denn diese beiden auf?
    case QuerySelectAllBiz:
    case QuerySelectAllHouse:


    ocmd:createbiz(playerid,params[])
    {
    if(!IsPlayerAdmin(playerid))return 1;
    new p,int,typ[32],name[64];
    if(sscanf(params,"iis[32]s[64]",p,int,typ,name))return SendClientMessage(playerid,COLOR_GREY,"Benutze: /createbiz [Preis] [Interior] [Typ] [Name] | Interiorliste: /bints");
    if(int <= 5) {
    mysql_pquery(dbHandle,"SELECT * FROM `biz`","OnQueryFinish","sdddsds","SELECT * FROM `biz`",QuerySelectAllBiz,playerid,p,name,int,typ);
    SendClientMessage(playerid,COLOR_LIGHTGREEN,"Du hast das Biz erfolgreich erstellt!");
    } else {
    SendClientMessage(playerid,COLOR_LIGHTRED,"Die InteriorID eines Biz' darf nicht größer als 5 sein!");
    }
    return 1;
    }


    ocmd:createhouse(playerid,params[])
    {
    if(IsPlayerAdmin(playerid)) {
    new p,r,int;
    if(sscanf(params,"iii",p,r,int))return SendClientMessage(playerid,COLOR_GREY,"Benutze: /createhouse [Preis] [Zimmer (max. 6)] [Interior ID (Liste: /hints)]");
    {
    if(r <= 6) {
    if(int <= 10) {
    new st[16];
    format(st,sizeof st,"%d",r);
    mysql_pquery(dbHandle,"SELECT * FROM `haeuser`","OnQueryFinish","sdddsd","SELECT * FROM `haeuser`",QuerySelectAllHouse,playerid,p,st,int);
    SendClientMessage(playerid,COLOR_LIGHTGREEN,"Du hast das Haus erfolgreich erstellt!");
    } else {
    SendClientMessage(playerid,COLOR_LIGHTRED,"Die InteriorID eines Hauses darf nicht größer als 10 sein!");
    }
    } else {
    SendClientMessage(playerid,COLOR_LIGHTRED,"Die Zimmer eines Hauses dürfen nicht mehr als 6 sein!");
    }
    }
    }
    return 1;
    }

  • Ok. Dann mach das hier komplett weg:
    case QuerySelectAllBiz:
    {
    cache_get_data(rows,fields);
    if(rows > MAX_BIZ) return 0;
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    //schreibt in Tabelle
    format(q,sizeof q,"SELECT * FROM `biz` WHERE `ID` = '%d'",rows);
    mysql_pquery(dbHandle, q, "OnQueryFinish", "sdd", q, QueryCallLoadBiz, playerid);
    }
    case QuerySelectAllHouse:
    {
    cache_get_data(rows,fields);
    if(rows > MAX_HAEUSER) return 0;
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    //schreibtr in Tabelle
    format(str,sizeof str,"SELECT * FROM `haeuser` WHERE `ID` = '%d'",rows);
    mysql_pquery(dbHandle, str, "OnQueryFinish", "sdd", str, QueryCallLoadHouse, playerid);
    }
    (Löschen)


    Und schreibe in den beiden anderen Queries (in den beiden Befehlen) diese cases anstelle rein:
    case QueryCallLoadHouse:
    case QueryCallLoadBiz:
    Im mysql_pquery.

  • Achso, ich dachte du willst die erst damit laden.
    Naja, dann ist der Befehl sowieso falsch. Wenn du etwas erstellen willst, also der Datenbank hinzufügen, musst du INSERT INTO verwenden. Das hat sich von R5 auf R39-3 auch nicht geändert, außer dass du eben mysql_pquery anstatt mysql_query verwendest. Ein Callback muss ja bei einem INSERT nicht zwangsläufig aufgerufen werden (außer du willst die ID in der Datenbank auslesen).


    Die SELECTs aus den Befehlen müssen dort hin wo du die Häuser laden lassen willst. Dort wo du eines erstellst, musst du mit INSERT INTO arbeiten.

  • Ja kannst du, solltest du aber nicht. Du kannst auch mit mysql_pquery einen INSERT senden, ohne ein Callback aufzurufen.


    Also nochmal kurz:
    /createXXX -> INSERT INTO
    Etwas Laden -> SELECT FROM



    Du hast beim /createXXX einen SELECT, und das ist falsch. Der SELECT muss bei OnGameModeInit hin.

  • Du kannst ja die Werte die du über sscanf eingibst direkt in die Variablen schreiben, du musst es nicht aus der Datenbank laden, was du zuvor eingetragen hast.


    Das stimmt schon.


    Allerdings lädt das seit dem SQL-Update auch nicht mehr alle Fraktionen, er lädt nur 2.
    Siehe:

    Code
    [17:30:51] <-| [MYSQL-LOAD] Die Fraktion 0 wurde erfolgreich geladen - Dauer: 0ms
    [17:30:51] <-| [MYSQL-LOAD] Die Fraktion 1 wurde erfolgreich geladen - Dauer: 0ms


    mysql_pquery(dbHandle,"SELECT * FROM `Frak`","OnQueryFinish","sd","SELECT * FROM `Frak`",QueryCallFrak);


    case QueryCallFrak:
    {
    cache_get_data(rows,fields);
    new fr;
    for(;fr<rows;fr++) {
    //if(fr==0){fr++;}
    cache_get_field_content(fr,"ID",result);
    FrakInfo[fr][fID] = strval(result);
    cache_get_field_content(fr,"Kasse",result);
    FrakInfo[fr][fKasse] = strval(result);
    cache_get_field_content(fr,"Marihuana",result);
    FrakInfo[fr][fMarihuana] = strval(result);
    cache_get_field_content(fr,"Mats",result);
    FrakInfo[fr][fMats] = strval(result);
    cache_get_field_content(fr,"Gangwaffen",result);
    FrakInfo[fr][fGangwaffen] = strval(result);
    cache_get_field_content(fr,"Rank1lohn",result);
    FrakInfo[fr][fR1L] = strval(result);
    cache_get_field_content(fr,"Rank2lohn",result);
    FrakInfo[fr][fR2L] = strval(result);
    cache_get_field_content(fr,"Rank3lohn",result);
    FrakInfo[fr][fR3L] = strval(result);
    cache_get_field_content(fr,"Rank4lohn",result);
    FrakInfo[fr][fR4L] = strval(result);
    cache_get_field_content(fr,"Rank5lohn",result);
    FrakInfo[fr][fR5L] = strval(result);
    cache_get_field_content(fr,"Rank6lohn",result);
    FrakInfo[fr][fR6L] = strval(result);
    cache_get_field_content(fr,"Rank7lohn",result);
    FrakInfo[fr][fR7L] = strval(result);
    cache_get_field_content(fr,"Rank8lohn",result);
    FrakInfo[fr][fR8L] = strval(result);
    cache_get_field_content(fr,"LagerOpen",result);
    FrakInfo[fr][fWLO] = strval(result);
    cache_get_field_content(fr,"Rank1name",result);
    format(FrakInfo[fr][fR1N],24,"%s",result);
    cache_get_field_content(fr,"Rank2name",result);
    format(FrakInfo[fr][fR2N],24,"%s",result);
    cache_get_field_content(fr,"Rank3name",result);
    format(FrakInfo[fr][fR3N],24,"%s",result);
    cache_get_field_content(fr,"Rank4name",result);
    format(FrakInfo[fr][fR4N],24,"%s",result);
    cache_get_field_content(fr,"Rank5name",result);
    format(FrakInfo[fr][fR5N],24,"%s",result);
    cache_get_field_content(fr,"Rank6name",result);
    format(FrakInfo[fr][fR6N],24,"%s",result);
    cache_get_field_content(fr,"Rank7name",result);
    format(FrakInfo[fr][fR7N],24,"%s",result);
    cache_get_field_content(fr,"Rank8name",result);
    format(FrakInfo[fr][fR8N],24,"%s",result);
    cache_get_field_content(fr,"Rank1skin",result);
    FrakInfo[fr][fR1S] = strval(result);
    cache_get_field_content(fr,"Rank2skin",result);
    FrakInfo[fr][fR2S] = strval(result);
    cache_get_field_content(fr,"Rank3skin",result);
    FrakInfo[fr][fR3S] = strval(result);
    cache_get_field_content(fr,"Rank4skin",result);
    FrakInfo[fr][fR4S] = strval(result);
    cache_get_field_content(fr,"Rank5skin",result);
    FrakInfo[fr][fR5S] = strval(result);
    cache_get_field_content(fr,"Rank6skin",result);
    FrakInfo[fr][fR6S] = strval(result);
    cache_get_field_content(fr,"Rank7skin",result);
    FrakInfo[fr][fR7S] = strval(result);
    cache_get_field_content(fr,"Rank8skin",result);
    FrakInfo[fr][fR8S] = strval(result);
    cache_get_field_content(fr,"WLX",result);
    FrakInfo[fr][fWLX] = floatstr(result);
    cache_get_field_content(fr,"WLY",result);
    FrakInfo[fr][fWLY] = floatstr(result);
    cache_get_field_content(fr,"WLZ",result);
    FrakInfo[fr][fWLZ] = floatstr(result);
    cache_get_field_content(fr,"PosX",result);
    FrakInfo[fr][fPosX] = floatstr(result);
    cache_get_field_content(fr,"PosY",result);
    FrakInfo[fr][fPosY] = floatstr(result);
    cache_get_field_content(fr,"PosZ",result);
    FrakInfo[fr][fPosZ] = floatstr(result);
    cache_get_field_content(fr,"IntX",result);
    FrakInfo[fr][fIntX] = floatstr(result);
    cache_get_field_content(fr,"IntY",result);
    FrakInfo[fr][fIntY] = floatstr(result);
    cache_get_field_content(fr,"IntZ",result);
    FrakInfo[fr][fIntZ] = floatstr(result);
    cache_get_field_content(fr,"Interior",result);
    FrakInfo[fr][fInterior] = strval(result);
    cache_get_field_content(fr,"VW",result);
    FrakInfo[fr][fVW] = strval(result);
    cache_get_field_content(fr,"SpawnX",result);
    FrakInfo[fr][fSpawnX] = floatstr(result);
    cache_get_field_content(fr,"SpawnY",result);
    FrakInfo[fr][fSpawnY] = floatstr(result);
    cache_get_field_content(fr,"SpawnZ",result);
    FrakInfo[fr][fSpawnZ] = floatstr(result);
    cache_get_field_content(fr,"SpawnA",result);
    FrakInfo[fr][fSpawnA] = floatstr(result);
    cache_get_field_content(fr,"Kokain",result);
    FrakInfo[fr][fKokain] = strval(result);
    cache_get_field_content(fr,"Carslots",result);
    FrakInfo[fr][fCarslots] = strval(result);
    FrakInfo[fr][fGWP] = CreateDynamicPickup(1239,1,FrakInfo[fr][fWLiX],FrakInfo[fr][fWLiY],FrakInfo[fr][fWLiZ],FrakInfo[fr][fVW]);
    FrakInfo[fr][fEntPickup] = CreateDynamicPickup(1318,1,FrakInfo[fr][fPosX],FrakInfo[fr][fPosY],FrakInfo[fr][fPosZ]);
    FrakInfo[fr][fExtPickup] = CreateDynamicPickup(1318,1,FrakInfo[fr][fIntX],FrakInfo[fr][fIntY],FrakInfo[fr][fIntZ],FrakInfo[fr][fVW]);
    SetTimerEx("LoadFrakVeh",500,0,"d",fr);
    }
    printf("<-| [MYSQL-LOAD] Die Fraktion %d wurde erfolgreich geladen - Dauer: %dms",fr,oldtime-GetTickCount());
    }
    }


    Auch mein Skinsystem buggt...
    Irgendwie hab ich entweder falsch gescriptet, oder die R39-3 braucht ein paar Sekunden um alle Querys auszuführen und die Daten zu "getten"...


    /edit: Jeffry:

  • Lass dir hier mal die Anzahl der Zeilen ausgeben, die selektiert worden sind:
    cache_get_data(rows,fields);
    zu:
    cache_get_data(rows,fields);
    printf("rows: %d max: %d", rows, sizeof(FrakInfo));


    Und poste dazu bitte einen Screenshot aus der Datenbank mit den Daten die du selektierst.