27.07.2016, 09:35
So, this is what I done, and now, when it loads an owned house, it sets the owner name to NULL and stops loading after loading an owned house:
I've tried to let the system show the owner acc ID, not name, and it worked well and it didn't stop loading after an owned house, but when I added that mysql shit, it stopped again.
Focus to that if(hInfo[i][hOwner] != -1) ..
I've tried to let the system show the owner acc ID, not name, and it worked well and it didn't stop loading after an owned house, but when I added that mysql shit, it stopped again.
Focus to that if(hInfo[i][hOwner] != -1) ..
PHP код:
forward LoadHouses();
public LoadHouses()
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
new housepw[4], housetitle[MAX_HOUSE_NAME];
for(new i = 0; i < rows; i++)
{
hInfo[i][hID] = cache_get_row_int(i, 0);
cache_get_row(i, 2, housetitle);
cache_get_row(i, 3, housepw);
hInfo[i][hOwner] = cache_get_row_int(i, 1);
hInfo[i][hInterior] = cache_get_row_int(i, 10);
hInfo[i][hPrice] = cache_get_row_int(i, 11);
hInfo[i][hEnterX] = cache_get_row_float(i, 4);
hInfo[i][hEnterY] = cache_get_row_float(i, 5);
hInfo[i][hEnterZ] = cache_get_row_float(i, 6);
hInfo[i][hExitX] = cache_get_row_float(i, 7);
hInfo[i][hExitY] = cache_get_row_float(i, 8);
hInfo[i][hExitZ] = cache_get_row_float(i, 9);
hInfo[i][hTitle] = housetitle;
hInfo[i][hPassword] = housepw;
hInfo[i][hWorldID] = hInfo[i][hID];
new hEntStr[200];
if(hInfo[i][hOwner] == -1)
{
format(hEntStr, sizeof(hEntStr), ""COL_GOLD"House: "COL_WHITE"%s(%d)\n"COL_GOLD"Owner: "COL_WHITE"No-one\n"COL_GOLD"Price: "COL_WHITE"$%s", hInfo[i][hTitle], i, AC(hInfo[i][hPrice]));
}
else if(hInfo[i][hOwner] != -1)
{
new query[50];
mysql_format(mysql, query, sizeof(query), "SELECT Name FROM accounts WHERE ID = %d LIMIT 1", hInfo[i][hOwner]);
new Cache: result = mysql_query(mysql, query);
if (cache_get_row_count()) cache_get_row(0, 1, query);
cache_delete(result);
format(hEntStr, sizeof(hEntStr), ""COL_GOLD"House: "COL_WHITE"%s(%d)\n"COL_GOLD"Owner: "COL_WHITE"%s\n"COL_GOLD"Price: "COL_WHITE"$%s", hInfo[i][hTitle], i, query, AC(hInfo[i][hPrice]));
}
hInfo[i][sEnterLabel] = CreateDynamic3DTextLabel(hEntStr, -1, hInfo[i][hEnterX], hInfo[i][hEnterY], hInfo[i][hEnterZ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, 0, -1, 100.0);
hInfo[i][sExitLabel] = CreateDynamic3DTextLabel(""COL_GOLD"[EXIT]", -1, hInfo[i][hExitX], hInfo[i][hExitY], hInfo[i][hExitZ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, hInfo[i][hWorldID], hInfo[i][hInterior], -1, 100.0);
hInfo[i][hEnterCP] = CreateDynamicCP(hInfo[i][hEnterX], hInfo[i][hEnterY], hInfo[i][hEnterZ], 1.0, -1, 0, -1, 100.0);
hInfo[i][hExitCP] = CreateDynamicCP(hInfo[i][hExitX], hInfo[i][hExitY], hInfo[i][hExitZ], 1.0, hInfo[i][hWorldID], hInfo[i][hInterior], -1, 100.0);
LoadedHouses++;
}
printf("Loaded %d houses", LoadedHouses);
}
else if(!rows)
{
printf("There are NO houses to load");
}
return 1;
}