26.07.2016, 18:24
Hello everyone, I've made houses system based on a MySQL table.
So my problem is that, my house stops loading houses after loading an owned house.
Example: House ID 0 isn't owned. House ID 1 isn't owned. House ID 2 is owned. House ID 3 is not owned.
My script loads ID 0 and 1 and 2, but it doesn't load the 3rd one because an owned house was loaded before. (House ID 2)
Another example: house ID 0 isn't owned. House ID 1 is owned, house ID 2 isn't owned.
It will load ID 0, then ID 1 but it won't load ID 2 because an owned house was loaded before (House ID 1)
And if the first house in the table is owned, it will load it ONLY, it won't load the other houses on the table.
I'm serious and I can't find the bug, here's my loading script:
So in short, here's the problem: It keeps loading houses, and when the system loads an owned house, it will stop loading, it's like the owned house is the last house in the table.
So my problem is that, my house stops loading houses after loading an owned house.
Example: House ID 0 isn't owned. House ID 1 isn't owned. House ID 2 is owned. House ID 3 is not owned.
My script loads ID 0 and 1 and 2, but it doesn't load the 3rd one because an owned house was loaded before. (House ID 2)
Another example: house ID 0 isn't owned. House ID 1 is owned, house ID 2 isn't owned.
It will load ID 0, then ID 1 but it won't load ID 2 because an owned house was loaded before (House ID 1)
And if the first house in the table is owned, it will load it ONLY, it won't load the other houses on the table.
I'm serious and I can't find the bug, here's my loading script:
So in short, here's the problem: It keeps loading houses, and when the system loads an owned house, it will stop loading, it's like the owned house is the last house in the table.
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 < cache_get_row_count(); 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)
{
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, GetNameFromMySQLID(hInfo[i][hOwner]), 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;
}