Haus System Fehler

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 Tag liebe Leute,
    Ich habe das Problem, das wenn ich ein Haus per Befehl erstellen möchte, dies auch teils funktioniert er mir dann aber ~10 Einträge von verschieden Häusern in die Datenbank knallt.

    Befehl zum Erstellen:

    ocmd:hcreate(playerid,params[])
    {
    if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    new inter,price;
    if(sscanf(params,"ii",inter,price))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}Use /hcreate [Interior ID] [BuyPrice]"),
    SendClientMessage(playerid,Grau,"[Types]: 1: Apartment, 2: House, 3: Villa");
    if(!InteriorInfo[inter][int_ID])return SendClientMessage(playerid,Rot,"Error: {FFFFFF}This isn't a Valid Interior. Use /validint to see what Interiors are Valid.");
    for(new i=0;i<MAX_HOUSES;i++)
    {
    if(strlen(HouseInfo[i][h_owner]))continue;
    {
    new query[512];
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    HouseInfo[i][h_enterX] = pos[0];
    HouseInfo[i][h_enterY] = pos[1];
    HouseInfo[i][h_enterZ] = pos[2];
    HouseInfo[i][h_exitX] = InteriorInfo[i][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[i][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[i][int_exitZ];
    HouseInfo[i][h_int] = inter;
    format(query,sizeof(query),"INSERT INTO Houses (id,Owner,EnterPosX,EnterPosY,EnterPosZ,ExitPosX,ExitPosY,ExitPosZ,Interior) VALUES ('%i','%s','%f','%f','%f','%f','%f','%f','%i')",
    i,HouseInfo[i][h_owner],HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],HouseInfo[i][h_exitX],HouseInfo[i][h_exitY],HouseInfo[i][h_exitZ],HouseInfo[i][h_int]);
    mysql_pquery(Handle,query);
    HouseInfo[i][h_vw] = cache_get_field_content_int(i,"VirtualWorld");
    HouseInfo[i][h_buyprice] = price;
    HouseInfo[i][h_rentprice] = 100;
    HouseInfo[i][h_bought] = 0;
    HouseInfo[i][h_rentable] = 0;
    HouseInfo[i][h_locked] = 1;
    HouseInfo[i][h_money] = 0;
    HouseInfo[i][h_type] = InteriorInfo[i][int_type];
    format(query,sizeof(query),"UPDATE Houses SET BuyPrice='%i',RentPrice='%i',Bought='%i',`Locked`='%i',Money='%i',`Type`='%i',RentAble='%i' WHERE id='%i'",
    HouseInfo[i][h_buyprice],HouseInfo[i][h_rentprice],HouseInfo[i][h_bought],HouseInfo[i][h_locked],HouseInfo[i][h_money],HouseInfo[i][h_type],HouseInfo[i][h_rentable],i);
    if(HouseInfo[i][h_type] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This Apartment has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 1)
    {
    new str[128];
    format(str,sizeof(str),"This House has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 2)
    {
    new str[128];
    format(str,sizeof(str),"This Villa has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    }
    }
    return 1;
    }


    InteriorInfo:
    enum interEnum
    {
    int_ID,
    Float:int_exitX,
    Float:int_exitY,
    Float:int_exitZ,
    int_type
    };


    new InteriorInfo[][interEnum] =
    {
    //Apartments
    {12,444.646911,508.239044,1001.419494,1},
    {1,244.411987,305.032989,999.148437,1},
    {2,271.884979,306.631988,999.148437,1},
    {2,1523.509887,-47.821197,1002.130981,1},
    {},
    //Houses
    {8,2807.619873,-1171.899902,1025.570312,2},
    {3,2496.049804,-1695.238159,1014.742187,2},
    {5,318.564971,1118.209960,1083.882812,2},
    {5,2350.339843,-1181.649902,1027.976562,2},
    {1,2527.654052,-1679.388305,1015.498596,2},
    //Villas
    {12,2324.419921,-1145.568359,1050.710083,3},
    {5,1267.663208,-781.323242,1091.906250,3}
    };
    Btw: Ist natürlich alles eingereiht.


    Bilder der Datenbank:


    Schonmal danke im vorraus.

  • ocmd:hcreate(playerid,params[])
    {
    if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    new inter,price;
    if(sscanf(params,"ii",inter,price))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}Use /hcreate [Interior ID] [BuyPrice]"),
    SendClientMessage(playerid,Grau,"[Types]: 1: Apartment, 2: House, 3: Villa");
    if(!InteriorInfo[inter][int_ID])return SendClientMessage(playerid,Rot,"Error: {FFFFFF}This isn't a Valid Interior. Use /validint to see what Interiors are Valid.");
    for(new i=0;i<MAX_HOUSES;i++)
    {
    if(strlen(HouseInfo[i][h_owner]))continue;
    {
    new query[512];
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    HouseInfo[i][h_enterX] = pos[0];
    HouseInfo[i][h_enterY] = pos[1];
    HouseInfo[i][h_enterZ] = pos[2];
    HouseInfo[i][h_exitX] = InteriorInfo[i][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[i][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[i][int_exitZ];
    HouseInfo[i][h_int] = inter;
    format(HouseInfo[i][h_owner], 24, "Niemand");
    format(query,sizeof(query),"INSERT INTO Houses (id,Owner,EnterPosX,EnterPosY,EnterPosZ,ExitPosX,ExitPosY,ExitPosZ,Interior) VALUES ('%i','%s','%f','%f','%f','%f','%f','%f','%i')",
    i,HouseInfo[i][h_owner],HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],HouseInfo[i][h_exitX],HouseInfo[i][h_exitY],HouseInfo[i][h_exitZ],HouseInfo[i][h_int]);
    mysql_pquery(Handle,query);
    HouseInfo[i][h_vw] = cache_get_field_content_int(i,"VirtualWorld");
    HouseInfo[i][h_buyprice] = price;
    HouseInfo[i][h_rentprice] = 100;
    HouseInfo[i][h_bought] = 0;
    HouseInfo[i][h_rentable] = 0;
    HouseInfo[i][h_locked] = 1;
    HouseInfo[i][h_money] = 0;
    HouseInfo[i][h_type] = InteriorInfo[i][int_type];
    format(query,sizeof(query),"UPDATE Houses SET BuyPrice='%i',RentPrice='%i',Bought='%i',`Locked`='%i',Money='%i',`Type`='%i',RentAble='%i' WHERE id='%i'",
    HouseInfo[i][h_buyprice],HouseInfo[i][h_rentprice],HouseInfo[i][h_bought],HouseInfo[i][h_locked],HouseInfo[i][h_money],HouseInfo[i][h_type],HouseInfo[i][h_rentable],i);
    if(HouseInfo[i][h_type] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This Apartment has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 1)
    {
    new str[128];
    format(str,sizeof(str),"This House has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 2)
    {
    new str[128];
    format(str,sizeof(str),"This Villa has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    return 1;
    }
    }
    return 1;
    }


    Dann sollte es passen.

  • Klappt soweit außer dass, er nicht die richtigen Exit Daten aus dem Enum ausliest. Also er trägt nicht die richtigen Daten ein sondern immer die gleichen wo er mich beim eintreten dann ich einen Schwarzen Raum mit einen Spiegel setzt.
    Wenn ich /interior nutze gibt er mir auch den richtigen aus


    //EDIT:
    @Mencent:
    Jeffry:


    Alles rund um Häuser sieht gerade so aus:

    Erstell Befehl

    ocmd:hcreate(playerid,params[])
    {
    if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    new inter,price,type;
    if(sscanf(params,"iii",inter,type,price))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}Use /hcreate [Interior ID] [Type] [BuyPrice]"),
    SendClientMessage(playerid,Grau,"[Types]: 1: Apartment, 2: House, 3: Villa");
    if(inter != InteriorInfo[inter][int_ID])return SendClientMessage(playerid,Rot,"Error: {FFFFFF}This isn't a Valid Interior. Use /validint to see what Interiors are Valid.");
    for(new i=0;i<MAX_HOUSES;i++)
    {
    if(strlen(HouseInfo[i][h_owner]))continue;
    {
    new query[512];
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    HouseInfo[i][h_enterX] = pos[0];
    HouseInfo[i][h_enterY] = pos[1];
    HouseInfo[i][h_enterZ] = pos[2];
    HouseInfo[i][h_exitX] = InteriorInfo[i][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[i][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[i][int_exitZ];
    HouseInfo[i][h_int] = inter;
    format(HouseInfo[i][h_owner], 24, " ");
    format(query,sizeof(query),"INSERT INTO Houses (id,Owner,EnterPosX,EnterPosY,EnterPosZ,ExitPosX,ExitPosY,ExitPosZ,Interior) VALUES ('%i','%s','%f','%f','%f','%f','%f','%f','%i')",
    i,HouseInfo[i][h_owner],HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],HouseInfo[i][h_exitX],HouseInfo[i][h_exitY],HouseInfo[i][h_exitZ],HouseInfo[i][h_int]);
    mysql_pquery(Handle,query);
    HouseInfo[i][h_vw] = cache_get_field_content_int(i,"VirtualWorld");
    HouseInfo[i][h_buyprice] = price;
    HouseInfo[i][h_rentprice] = 100;
    HouseInfo[i][h_bought] = 0;
    HouseInfo[i][h_rentable] = 0;
    HouseInfo[i][h_locked] = 1;
    HouseInfo[i][h_money] = 0;
    HouseInfo[i][h_type] = type;
    format(query,sizeof(query),"UPDATE Houses SET BuyPrice='%i',RentPrice='%i',Bought='%i',IsLocked='%i',Money='%i',`Type`='%i',RentAble='%i' WHERE id='%i'",
    HouseInfo[i][h_buyprice],HouseInfo[i][h_rentprice],HouseInfo[i][h_bought],HouseInfo[i][h_locked],HouseInfo[i][h_money],HouseInfo[i][h_type],HouseInfo[i][h_rentable],i);
    mysql_pquery(Handle,query);
    if(HouseInfo[i][h_type] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This Apartment has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 1)
    {
    new str[128];
    format(str,sizeof(str),"This House has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 2)
    {
    new str[128];
    format(str,sizeof(str),"This Villa has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    return 1;
    }
    }
    return 1;
    }


    Häuser Laden

    stock LoadHouses()
    {
    mysql_pquery(Handle, "SELECT * FROM houses ORDER BY ID ASC","LoadHouses_Data");
    return 1;
    }

    Häuser Laden
    forward LoadHouses_Data();
    public LoadHouses_Data()
    {
    new rows;
    rows = cache_num_rows();
    for(new i=0;i<rows;i++)
    {
    HouseInfo[i][h_ID] = cache_get_field_content_int(i, "id");
    cache_get_field_content(i,"Owner",HouseInfo[i][h_owner],Handle,24);
    HouseInfo[i][h_enterX] = cache_get_field_content_float(i, "EnterPosX");
    HouseInfo[i][h_enterY] = cache_get_field_content_float(i, "EnterPosY");
    HouseInfo[i][h_enterZ] = cache_get_field_content_float(i, "EnterPosZ");
    HouseInfo[i][h_exitX] = cache_get_field_content_float(i, "ExitPosX");
    HouseInfo[i][h_exitY] = cache_get_field_content_float(i, "ExitPosY");
    HouseInfo[i][h_exitZ] = cache_get_field_content_float(i, "ExitPosZ");
    HouseInfo[i][h_int] = cache_get_field_content_int(i, "Interior");
    HouseInfo[i][h_vw] = cache_get_field_content_int(i, "VirtualWorld");
    HouseInfo[i][h_buyprice] = cache_get_field_content_int(i, "BuyPrice");
    HouseInfo[i][h_rentprice] = cache_get_field_content_int(i, "RentPrice");
    HouseInfo[i][h_bought] = cache_get_field_content_int(i, "Bought");
    HouseInfo[i][h_rentable] = cache_get_field_content_int(i, "RentAble");
    HouseInfo[i][h_locked] = cache_get_field_content_int(i, "IsLocked");
    HouseInfo[i][h_money] = cache_get_field_content_int(i, "Money");
    HouseInfo[i][h_type] = cache_get_field_content_int(i, "Type");
    for(new h=0;h<MAX_HOUSES;h++)
    {
    if(HouseInfo[h][h_type] == 0)
    {
    if(HouseInfo[h][h_bought] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This Apartment has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[h][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
    }
    else
    {
    new str[128];
    format(str,sizeof(str),"This Apartment is already bought.\nOwner: %s\nRent Price: %i",HouseInfo[h][h_owner],HouseInfo[h][h_rentprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
    }
    }
    else if(HouseInfo[h][h_type] == 1)
    {
    if(HouseInfo[h][h_bought] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This House has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[h][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
    }
    else
    {
    new str[128];
    format(str,sizeof(str),"This House is already bought.\nOwner: %s\nRent Price: %i",HouseInfo[h][h_owner],HouseInfo[h][h_rentprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
    }
    }
    else if(HouseInfo[h][h_type] == 2)
    {
    if(HouseInfo[h][h_bought] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This Villa has NO Owner, you can buy it.\nPrice: %i$",HouseInfo[h][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
    }
    else
    {
    new str[128];
    format(str,sizeof(str),"This Villa is already bought.\nOwner: %s\nRent Price: %i",HouseInfo[h][h_owner],HouseInfo[h][h_rentprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
    }
    }
    }
    }
    return 1;
    }


    Häuser betreten

    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    for(new i=0;i<MAX_HOUSES;i++)
    {
    if(newkeys == KEY_SECONDARY_ATTACK && IsPlayerInRangeOfPoint(playerid,2,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ]))
    {
    EnterHouse(i,playerid);
    }
    }
    return 1;
    }
    stock EnterHouse(house,playerid)
    {
    if(HouseInfo[house][h_locked] == 1)return SendClientMessage(playerid,Rot,"Error: {FFFFFF}This House is locked.");
    SetPlayerPos(playerid,HouseInfo[house][h_exitX],HouseInfo[house][h_exitY],HouseInfo[house][h_exitZ]);
    SetPlayerInterior(playerid,HouseInfo[house][h_int]);
    SetPlayerVirtualWorld(playerid,HouseInfo[house][h_vw]);
    return 1;
    }


    InteriorInfo

    enum interEnum
    {
    int_ID,
    Float:int_exitX,
    Float:int_exitY,
    Float:int_exitZ
    };

    InteriorInfo
    new InteriorInfo[][interEnum] =
    {
    //Apartments
    {12,444.646911,508.239044,1001.419494},
    {1,244.411987,305.032989,999.148437},
    {2,271.884979,306.631988,999.148437},
    {2,1523.509887,-47.821197,1002.130981},
    {},
    //Houses
    {8,2807.619873,-1171.899902,1025.570312},
    {3,2496.049804,-1695.238159,1014.742187},
    {5,318.564971,1118.209960,1083.882812},
    {5,2350.339843,-1181.649902,1027.976562},
    {1,2527.654052,-1679.388305,1015.498596},
    //Villas
    {12,2324.419921,-1145.568359,1050.710083},
    {5,1267.663208,-781.323242,1091.906250}
    };

    2 Mal editiert, zuletzt von CaZe ()

  • Jeffry:
    Ich habe das Problem gefunden kann es aber nicht beheben, da ich nicht weiß wie.
    Es liegt an dem Enum, er liest immer nur die erste Zeile aus dem InteriorInfo Enum aus und trägt die Exit/Interior Positionen in die Datenbank ein.
    Leider weiß ich halt nicht wie ich durch dieses enum switche.


    //EDIT:

    Und ich habe gemerkt, dass er bei dem erstellen keine neuen PickUps und TextLables macht.

  • Nein und Ja.
    Guck mal:
    Ist ein Haus aus dem Enum mit der Interior ID: 5
    {5,2350.339843,-1181.649902,1027.976562},
    Ist ein Villen Interior aus dem Enum mit der Interior ID: 5
    {5,1267.663208,-781.323242,1091.906250}


    Wenn ich nun diese Villa erstellen möchte, sucht er nichtmal nach der 5 er geht einfach das Enum runter bis er Zahlen hat die noch unverwendet sind. Da weiß ich nicht wie ich überprüfen soll ob die Variable "inter" mit der Interior ID und der Variable Type übereinstimmt.
    Ich habe mir das so gedacht:
    Jede Zeile erhält nochmal einen Typen also Apartment Haus oder Villa.
    Nun weiß ich nicht wie ich in einer if Abfrage abfragen soll ob Interior ID und Type übereinstimmen. Habe da bis jetzt nur Errors bekommen.
    Und wenn ich das schon wieder so sehe weiß ich das meine Methode wieder zu 90% nicht funktionieren wird weil, es die Interior ID: 2 schon 2x allein in Apartments existiert also: Bei Abfrage gleiche Interior ID und gleicher Type.

    enum interEnum
    {
    int_ID,
    Float:int_exitX,
    Float:int_exitY,
    Float:int_exitZ,
    int_type
    };


    new InteriorInfo[][interEnum] =
    {
    //Apartments
    {12,444.646911,508.239044,1001.419494,1},
    {1,244.411987,305.032989,999.148437,1},
    {2,271.884979,306.631988,999.148437,1},
    {2,1523.509887,-47.821197,1002.130981,1},
    {},
    //Houses
    {8,2807.619873,-1171.899902,1025.570312,2},
    {3,2496.049804,-1695.238159,1014.742187,2},
    {5,318.564971,1118.209960,1083.882812,2},
    {5,2350.339843,-1181.649902,1027.976562,2},
    {1,2527.654052,-1679.388305,1015.498596,2},
    //Villas
    {12,2324.419921,-1145.568359,1050.710083,3},
    {5,1267.663208,-781.323242,1091.906250,3}
    };


    //EDIT:
    Siehst du auch bei dem Screenshot das Haus-ID: 1 keine Einträge außer Koordinaten hat was an sich schon ein Fehler ist, da dies beim erstellen eingetragen wird etc.

  • Beim Erstellen:
    HouseInfo[i][h_exitX] = InteriorInfo[i][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[i][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[i][int_exitZ];


    new count, tmp;
    for(new j=0; j<sizeof(HouseInfo); j++) if(HouseInfo[j][h_int] == inter && HouseInfo[j][h_type] == type) count++;
    for(new j=0; j<sizeof(InteriorInfo); j++)
    {
    if(InteriorInfo[j][int_ID] == inter && InteriorInfo[j][int_type] == type)
    {
    if(tmp == count)
    {
    HouseInfo[i][h_exitX] = InteriorInfo[j][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[j][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[j][int_exitZ];
    }
    }
    tmp++;
    }


    Das dürfte sein was du willst.

    3HZXdYd.png

    Einmal editiert, zuletzt von Jeffry ()

  • Aber es besteht doch trotzdem noch das Problem welches ich //EDIT: habe.
    //EDITwelchesNichtsMitDemEditImSatzDrüberZuTuhenHat::
    Ich bin mir gar nicht sicher ob man dieses Problem auf eine leichte Weise umgehen kann.

  • Befehl:
    ocmd:hcreate(playerid,params[])
    {
    if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    new inter,price,type;
    if(sscanf(params,"iii",inter,type,price))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}Use /hcreate [Interior ID] [Type] [BuyPrice]"),
    SendClientMessage(playerid,Grau,"[Types]: 1: Apartment, 2: House, 3: Villa");
    //if(inter != InteriorInfo[inter][int_ID])return SendClientMessage(playerid,Rot,"Error: {FFFFFF}This isn't a Valid Interior. Use /validint to see what Interiors are Valid.");
    for(new i=0;i<MAX_HOUSES;i++)
    {
    if(strlen(HouseInfo[i][h_owner]))continue;
    {
    new query[512];
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    HouseInfo[i][h_enterX] = pos[0];
    HouseInfo[i][h_enterY] = pos[1];
    HouseInfo[i][h_enterZ] = pos[2];
    new count, tmp;
    for(new j=0; j<sizeof(HouseInfo); j++) if(HouseInfo[j][h_int] == inter && HouseInfo[j][h_type] == type) count++;
    for(new j=0; j<sizeof(HouseInfo); j++)
    {
    if(InteriorInfo[j][int_ID] == inter && InteriorInfo[j][int_type] == type)
    {
    if(tmp == count)
    {
    HouseInfo[i][h_exitX] = InteriorInfo[j][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[j][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[j][int_exitZ];
    }
    }
    tmp++;
    }
    HouseInfo[i][h_int] = inter;
    format(HouseInfo[i][h_owner], 24, " ");
    format(query,sizeof(query),"INSERT INTO Houses (id,Owner,EnterPosX,EnterPosY,EnterPosZ,ExitPosX,ExitPosY,ExitPosZ,Interior) VALUES ('%i','%s','%f','%f','%f','%f','%f','%f','%i')",
    i,HouseInfo[i][h_owner],HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],HouseInfo[i][h_exitX],HouseInfo[i][h_exitY],HouseInfo[i][h_exitZ],HouseInfo[i][h_int]);
    mysql_pquery(Handle,query);
    HouseInfo[i][h_vw] = cache_get_field_content_int(i,"VirtualWorld");
    HouseInfo[i][h_buyprice] = price;
    HouseInfo[i][h_rentprice] = 100;
    HouseInfo[i][h_bought] = 0;
    HouseInfo[i][h_rentable] = 0;
    HouseInfo[i][h_locked] = 1;
    HouseInfo[i][h_money] = 0;
    HouseInfo[i][h_type] = type;
    format(query,sizeof(query),"UPDATE Houses SET BuyPrice='%i',RentPrice='%i',Bought='%i',IsLocked='%i',Money='%i',`Type`='%i',RentAble='%i' WHERE id='%i'",
    HouseInfo[i][h_buyprice],HouseInfo[i][h_rentprice],HouseInfo[i][h_bought],HouseInfo[i][h_locked],HouseInfo[i][h_money],HouseInfo[i][h_type],HouseInfo[i][h_rentable],i);
    mysql_pquery(Handle,query);
    if(HouseInfo[i][h_type] == 0)
    {
    new str[128];
    format(str,sizeof(str),"This Apartment has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 1)
    {
    new str[128];
    format(str,sizeof(str),"This House has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 2)
    {
    new str[128];
    format(str,sizeof(str),"This Villa has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    return 1;
    }
    }
    return 1;
    }
    Datenbank:

  • Debugge es mal so:
    new count, tmp;
    for(new j=0; j<sizeof(HouseInfo); j++) if(HouseInfo[j][h_int] == inter && HouseInfo[j][h_type] == type) count++;
    printf("count: %d", count);
    for(new j=0; j<sizeof(InteriorInfo); j++)
    {
    printf("%d == %d | %d == %d", InteriorInfo[j][int_ID], inter, InteriorInfo[j][int_type], type);
    if(InteriorInfo[j][int_ID] == inter && InteriorInfo[j][int_type] == type)
    {
    printf("%d == %d", tmp, count);
    if(tmp == count)
    {
    printf("Nutze InteriorInfo %d", j);
    HouseInfo[i][h_exitX] = InteriorInfo[j][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[j][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[j][int_exitZ];
    }
    }
    tmp++;
    }


    Was steht im Log, wenn du die Häuser erstellst? Und was steht in der Datenbank?
    Nicht vergessen die Datenbank vorher zu leeren.

  • Klappt so halbwegs:


    //EDIT:
    Debug:

  • Oooh, böser Fehler von mir. Habe das tmp++ eine Ebene versetzt eingefügt.
    So passt es:
    new count, tmp;
    for(new j=0; j<sizeof(HouseInfo); j++) if(HouseInfo[j][h_int] == inter && HouseInfo[j][h_type] == type) count++;
    printf("count: %d", count);
    for(new j=0; j<sizeof(InteriorInfo); j++)
    {
    printf("%d == %d | %d == %d", InteriorInfo[j][int_ID], inter, InteriorInfo[j][int_type], type);
    if(InteriorInfo[j][int_ID] == inter && InteriorInfo[j][int_type] == type)
    {
    printf("%d == %d", tmp, count);
    if(tmp == count)
    {
    printf("Nutze InteriorInfo %d", j);
    HouseInfo[i][h_exitX] = InteriorInfo[j][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[j][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[j][int_exitZ];
    }
    tmp++;
    }
    }

  • Ich glaube momentan besteht eine 50/50 Chance ein Haus richtig zu erstellen :S


    ocmd:hcreate(playerid,params[])
    {
    if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}You are not allowed to use this Command.");
    new inter,price,type;
    if(sscanf(params,"iii",inter,type,price))return SendClientMessage(playerid,Rot,"Error: {FFFFFF}Use /hcreate [Interior ID] [Type] [BuyPrice]"),
    SendClientMessage(playerid,Grau,"[Types]: 1: Apartment, 2: House, 3: Villa");
    if(type < 1 || type > 3)return SendClientMessage(playerid,Rot,"Error: Something's wrong with the Type");
    //if(inter != InteriorInfo[inter][int_ID])return SendClientMessage(playerid,Rot,"Error: {FFFFFF}This isn't a Valid Interior. Use /validint to see what Interiors are Valid.");
    for(new i=0;i<MAX_HOUSES;i++)
    {
    if(strlen(HouseInfo[i][h_owner]))continue;
    {
    new query[512];
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    HouseInfo[i][h_enterX] = pos[0];
    HouseInfo[i][h_enterY] = pos[1];
    HouseInfo[i][h_enterZ] = pos[2];
    new count, tmp;
    for(new j=0; j<sizeof(HouseInfo); j++) if(HouseInfo[j][h_int] == inter && HouseInfo[j][h_type] == type) count++;
    printf("count: %d", count);
    for(new j=0; j<sizeof(InteriorInfo); j++)
    {
    printf("%d == %d | %d == %d", InteriorInfo[j][int_ID], inter, InteriorInfo[j][int_type], type);
    if(InteriorInfo[j][int_ID] == inter && InteriorInfo[j][int_type] == type)
    {
    printf("%d == %d", tmp, count);
    if(tmp == count)
    {
    printf("Nutze InteriorInfo %d", j);
    HouseInfo[i][h_exitX] = InteriorInfo[j][int_exitX];
    HouseInfo[i][h_exitY] = InteriorInfo[j][int_exitY];
    HouseInfo[i][h_exitZ] = InteriorInfo[j][int_exitZ];
    }
    tmp++;
    }
    }
    HouseInfo[i][h_int] = inter;
    format(HouseInfo[i][h_owner], 24, " ");
    format(query,sizeof(query),"INSERT INTO Houses (id,Owner,EnterPosX,EnterPosY,EnterPosZ,ExitPosX,ExitPosY,ExitPosZ,Interior) VALUES ('%i','%s','%f','%f','%f','%f','%f','%f','%i')",
    i,HouseInfo[i][h_owner],HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],HouseInfo[i][h_exitX],HouseInfo[i][h_exitY],HouseInfo[i][h_exitZ],HouseInfo[i][h_int]);
    mysql_pquery(Handle,query);
    HouseInfo[i][h_vw] = cache_get_field_content_int(i,"VirtualWorld");
    HouseInfo[i][h_buyprice] = price;
    HouseInfo[i][h_rentprice] = 100;
    HouseInfo[i][h_bought] = 0;
    HouseInfo[i][h_rentable] = 0;
    HouseInfo[i][h_locked] = 1;
    HouseInfo[i][h_money] = 0;
    HouseInfo[i][h_type] = type;
    format(query,sizeof(query),"UPDATE Houses SET BuyPrice='%i',RentPrice='%i',Bought='%i',IsLocked='%i',Money='%i',`Type`='%i',RentAble='%i' WHERE id='%i'",
    HouseInfo[i][h_buyprice],HouseInfo[i][h_rentprice],HouseInfo[i][h_bought],HouseInfo[i][h_locked],HouseInfo[i][h_money],HouseInfo[i][h_type],HouseInfo[i][h_rentable],i);
    mysql_pquery(Handle,query);
    if(HouseInfo[i][h_type] == 1)
    {
    new str[128];
    format(str,sizeof(str),"This Apartment has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 2)
    {
    new str[128];
    format(str,sizeof(str),"This House has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    else if(HouseInfo[i][h_type] == 3)
    {
    new str[128];
    format(str,sizeof(str),"This Villa has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[i][h_buyprice]);
    Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10,0,0);
    CreatePickup(1274,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
    }
    return 1;
    }
    }
    return 1;
    }

  • mysql_log:


  • Koordinaten passen soweit ich das sehe auch, aber wie du siehst werden die End-Daten nicht mehr übermittel beim erstellen des Hauses.


    Server_log:

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen