forward LoadHouse();
public LoadHouse()
{
mysql_tquery(MySQLCon, "SELECT * FROM "HOUSES_TABLE" ORDER BY `ID` ASC", "OnHouseLoad", "");
forward OnHouseLoad();
public OnHouseLoad() {
new rows, fields, houseLoadTime;
cache_get_data(rows, fields);
if(!rows)
return printf("[House] No houses to load.");
if(rows) {
houseLoadTime = GetTickCount();
for(new i = 0; i < rows; i++) {
HouseInfo[houses][hID] = cache_get_row_int(i, 0, MySQLCon);
HouseInfo[houses][hExt][0] = cache_get_row_float(i, 1, MySQLCon);
HouseInfo[houses][hExt][1] = cache_get_row_float(i, 2, MySQLCon);
HouseInfo[houses][hExt][2] = cache_get_row_float(i, 3, MySQLCon);
HouseInfo[houses][hInt][0] = cache_get_row_float(i, 4, MySQLCon);
HouseInfo[houses][hInt][1] = cache_get_row_float(i, 5, MySQLCon);
HouseInfo[houses][hInt][2] = cache_get_row_float(i, 6, MySQLCon);
HouseInfo[houses][hInterior] = cache_get_row_int(i, 7, MySQLCon);
cache_get_row(i, 8, HouseInfo[houses][hOwner], MySQLCon, MAX_PLAYER_NAME);
HouseInfo[houses][hPrice] = cache_get_row_int(i, 9, MySQLCon);
HouseInfo[houses][hOwned] = cache_get_row_int(i, 10, MySQLCon);
HouseInfo[houses][hType] = cache_get_row_int(i, 11, MySQLCon);
if(HouseInfo[houses][hOwned] == 0) {
HouseInfo[houses][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[houses][hExt][0], HouseInfo[houses][hExt][1], HouseInfo[houses][hExt][2]);
}
else {
HouseInfo[houses][hPickup] = CreateDynamicPickup(1239, 1, HouseInfo[houses][hExt][0], HouseInfo[houses][hExt][1], HouseInfo[houses][hExt][2]);
}
houses++;
}
printf("Loaded %d houses in %02d ms.", houses, GetTickCount() - houseLoadTime);
}
return 1;
}
CMD:buyhouse(playerid) {
for(new h; h < houses; h++) {
if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[h][hExt][0], HouseInfo[h][hExt][1], HouseInfo[h][hExt][2])) {
if(!HouseInfo[h][hOwned]) {
if(pInfo[playerid][pMoney] < HouseInfo[h][hPrice])
return SendClientMessage(playerid, COLOR_RED, "ERROR: {FFFFFF}You have insufficient funds to do this action('s).");
if(pInfo[playerid][pHouseKey] > 1)
return SendClientMessage(playerid, COLOR_RED, "ERROR: {FFFFFF}You already own a house.");
SendClientMessage(playerid, COLOR_WHITE, "Property has been {2BFF00}purchased.");
pInfo[playerid][pHouseKey] = 1;
HouseInfo[h][hOwned] = 1;
HouseInfo[h][hOwner] = GetName(playerid);
GiveCash(playerid, -HouseInfo[h][hPrice]);
DestroyDynamicPickup(HouseInfo[h][hPickup]);
HouseInfo[h][hPickup] = CreateDynamicPickup(1239, 1, HouseInfo[h][hExt][0], HouseInfo[h][hExt][1], HouseInfo[h][hExt][2]);
}
}
}
return 1;
}
|
Well, you don't save the new values in buyhouse, so why would they change.
|
tock SaveHouses() {
new Query[325];
for(new h; h < houses; h++) {
format(Query, sizeof Query, "UPDATE `houses` SET `ExtX`=%0.2f,`ExtY`=%0.2f,`ExtZ`=%0.2f,`IntX`=%0.2f,`IntY`=%0.2f,`IntZ`=%0.2f,`Interior`=%d,`Owner`='%s',`Price`=%d,`Owned`=%d,`Type`=%d WHERE `ID`=%d",
HouseInfo[h][hExt][0],
HouseInfo[h][hExt][1],
HouseInfo[h][hExt][2],
HouseInfo[h][hInt][0],
HouseInfo[h][hInt][1],
HouseInfo[h][hInt][2],
HouseInfo[h][hInterior],
HouseInfo[h][hOwner],
HouseInfo[h][hPrice],
HouseInfo[h][hOwned],
HouseInfo[h][hType],
HouseInfo[h][hID]);
mysql_tquery(MySQLCon, Query, "", "");
}
return 1;
}