Nabend Gemeinde von Breadfish,
ich habe das Problem, dass ich soeben meinen /hedit Befehl fertiggestellt habe und nun herausfinde dass er bei dem Befehl die richtige ID des Hauses herausbekommt aber eine falsche bei dem stock SaveHouses() wiedergibt.
stock SaveHouses()
{
new query[256];
for(new h=0;h<MAX_HOUSES;h++)
{
format(query,sizeof(query),"UPDATE houses SET RentPrice='%i',",query,HouseInfo[h][h_rentprice]);
format(query,sizeof(query),"%s IsLocked='%i',",query,HouseInfo[h][h_locked]);
format(query,sizeof(query),"%s Money='%i',",query,HouseInfo[h][h_money]);
format(query,sizeof(query),"%s RentAble='%i',",query,HouseInfo[h][h_rentable]);
format(query,sizeof(query),"%s Renter='%i',",query,HouseInfo[h][h_renter]);
format(query,sizeof(query),"%s Interior='%i',",query,HouseInfo[h][h_int]);
format(query,sizeof(query),"%s Bought='%i',",query,HouseInfo[h][h_bought]);
format(query,sizeof(query),"%s Type='%i',",query,HouseInfo[h][h_type]);
format(query,sizeof(query),"%s Owner='%s',",query,HouseInfo[h][h_owner]);
format(query,sizeof(query),"%s WHERE id='%i'",query,h);
mysql_pquery(Handle,query);
}
return 1;
}
ocmd:hedit(playerid,params[])
{
if(!IsPlayerOnline(playerid))return SendClientMessage(playerid,Rot,NotOnlineMSG);
if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,NotAnAdminMSG);
if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,NotAnAdminRankMSG);
if(EditedHouse[playerid][eh_ID] != -1)return SendClientMessage(playerid,Rot,"Error"#cWeiß": You are currently editing another House.");
for(new i=0;i<MAX_HOUSES;i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ]) || IsPlayerInRangeOfPoint(playerid,2,HouseInfo[i][h_exitX],HouseInfo[i][h_exitY],HouseInfo[i][h_exitZ]))
{
EditedHouse[playerid][eh_ID] = HouseInfo[i][h_ID];
EditedHouse[playerid][eh_int] = HouseInfo[i][h_int];
EditedHouse[playerid][eh_vw] = HouseInfo[i][h_vw];
EditedHouse[playerid][eh_type] = HouseInfo[i][h_type];
format(EditedHouse[playerid][eh_owner],24,HouseInfo[i][h_owner]);
EditedHouse[playerid][eh_buyprice] = HouseInfo[i][h_buyprice];
EditedHouse[playerid][eh_rentprice] = HouseInfo[i][h_rentprice];
EditedHouse[playerid][eh_bought] = HouseInfo[i][h_bought];
EditedHouse[playerid][eh_rentable] = HouseInfo[i][h_rentable];
EditedHouse[playerid][eh_locked] = HouseInfo[i][h_locked];
EditedHouse[playerid][eh_money] = HouseInfo[i][h_money];
EditedHouse[playerid][eh_label] = HouseInfo[i][h_label];
EditedHouse[playerid][eh_enterX] = HouseInfo[i][h_enterX];
EditedHouse[playerid][eh_enterY] = HouseInfo[i][h_enterY];
EditedHouse[playerid][eh_enterZ] = HouseInfo[i][h_enterZ];
EditedHouse[playerid][eh_exitX] = HouseInfo[i][h_exitX];
EditedHouse[playerid][eh_exitY] = HouseInfo[i][h_exitY];
EditedHouse[playerid][eh_exitZ] = HouseInfo[i][h_exitZ];
EditedHouse[playerid][eh_exitA] = HouseInfo[i][h_exitA];
new str[375];
format(str,sizeof(str),""#cWeiß"House ID:\t"#cOrange"%i\n",EditedHouse[playerid][eh_ID]);
format(str,sizeof(str),"%s"#cWeiß"House Interior:\t"#cOrange"%i\n",str,EditedHouse[playerid][eh_int]);
format(str,sizeof(str),"%s"#cWeiß"House Owner:\t"#cOrange"%s\n",str,EditedHouse[playerid][eh_owner]);
format(str,sizeof(str),"%s"#cWeiß"House BuyPrice:\t"#cOrange"%i$\n",str,EditedHouse[playerid][eh_buyprice]);
format(str,sizeof(str),"%s"#cWeiß"House SellPrice:\t"#cOrange"%i$\n",str,EditedHouse[playerid][eh_buyprice]/2);
format(str,sizeof(str),"%s"#cWeiß"House Bought:\t"#cOrange"%i\n",str,EditedHouse[playerid][eh_bought]);
format(str,sizeof(str),"%s"#cWeiß"House Locked:\t"#cOrange"%i\n",str,EditedHouse[playerid][eh_locked]);
format(str,sizeof(str),"%s"#cWeiß"House Money:\t"#cOrange"%i$\n",str,EditedHouse[playerid][eh_money]);
format(str,sizeof(str),"%s"#cWeiß"House Type:\t"#cOrange"%i\n",str,EditedHouse[playerid][eh_type]);
format(str,sizeof(str),"%s"#cWeiß"House VirtualWorld:\t"#cOrange"%i\n",str,EditedHouse[playerid][eh_vw]);
ShowPlayerDialog(playerid,DIALOG_EDIT_HOUSE,DIALOG_STYLE_TABLIST,""#cOrange"TRP"#cWeiß" - Edit House",str,"Edit","Close");
return 1;
}
}
return SendClientMessage(playerid,Rot,"Error"#cWeiß": You aren't close to any House.");
}
ocmd:hcreate(playerid,params[])
{
if(!IsPlayerOnline(playerid))return SendClientMessage(playerid,Rot,NotOnlineMSG);
if(!IsPlayerAnAdmin(playerid))return SendClientMessage(playerid,Rot,NotAnAdminMSG);
if(!IsPlayerAdminRank(playerid,4))return SendClientMessage(playerid,Rot,NotAnAdminRankMSG);
new inter,price,type;
if(sscanf(params,"iii",inter,type,price))return SendClientMessage(playerid,Rot,"Error"#cWeiß": Use /hcreate [Interior ID] [Type] [BuyPrice]"),
SendClientMessage(playerid,Grau,"[Types]: 1: Apartment | 2: House | 3: Villa | 4: Madd Dogg Villa"),
SendClientMessage(playerid,Grau,"[Interiors]: To see Valid Interiors Use /validints.");
if(type < 1 || type > 4)return SendClientMessage(playerid,Rot,"Error: Something's wrong with the Type");
for(new i=0;i<MAX_HOUSES;i++)
{
if(strlen(HouseInfo[i][h_owner]))continue;
{
new bool:found = false;
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)
{
found = true;
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];
HouseInfo[i][h_exitA] = InteriorInfo[j][int_exitA];
break;
}
}
if(!found)return SendClientMessage(playerid,Rot,"Error"#cWeiß": The Interior doesn't match with the Type.");
new query[1042];
new Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
HouseInfo[i][h_ID] = i;
HouseInfo[i][h_enterX] = pos[0];
HouseInfo[i][h_enterY] = pos[1];
HouseInfo[i][h_enterZ] = pos[2];
HouseInfo[i][h_int] = inter;
format(HouseInfo[i][h_owner], 24, "-");
HouseInfo[i][h_buyprice] = price;
HouseInfo[i][h_rentprice] = 100;
HouseInfo[i][h_bought] = 0;
HouseInfo[i][h_rentable] = 0;
HouseInfo[i][h_renter] = 0;
HouseInfo[i][h_locked] = 1;
HouseInfo[i][h_money] = 0;
HouseInfo[i][h_type] = type;
format(query,sizeof(query),"INSERT INTO Houses (id,Owner,EnterPosX,EnterPosY,EnterPosZ,ExitPosX,ExitPosY,ExitPosZ,ExitPosA,Interior,BuyPrice,RentPrice,Bought,RentAble,Renter,IsLocked,Money,Type) VALUES ('%i','%s','%f','%f','%f','%f','%f','%f','%f','%i','%i','%i','%i','%i','%i','%i','%i','%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_exitA],HouseInfo[i][h_int],HouseInfo[i][h_buyprice],HouseInfo[i][h_rentprice],HouseInfo[i][h_bought],HouseInfo[i][h_rentable],HouseInfo[i][h_renter],HouseInfo[i][h_locked],HouseInfo[i][h_money],HouseInfo[i][h_type]);
mysql_pquery(Handle,query);
printf("%i",HouseInfo[i][h_ID]);
HouseInfo[i][h_vw] = cache_get_field_content_int(i,"VirtualWorld");
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]);
HouseInfo[i][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10.0,0,0);
HouseInfo[i][h_pick] = CreatePickup(1273,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[i][h_pick]);
return 1;
}
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]);
HouseInfo[i][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10.0,0,0);
HouseInfo[i][h_pick] = CreatePickup(1273,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[i][h_pick]);
return 1;
}
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]);
HouseInfo[i][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],10.0,0,0);
HouseInfo[i][h_pick] = CreatePickup(1273,0,HouseInfo[i][h_enterX],HouseInfo[i][h_enterY],HouseInfo[i][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[i][h_pick]);
return 1;
}
}
}
return 1;
}
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_exitA] = cache_get_field_content_float(i, "ExitPosA");
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_renter] = cache_get_field_content_int(i, "Renter");
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] == 1)
{
if(HouseInfo[h][h_bought] == 0)
{
new str[128];
format(str,sizeof(str),"This Apartment has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[h][h_buyprice]);
HouseInfo[h][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10.0,0,0);
HouseInfo[h][h_pick] = CreatePickup(1273,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[h][h_pick]);
}
else
{
new str[148];
format(str,sizeof(str),"This Apartment is already bought.\nType /rent to rent a room in this Apartment.\nOwner: %s\nRent Price: %i$",HouseInfo[h][h_owner],HouseInfo[h][h_rentprice]);
HouseInfo[h][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10.0,0,0);
HouseInfo[h][h_pick] = CreatePickup(1273,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[h][h_pick]);
}
}
else if(HouseInfo[h][h_type] == 2)
{
if(HouseInfo[h][h_bought] == 0)
{
new str[128];
format(str,sizeof(str),"This House has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[h][h_buyprice]);
HouseInfo[h][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10.0,0,0);
HouseInfo[h][h_pick] = CreatePickup(1273,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[h][h_pick]);
}
else
{
new str[148];
format(str,sizeof(str),"This House is already bought.\nType /rent to rent a room in this House.\nOwner: %s\nRent Price: %i$",HouseInfo[h][h_owner],HouseInfo[h][h_rentprice]);
HouseInfo[h][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10.0,0,0);
HouseInfo[h][h_pick] = CreatePickup(1273,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[h][h_pick]);
}
}
else if(HouseInfo[h][h_type] == 3)
{
if(HouseInfo[h][h_bought] == 0)
{
new str[128];
format(str,sizeof(str),"This Villa has NO Owner.Type /buyhouse to buy it.\nPrice: %i$",HouseInfo[h][h_buyprice]);
HouseInfo[h][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10.0,0,0);
HouseInfo[h][h_pick] = CreatePickup(1273,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[h][h_pick]);
}
else
{
new str[148];
format(str,sizeof(str),"This Villa is already bought.\nType /rent to rent a room in this Villa.\nOwner: %s\nRent Price: %i$",HouseInfo[h][h_owner],HouseInfo[h][h_rentprice]);
HouseInfo[h][h_label] = Create3DTextLabel(str,Weiß,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],10.0,0,0);
HouseInfo[h][h_pick] = CreatePickup(1273,0,HouseInfo[h][h_enterX],HouseInfo[h][h_enterY],HouseInfo[h][h_enterZ],0);
printf("PickUP ID: %i",HouseInfo[h][h_pick]);
}
}
}
}
return 1;
}
stock LoadHouses()
{
mysql_pquery(Handle, "SELECT * FROM houses ORDER BY ID ASC","LoadHouses_Data");
return 1;
}
Ich danke im Voraus.