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.
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.