Haussystem klappt nit

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


    Ich hab mir gestern Abend ein Haussystem zusammengestellt, und dieses grad getestet.
    Leider musste Ich feststellen, dass das Haus nicht geladen wird.
    Hier ist alles, was zum Haussystem gehört:

    Peter PAWN Code
    #define MAX_HAEUSER 25
    enum HausDaten
    {
    hID,
    Float:hPosX,
    Float:hPosY,
    Float:hPosZ,
    hPickup,
    Text3D:hLabel,
    hBesitzer[24],
    hPreis,
    hLevel,
    hBought
    }
    new HausInfo[MAX_HAEUSER][HausDaten];

    Peter PAWN Code
    stock CreateHouse(Float:X,Float:Y,Float:Z,Level,Price)
    {
    for(new i=1;i<MAX_HAEUSER;i++)
    {
    new query[1024];
    format(query,sizeof(query),"INSERT INTO `haeuser` (`PosX`, `PosY`, `PosZ`, `Level`, `Preis`, `Besitzer`, `Bought`) VALUES ('%f', '%f', '%f', '%d', '%d', 'Niemand', '0')",X,Y,Z,Level,Price);
    mysql_query(query);
    return LoadHouse(i);
    }
    return 1;
    }

    Peter PAWN Code
    stock LoadHouse(HouseID)
    {
    new str[128];
    HausInfo[HouseID][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[HouseID][hID]);
    format(HausInfo[HouseID][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]));
    HausInfo[HouseID][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPickup] = CreatePickup(1239,1,HausInfo[HouseID][hPosZ],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],0);
    if(HausInfo[HouseID][hBought] == 0)
    {
    format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[HouseID][hLevel],HausInfo[HouseID][hPreis]);
    }
    else
    {
    format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[HouseID][hBesitzer]);
    }
    HausInfo[HouseID][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[HouseID][hPosX],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],7,0);
    return 1;
    }

    Peter PAWN Code
    stock LoadAllHouses()
    {
    for(new i=1;i<MAX_HAEUSER;i++)
    {
    new str[128];
    HausInfo[i][hID] = GetMySQLint("haeuser", "ID", "ID", HausInfo[i][hID]);
    HausInfo[i][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[i][hID]);
    HausInfo[i][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[i][hID]);
    HausInfo[i][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[i][hID]);
    HausInfo[i][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[i][hID]);
    HausInfo[i][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[i][hID]);
    format(HausInfo[i][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[i][hID]));
    HausInfo[i][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[i][hID]);
    HausInfo[i][hPickup] = CreatePickup(1239,1,HausInfo[i][hPosZ],HausInfo[i][hPosY],HausInfo[i][hPosZ],0);
    if(HausInfo[i][hBought] == 0)
    {
    format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[i][hLevel],HausInfo[i][hPreis]);
    }
    else
    {
    format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[i][hBesitzer]);
    }
    HausInfo[i][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[i][hPosX],HausInfo[i][hPosY],HausInfo[i][hPosZ],7,0);
    }
    return 1;
    }

    Peter PAWN Code
    stock SaveHouse(HouseID)
    {
    SetMySQLfloat("haeuser", "PosX", HausInfo[HouseID][hPosX], "ID", HausInfo[HouseID][hID]);
    SetMySQLfloat("haeuser", "PosY", HausInfo[HouseID][hPosY], "ID", HausInfo[HouseID][hID]);
    SetMySQLfloat("haeuser", "PosZ", HausInfo[HouseID][hPosZ], "ID", HausInfo[HouseID][hID]);
    SetMySQLint("haeuser", "Level", HausInfo[HouseID][hLevel], "ID", HausInfo[HouseID][hID]);
    SetMySQLint("haeuser", "Preis", HausInfo[HouseID][hPreis], "ID", HausInfo[HouseID][hID]);
    SetMySQLstring("haeuser", "Besitzer", HausInfo[HouseID][hBesitzer], "ID", HausInfo[HouseID][hID]);
    SetMySQLint("haeuser", "Bought", HausInfo[HouseID][hBought], "ID", HausInfo[HouseID][hID]);
    return 1;
    }

    Peter PAWN Code
    stock SaveAllHouse()
    {
    for(new i=1;i<MAX_HAEUSER;i++)
    {
    SetMySQLfloat("haeuser", "PosX", HausInfo[HouseID][hPosX], "ID", HausInfo[i][hID]);
    SetMySQLfloat("haeuser", "PosY", HausInfo[HouseID][hPosY], "ID", HausInfo[i][hID]);
    SetMySQLfloat("haeuser", "PosZ", HausInfo[HouseID][hPosZ], "ID", HausInfo[i][hID]);
    SetMySQLint("haeuser", "Level", HausInfo[HouseID][hLevel], "ID", HausInfo[i][hID]);
    SetMySQLint("haeuser", "Preis", HausInfo[HouseID][hPrice], "ID", HausInfo[i][hID]);
    SetMySQLstring("haeuser", "Besitzer", HausInfo[HouseID][hBesitzer], "ID", HausInfo[i][hID]);
    SetMySQLint("haeuser", "Bought", HausInfo[HouseID][hBought], "ID", HausInfo[i][hID]);
    }
    return 1;
    }

    Peter PAWN Code
    stock KillHouse(HouseID)
    {
    SaveHouse(HouseID);
    DestroyPickup(HausInfo[HouseID][hPickup]);
    Delete3DTextLabel(HausInfo[HouseID][hLabel]);
    return 1;
    }

    Peter PAWN Code
    ocmd:buyhouse(playerid,params[])
    {
    if(!isPlayerAFK(playerid))
    {
    if(SpielerInfo[playerid][pHaus] == 0)
    {
    for(new i=1;i<MAX_HAEUSER;i++)
    {
    if(IsPlayerInRangeOfPoint(playerid,3,HausInfo[i][hPosX],HausInfo[i][hPosY],HausInfo[i][hPosZ]))
    {
    if(HausInfo[i][hBought] == 1)return SCM(playerid,COLOR_LIGHTRED,"Dieses Haus ist nicht zu verkaufen!");
    if(HausInfo[i][hBought] == 0)
    {
    if(SpielerInfo[playerid][pLevel] < HausInfo[i][hLevel])return SCM(playerid,COLOR_LIGHTRED,"Dein Level reicht nicht aus, um dieses Haus zu kaufen!");
    if(SpielerInfo[playerid][pGeld] < HausInfo[i][hPreis])return SCM(playerid,COLOR_LIGHTRED,"Dein Geld reicht nicht aus, um dieses Haus zu kaufen!");
    if(strcmp(HausInfo[i][hBesitzer],"Niemand",true))
    format(HausInfo[i][hBesitzer],24,"%s",PlayerName(playerid));
    HausInfo[i][hBought] = 1;
    SpielerInfo[playerid][pGeld] -= HausInfo[i][hPreis];
    SpielerInfo[playerid][pHaus] = 1;
    SpielerInfo[playerid][pHausKey] = i;
    SavePlayer(playerid);
    KillHouse(i);
    LoadHouse(i);
    SCM(playerid,COLOR_LIGHTGREEN,"Du hast dir das Haus erfolgreich gekauft!");
    return 1;
    }
    }
    }
    }
    else
    {
    SCM(playerid,COLOR_LIGHTRED,"Du besitzt bereits ein Haus!");
    }
    }
    return 1;
    }

    Peter PAWN Code
    ocmd:createhouse(playerid,params[])
    {
    if(!isPlayerAFK(playerid))
    {
    new p,l;
    if(sscanf(params,"ii",p,l))return SCM(playerid,COLOR_GREY,"Benutze: /createhouse [Preis] [Level]");
    {
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    CreateHouse(X,Y,Z,l,p);
    SCM(playerid,COLOR_LIGHTGREEN,"Du hast das Haus erfolgreich erstellt!");
    }
    }
    return 1;
    }


    Ich bekomme die msg, dass ein Haus ertellt wird, ebenso, wird alles in die Datenbank eingetragen.
    Nur geladen wird es nicht...


    lg

  • OK, habs nun so:
    stock LoadHouse(HouseID)
    {
    new str[128];
    HausInfo[HouseID][hID] = GetMySQLint("haeuser", "ID", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[HouseID][hID]);
    format(HausInfo[HouseID][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]));
    HausInfo[HouseID][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[HouseID][hID]);
    HausInfo[HouseID][hPickup] = CreatePickup(1239,1,HausInfo[HouseID][hPosZ],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],0);
    if(HausInfo[HouseID][hBought] == 0)
    {
    format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[HouseID][hLevel],HausInfo[HouseID][hPreis]);
    }
    else
    {
    format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[HouseID][hBesitzer]);
    }
    HausInfo[HouseID][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[HouseID][hPosX],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],7,0);
    return 1;
    }


    auszug der log:

  • kann es sein das du den intger als string sendest?
    WHERE Id = %s
    oder
    WHERE Id = %d


    stock GetMySQLint(Table[], Field[], Where[], Is[])
    {
    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);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    new sqlint = mysql_fetch_int();
    mysql_free_result();
    return sqlint;
    }


    dafuq, das is von maddin wtf

  • Intger != string das solltest du eig gesehen haben
    stock LoadHouse(HouseID)
    {
    new str[128];
    format(str,12,"%d",HouseID);
    HausInfo[HouseID][hID] = GetMySQLint("haeuser", "ID", "ID", str);
    HausInfo[HouseID][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", str);
    HausInfo[HouseID][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", str);
    HausInfo[HouseID][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", str);
    HausInfo[HouseID][hLevel] = GetMySQLint("haeuser", "Level", "ID", str);
    HausInfo[HouseID][hPreis] = GetMySQLint("haeuser", "Preis", "ID", str);
    format(HausInfo[HouseID][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", str));
    HausInfo[HouseID][hBought] = GetMySQLint("haeuser", "Bought", "ID", str);
    HausInfo[HouseID][hPickup] = CreatePickup(1239,1,HausInfo[HouseID][hPosZ],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],0);
    if(HausInfo[HouseID][hBought] == 0)
    {
    format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[HouseID][hLevel],HausInfo[HouseID][hPreis]);
    }
    else
    {
    format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[HouseID][hBesitzer]);
    }
    HausInfo[HouseID][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[HouseID][hPosX],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],7,0);
    return 1;
    }
    //e
    Hab dir es mal verbessert so sollte es gehen

    All in all it's just another brick in the wall


  • Des klappt nicht... InGame ist kein Pickup, ich kann kein /buyhouse machen NIX!


    Hier die Log:

    Code
    [12:33:21] CMySQLHandler::Query(SELECT `Bought` FROM `haeuser` WHERE `ID` = '24') - Successfully executed.
    [12:33:21] >> mysql_store_result( Connection handle: 1 )
    [12:33:21] CMySQLHandler::StoreResult() - Result was stored.
    [12:33:21] >> mysql_fetch_int( Connection handle: 1 )
    [12:33:21] >> mysql_free_result( Connection handle: 1 )
    [12:33:21] CMySQLHandler::FreeResult() - Result was successfully free'd.


    24? Es gibt nur 1 Hau, aber das wird nicht geladen...


    Was is da looos?!


    /e MySQL-Log
    /e² MySQL Log in CODE eingefügt