function LoadHouses()
{
new query[200];
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
for (new i = 1; i < MAX_HOUSES; i++)
{
mysql_format(mysql,query,sizeof(query),"SELECT * FROM `houses` WHERE `hID` = %d",i);
mysql_tquery(mysql,query);
HouseInfo[i][XEnt] = cache_get_field_content_float(0, "XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
HouseInfo[i][YEnt] = cache_get_field_content_float(0, "YEnt"); //Above
HouseInfo[i][ZEnt] = cache_get_field_content_float(0, "ZEnt");//Above
HouseInfo[i][XExit] = cache_get_field_content_float(0, "XExit");//Above. Since player's position is a float, we use cache_get_field_content_float
HouseInfo[i][YExit] = cache_get_field_content_float(0, "YExit");//Above
HouseInfo[i][ZExit] = cache_get_field_content_float(0, "ZExit");//Above
HouseInfo[i][HVirtualWorld] = cache_get_field_content_int(0, "HVirtualWorld");
HouseInfo[i][HInterior] = cache_get_field_content_int(0, "HInterior");
HouseInfo[i][HPrice] = cache_get_field_content_int(0, "HPrice");
cache_get_field_content(0,"HOwnerID",HouseInfo[i][HOwnerID], 24);
HouseInfo[i][HOwned] = cache_get_field_content_int(0, "HOwned");
HouseInfo[i][HLocked] = cache_get_field_content_int(0, "HLocked");
cache_get_field_content(0, "HName", HouseInfo[i][HName], 30);
}
print("Successfully Loaded All Houses!");
}
else if(!rows)
{
print("There are no houses to load!");
}
return 1;
}
printf("houses: %d rows",rows);
If you add the code below before if(rows), will it always say 0 rows?
PHP код:
|
mysql_tquery
mysql_query
function CreateHouse(Float:Xen,Float:Yen,Float:Zen,Float:Xex,Float:Yex,Float:Zex,virtualworld,interiorid,price)
{
static hCount;
new hid = hCount; hCount += 1;
new string[100];
new query[350];
hid += 1;
HouseInfo[hid][XEnt] = Xen;
HouseInfo[hid][YEnt] = Yen;
HouseInfo[hid][ZEnt] = Zen;
HouseInfo[hid][XExit] = Xex;
HouseInfo[hid][YExit] = Yex;
HouseInfo[hid][ZExit] = Zex;
HouseInfo[hid][HVirtualWorld] = virtualworld;
HouseInfo[hid][HInterior] = interiorid;
HouseInfo[hid][HPrice] = price;
HouseInfo[hid][HOwned] = 0;
HouseInfo[hid][HLocked] = 0;
format(string,sizeof(string),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",price);
HouseInfo[hid][H3D] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, Xen, Yen, Zen, 40.0, 1);
mysql_format(mysql,query,sizeof(query), "INSERT INTO `houses` (`Xent`, `Yent`, `Zent`, `XExit`, `YExit`, `ZExit`, `HVirtualWorld`, `HInterior`, `HPrice`,\
`HOwned`, `HLocked`) VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, 0, 0)", Xen,Yen,Zen,Xex,Yex,Zex,virtualworld,interiorid,price);
mysql_tquery(mysql, query, "RegisterHouse","i",hid);
return 1;
}
EDIT: reading this again i might be wrong.
You're possibly using a wrong function for your query. swap PHP код:
PHP код:
|
mysql_format(mysql,query,sizeof(query), "INSERT INTO `houses` (`Xent`, `Yent`, `Zent`, `XExit`, `YExit`, `ZExit`, `HVirtualWorld`, `HInterior`, `HPrice`,\
`HOwned`, `HLocked`) VALUES (%.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %d, 0, 0)", Xen,Yen,Zen,Xex,Yex,Zex,virtualworld,interiorid,price);
mysql_tquery(mysql, query, "RegisterHouse","i",hid);