BlueG MySQL only loading 1 row
#1

I'm having a problem where BlueG MySQL is only loading data from 1 row but it sees that there is 37 rows.

samp-server.exe:
Код:
House rows = 37
House 1 ID = 1
* 1 houses were loaded from the database.
Code:
PHP код:
public OnGameModeInit()
{
    ....
    
mysql_tquery(g_SQL"SELECT * FROM `houses`""Query_LoadHouses");
    ....
}
public 
Query_LoadHouses()
{
    new 
rows cache_num_rows();
    if(!
rows)
        return print(
"* No houses were loaded from the database.");
    
printf("House rows = %d"rows);
    new 
countHouses 0;
    for(new 
0rowsi++)
    {
        
cache_get_value_int(i"ID"HouseInfo[i+1][HouseID]);
        if(
HouseInfo[i+1][HouseID])
        {
            
printf("House %d ID = %d"i+1HouseInfo[i+1][HouseID]);
            
cache_get_value_int(i"OwnerID"HouseInfo[i+1][HouseOwnerID]);
            
cache_get_value_int(i"MarketPrice"HouseInfo[i+1][HouseMarketPrice]);
            
cache_get_value_float(i"ExteriorX"HouseInfo[i+1][HouseExteriorX]);
            
cache_get_value_float(i"ExteriorY"HouseInfo[i+1][HouseExteriorY]);
            
cache_get_value_float(i"ExteriorZ"HouseInfo[i+1][HouseExteriorZ]);
            
cache_get_value_float(i"ExteriorA"HouseInfo[i+1][HouseExteriorA]);
            
cache_get_value_int(i"ExteriorInt"HouseInfo[i+1][HouseExteriorInt]);
            
cache_get_value_int(i"ExteriorVW"HouseInfo[i+1][HouseExteriorVW]);
            
cache_get_value_float(i"InteriorX"HouseInfo[i+1][HouseInteriorX]);
            
cache_get_value_float(i"InteriorY"HouseInfo[i+1][HouseInteriorY]);
            
cache_get_value_float(i"InteriorZ"HouseInfo[i+1][HouseInteriorZ]);
            
cache_get_value_float(i"InteriorA"HouseInfo[i+1][HouseInteriorA]);
            
cache_get_value_int(i"InteriorInt"HouseInfo[i+1][HouseInteriorInt]);
            
cache_get_value_int(i"Locked"HouseInfo[i+1][HouseLocked]);
            
cache_get_value_int(i"CashBox"HouseInfo[i+1][HouseCashBox]);
            
// I rrly do not like this code, but having a loop made the compiler cry :(
            
cache_get_value_int(i"Weapons0"HouseInfo[i+1][HouseWeapons][0]);
            
cache_get_value_int(i"Weapons1"HouseInfo[i+1][HouseWeapons][1]);
            
cache_get_value_int(i"Weapons2"HouseInfo[i+1][HouseWeapons][2]);
            
cache_get_value_int(i"Weapons3"HouseInfo[i+1][HouseWeapons][3]);
            
cache_get_value_int(i"Weapons4"HouseInfo[i+1][HouseWeapons][4]);
            
cache_get_value_int(i"Weapons5"HouseInfo[i+1][HouseWeapons][5]);
            
cache_get_value_int(i"Weapons6"HouseInfo[i+1][HouseWeapons][6]);
            
cache_get_value_int(i"Weapons7"HouseInfo[i+1][HouseWeapons][7]);
            
cache_get_value_int(i"Weapons8"HouseInfo[i+1][HouseWeapons][8]);
            
cache_get_value_int(i"Weapons9"HouseInfo[i+1][HouseWeapons][9]);
            
cache_get_value_int(i"Weapons10"HouseInfo[i+1][HouseWeapons][10]);
            
cache_get_value_int(i"Weapons11"HouseInfo[i+1][HouseWeapons][11]);
            
cache_get_value_int(i"Weapons12"HouseInfo[i+1][HouseWeapons][12]);
            
cache_get_value_int(i"Weapons13"HouseInfo[i+1][HouseWeapons][13]);
            
cache_get_value_int(i"Weapons14"HouseInfo[i+1][HouseWeapons][14]);
            
cache_get_value_int(i"Weapons15"HouseInfo[i+1][HouseWeapons][15]);
            
cache_get_value_int(i"Weapons16"HouseInfo[i+1][HouseWeapons][16]);
            
cache_get_value_int(i"Weapons17"HouseInfo[i+1][HouseWeapons][17]);
            
cache_get_value_int(i"Weapons18"HouseInfo[i+1][HouseWeapons][18]);
            
cache_get_value_int(i"Weapons19"HouseInfo[i+1][HouseWeapons][19]);
            
cache_get_value_int(i"Weapons20"HouseInfo[i+1][HouseWeapons][20]);
            
// I rrly do not like this code, but having a loop made the compiler cry :(
            
cache_get_value_int(i"WeaponsAmmo0"HouseInfo[i+1][HouseWeaponsAmmo][0]);
            
cache_get_value_int(i"WeaponsAmmo1"HouseInfo[i+1][HouseWeaponsAmmo][1]);
            
cache_get_value_int(i"WeaponsAmmo2"HouseInfo[i+1][HouseWeaponsAmmo][2]);
            
cache_get_value_int(i"WeaponsAmmo3"HouseInfo[i+1][HouseWeaponsAmmo][4]);
            
cache_get_value_int(i"WeaponsAmmo5"HouseInfo[i+1][HouseWeaponsAmmo][5]);
            
cache_get_value_int(i"WeaponsAmmo6"HouseInfo[i+1][HouseWeaponsAmmo][6]);
            
cache_get_value_int(i"WeaponsAmmo7"HouseInfo[i+1][HouseWeaponsAmmo][7]);
            
cache_get_value_int(i"WeaponsAmmo8"HouseInfo[i+1][HouseWeaponsAmmo][8]);
            
cache_get_value_int(i"WeaponsAmmo9"HouseInfo[i+1][HouseWeaponsAmmo][9]);
            
cache_get_value_int(i"WeaponsAmmo10"HouseInfo[i+1][HouseWeaponsAmmo][10]);
            
cache_get_value_int(i"WeaponsAmmo11"HouseInfo[i+1][HouseWeaponsAmmo][11]);
            
cache_get_value_int(i"WeaponsAmmo12"HouseInfo[i+1][HouseWeaponsAmmo][12]);
            
cache_get_value_int(i"WeaponsAmmo13"HouseInfo[i+1][HouseWeaponsAmmo][13]);
            
cache_get_value_int(i"WeaponsAmmo14"HouseInfo[i+1][HouseWeaponsAmmo][14]);
            
cache_get_value_int(i"WeaponsAmmo15"HouseInfo[i+1][HouseWeaponsAmmo][15]);
            
cache_get_value_int(i"WeaponsAmmo16"HouseInfo[i+1][HouseWeaponsAmmo][16]);
            
cache_get_value_int(i"WeaponsAmmo17"HouseInfo[i+1][HouseWeaponsAmmo][17]);
            
cache_get_value_int(i"WeaponsAmmo18"HouseInfo[i+1][HouseWeaponsAmmo][18]);
            
cache_get_value_int(i"WeaponsAmmo19"HouseInfo[i+1][HouseWeaponsAmmo][19]);
            
cache_get_value_int(i"WeaponsAmmo20"HouseInfo[i+1][HouseWeaponsAmmo][20]);
            
            
cache_get_value_float(i"PlacePosX"HouseInfo[i+1][HousePlacePosX]);
            
cache_get_value_float(i"PlacePosY"HouseInfo[i+1][HousePlacePosY]);
            
cache_get_value_float(i"PlacePosZ"HouseInfo[i+1][HousePlacePosZ]);
            
cache_get_value_int(i"Boombox"HouseInfo[i+1][HouseBoombox]);
            
cache_get_value_int(i"RentFee"HouseInfo[i+1][HouseRentFee]);
            
cache_get_value_int(i"Rentable"HouseInfo[i+1][HouseRentable]);
            new 
query[128];
            
mysql_format(g_SQLquerysizeof query"SELECT * FROM furniture WHERE HouseID = %d"HouseInfo[i+1][HouseID]);
            
mysql_tquery(g_SQLquery"OnLoadFurniture""d"i);
            
            if(
HouseInfo[i+1][HouseLocked] == 0)
                
HouseInfo[i+1][HouseLocked] = 1;
            
UpdateHousePickup(i+1);
            
countHouses++;
        }
    }
    
printf("* %d houses were loaded from the database."countHouses);
    return 
1;

Код:
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
[22:09:01] [ERROR] cache_get_value_name_int: no active cache (./Source/Properties/House.pwn:877)
Reply
#2

Try commenting the query to load your furniture and see if that does the trick.

If it now loads all houses, you can be certain that sending the query and calling the OnLoadFurniture callback exitst the house-loading loop by going to the other callback and not returning here.
Then you can fix it by loading all furniture at once after you've finished loading all the houses and looping through the result and store your furniture at each house. You may want to order it all by the HouseID.

If not, then I don't know what the problem might be.
Reply
#3

Quote:
Originally Posted by AmigaBlizzard
Посмотреть сообщение
Try commenting the query to load your furniture and see if that does the trick.

If it now loads all houses, you can be certain that sending the query and calling the OnLoadFurniture callback exitst the house-loading loop by going to the other callback and not returning here.
Then you can fix it by loading all furniture at once after you've finished loading all the houses and looping through the result and store your furniture at each house. You may want to order it all by the HouseID.

If not, then I don't know what the problem might be.
I'll try that, but I honestly doubt that's the issue.

EDIT: Nope, just as I suspected, that did nothing.
Reply
#4

What error does the mysql log show?
Reply
#5

Quote:
Originally Posted by Phreak
Посмотреть сообщение
What error does the mysql log show?
I added the MySQL log.
Reply
#6

There are tons of mistakes in your code!

Why are you adding +1 to the loop ID? The arrays start from 0 not 1 and you should.
PHP код:
HouseInfo[i+1][HouseID]); 
Remove the if statement in the loop. That clearly doesn't makes sense if your house row IDs have auto increment.

SQL is a relational database, make use of foreign keys. Make a separate table dedicated to house weapons!
PHP код:
          cache_get_value_int(i"Weapons0"HouseInfo[i+1][HouseWeapons][0]); 
            
cache_get_value_int(i"Weapons1"HouseInfo[i+1][HouseWeapons][1]); 
            
cache_get_value_int(i"Weapons2"HouseInfo[i+1][HouseWeapons][2]); 
            
cache_get_value_int(i"Weapons3"HouseInfo[i+1][HouseWeapons][3]); 
            
cache_get_value_int(i"Weapons4"HouseInfo[i+1][HouseWeapons][4]); 
            
cache_get_value_int(i"Weapons5"HouseInfo[i+1][HouseWeapons][5]); 
            
cache_get_value_int(i"Weapons6"HouseInfo[i+1][HouseWeapons][6]); 
            
cache_get_value_int(i"Weapons7"HouseInfo[i+1][HouseWeapons][7]); 
            
cache_get_value_int(i"Weapons8"HouseInfo[i+1][HouseWeapons][8]); 
            
cache_get_value_int(i"Weapons9"HouseInfo[i+1][HouseWeapons][9]); 
            
cache_get_value_int(i"Weapons10"HouseInfo[i+1][HouseWeapons][10]); 
            
cache_get_value_int(i"Weapons11"HouseInfo[i+1][HouseWeapons][11]); 
            
cache_get_value_int(i"Weapons12"HouseInfo[i+1][HouseWeapons][12]); 
            
cache_get_value_int(i"Weapons13"HouseInfo[i+1][HouseWeapons][13]); 
            
cache_get_value_int(i"Weapons14"HouseInfo[i+1][HouseWeapons][14]); 
            
cache_get_value_int(i"Weapons15"HouseInfo[i+1][HouseWeapons][15]); 
            
cache_get_value_int(i"Weapons16"HouseInfo[i+1][HouseWeapons][16]); 
            
cache_get_value_int(i"Weapons17"HouseInfo[i+1][HouseWeapons][17]); 
            
cache_get_value_int(i"Weapons18"HouseInfo[i+1][HouseWeapons][18]); 
            
cache_get_value_int(i"Weapons19"HouseInfo[i+1][HouseWeapons][19]); 
            
cache_get_value_int(i"Weapons20"HouseInfo[i+1][HouseWeapons][20]); 
(( Ewww, Yuck! ))

Just run this query separately once you've loaded all the houses!
PHP код:
            new query[128]; 
            
mysql_format(g_SQLquerysizeof query"SELECT * FROM furniture WHERE HouseID = %d"HouseInfo[i+1][HouseID]); 
            
mysql_tquery(g_SQLquery"OnLoadFurniture""d"i); 
becomes
PHP код:
mysql_tquery(g_SQL"SELECT * FROM furniture""OnLoadFurnitures"); 
Reply
#7

Quote:
Originally Posted by Logic_
Посмотреть сообщение
There are tons of mistakes in your code!

Why are you adding +1 to the loop ID? The arrays start from 0 not 1 and you should.
PHP код:
HouseInfo[i+1][HouseID]); 
Remove the if statement in the loop. That clearly doesn't makes sense if your house row IDs have auto increment.

SQL is a relational database, make use of foreign keys. Make a separate table dedicated to house weapons!
PHP код:
          cache_get_value_int(i"Weapons0"HouseInfo[i+1][HouseWeapons][0]); 
            
cache_get_value_int(i"Weapons1"HouseInfo[i+1][HouseWeapons][1]); 
            
cache_get_value_int(i"Weapons2"HouseInfo[i+1][HouseWeapons][2]); 
            
cache_get_value_int(i"Weapons3"HouseInfo[i+1][HouseWeapons][3]); 
            
cache_get_value_int(i"Weapons4"HouseInfo[i+1][HouseWeapons][4]); 
            
cache_get_value_int(i"Weapons5"HouseInfo[i+1][HouseWeapons][5]); 
            
cache_get_value_int(i"Weapons6"HouseInfo[i+1][HouseWeapons][6]); 
            
cache_get_value_int(i"Weapons7"HouseInfo[i+1][HouseWeapons][7]); 
            
cache_get_value_int(i"Weapons8"HouseInfo[i+1][HouseWeapons][8]); 
            
cache_get_value_int(i"Weapons9"HouseInfo[i+1][HouseWeapons][9]); 
            
cache_get_value_int(i"Weapons10"HouseInfo[i+1][HouseWeapons][10]); 
            
cache_get_value_int(i"Weapons11"HouseInfo[i+1][HouseWeapons][11]); 
            
cache_get_value_int(i"Weapons12"HouseInfo[i+1][HouseWeapons][12]); 
            
cache_get_value_int(i"Weapons13"HouseInfo[i+1][HouseWeapons][13]); 
            
cache_get_value_int(i"Weapons14"HouseInfo[i+1][HouseWeapons][14]); 
            
cache_get_value_int(i"Weapons15"HouseInfo[i+1][HouseWeapons][15]); 
            
cache_get_value_int(i"Weapons16"HouseInfo[i+1][HouseWeapons][16]); 
            
cache_get_value_int(i"Weapons17"HouseInfo[i+1][HouseWeapons][17]); 
            
cache_get_value_int(i"Weapons18"HouseInfo[i+1][HouseWeapons][18]); 
            
cache_get_value_int(i"Weapons19"HouseInfo[i+1][HouseWeapons][19]); 
            
cache_get_value_int(i"Weapons20"HouseInfo[i+1][HouseWeapons][20]); 
(( Ewww, Yuck! ))

Just run this query separately once you've loaded all the houses!
PHP код:
            new query[128]; 
            
mysql_format(g_SQLquerysizeof query"SELECT * FROM furniture WHERE HouseID = %d"HouseInfo[i+1][HouseID]); 
            
mysql_tquery(g_SQLquery"OnLoadFurniture""d"i); 
becomes
PHP код:
mysql_tquery(g_SQL"SELECT * FROM furniture""OnLoadFurnitures"); 
That doesn't fix the issue at all, I'm still getting the same result as before. I have changed the code accordingly though.
Reply
#8

Код:
public OnGameModeInit()
{
    ....
    mysql_tquery(g_SQL, "SELECT * FROM houses", "Query_LoadHouses", "");
    ....
}

public Query_LoadHouses()
{
    new rows = cache_num_rows();
    mysql_store_result();
    if(rows)
  	{
    for(new i; i < rows; i++)
    {
            new h;
            h = cache_get_field_content_int(i, "ID");
            cache_get_field_content(i, "OwnerID", HouseInfo[h][HouseOwnerID]);
            HouseInfo[h][HouseMarketPrice] = cache_get_field_content_int(i, "hpass");
            HouseInfo[h][HouseExteriorX] = cache_get_field_content_float(i, "ExteriorX");
            HouseInfo[h][HouseExteriorY] = cache_get_field_content_float(i, "ExteriorY");
            HouseInfo[h][HouseExteriorZ] = cache_get_field_content_float(i, "ExteriorZ");
            HouseInfo[h][HouseExteriorA] = cache_get_field_content_float(i, "ExteriorA");
            HouseInfo[h][HouseExteriorInt] = cache_get_field_content_int(i, "ExteriorInt")
            HouseInfo[h][HouseExteriorVW] = cache_get_field_content_int(i, "ExteriorVW")
            HouseInfo[h][HouseInteriorX] = cache_get_field_content_float(i, "InteriorX");
            HouseInfo[h][HouseInteriorY] = cache_get_field_content_float(i, "InteriorY");
            HouseInfo[h][HouseInteriorZ] = cache_get_field_content_float(i, "InteriorZ");
            HouseInfo[h][HouseInteriorA] = cache_get_field_content_float(i, "InteriorA");
            HouseInfo[h][HouseInteriorInt] = cache_get_field_content_int(i, "InteriorInt");
            HouseInfo[h][HouseLocked] = cache_get_field_content_int(i, "Locked");
            HouseInfo[h][HouseCashBox] = cache_get_field_content_int(i, "CashBox");

            // I rrly do not like this code, but having a loop made the compiler cry :(
            cache_get_value_int(i, "Weapons0", HouseInfo[h][HouseWeapons][0]);
            cache_get_value_int(i, "Weapons1", HouseInfo[h][HouseWeapons][1]);
            cache_get_value_int(i, "Weapons2", HouseInfo[h][HouseWeapons][2]);
            cache_get_value_int(i, "Weapons3", HouseInfo[h][HouseWeapons][3]);
            cache_get_value_int(i, "Weapons4", HouseInfo[h][HouseWeapons][4]);
            cache_get_value_int(i, "Weapons5", HouseInfo[h][HouseWeapons][5]);
            cache_get_value_int(i, "Weapons6", HouseInfo[h][HouseWeapons][6]);
            cache_get_value_int(i, "Weapons7", HouseInfo[h][HouseWeapons][7]);
            cache_get_value_int(i, "Weapons8", HouseInfo[h][HouseWeapons][8]);
            cache_get_value_int(i, "Weapons9", HouseInfo[h][HouseWeapons][9]);
            cache_get_value_int(i, "Weapons10", HouseInfo[h][HouseWeapons][10]);
            cache_get_value_int(i, "Weapons11", HouseInfo[h][HouseWeapons][11]);
            cache_get_value_int(i, "Weapons12", HouseInfo[h][HouseWeapons][12]);
            cache_get_value_int(i, "Weapons13", HouseInfo[h][HouseWeapons][13]);
            cache_get_value_int(i, "Weapons14", HouseInfo[h][HouseWeapons][14]);
            cache_get_value_int(i, "Weapons15", HouseInfo[h][HouseWeapons][15]);
            cache_get_value_int(i, "Weapons16", HouseInfo[h][HouseWeapons][16]);
            cache_get_value_int(i, "Weapons17", HouseInfo[h][HouseWeapons][17]);
            cache_get_value_int(i, "Weapons18", HouseInfo[h][HouseWeapons][18]);
            cache_get_value_int(i, "Weapons19", HouseInfo[h][HouseWeapons][19]);
            cache_get_value_int(i, "Weapons20", HouseInfo[h][HouseWeapons][20]);

            // I rrly do not like this code, but having a loop made the compiler cry :(
            cache_get_value_int(i, "WeaponsAmmo0", HouseInfo[h][HouseWeaponsAmmo][0]);
            cache_get_value_int(i, "WeaponsAmmo1", HouseInfo[h][HouseWeaponsAmmo][1]);
            cache_get_value_int(i, "WeaponsAmmo2", HouseInfo[h][HouseWeaponsAmmo][2]);
            cache_get_value_int(i, "WeaponsAmmo3", HouseInfo[h][HouseWeaponsAmmo][4]);
            cache_get_value_int(i, "WeaponsAmmo5", HouseInfo[h][HouseWeaponsAmmo][5]);
            cache_get_value_int(i, "WeaponsAmmo6", HouseInfo[h][HouseWeaponsAmmo][6]);
            cache_get_value_int(i, "WeaponsAmmo7", HouseInfo[h][HouseWeaponsAmmo][7]);
            cache_get_value_int(i, "WeaponsAmmo8", HouseInfo[h][HouseWeaponsAmmo][8]);
            cache_get_value_int(i, "WeaponsAmmo9", HouseInfo[h][HouseWeaponsAmmo][9]);
            cache_get_value_int(i, "WeaponsAmmo10", HouseInfo[h][HouseWeaponsAmmo][10]);
            cache_get_value_int(i, "WeaponsAmmo11", HouseInfo[h][HouseWeaponsAmmo][11]);
            cache_get_value_int(i, "WeaponsAmmo12", HouseInfo[h][HouseWeaponsAmmo][12]);
            cache_get_value_int(i, "WeaponsAmmo13", HouseInfo[h][HouseWeaponsAmmo][13]);
            cache_get_value_int(i, "WeaponsAmmo14", HouseInfo[h][HouseWeaponsAmmo][14]);
            cache_get_value_int(i, "WeaponsAmmo15", HouseInfo[h][HouseWeaponsAmmo][15]);
            cache_get_value_int(i, "WeaponsAmmo16", HouseInfo[h][HouseWeaponsAmmo][16]);
            cache_get_value_int(i, "WeaponsAmmo17", HouseInfo[h][HouseWeaponsAmmo][17]);
            cache_get_value_int(i, "WeaponsAmmo18", HouseInfo[h][HouseWeaponsAmmo][18]);
            cache_get_value_int(i, "WeaponsAmmo19", HouseInfo[h][HouseWeaponsAmmo][19]);
            cache_get_value_int(i, "WeaponsAmmo20", HouseInfo[h][HouseWeaponsAmmo][20]);

            cache_get_value_float(i, "PlacePosX", HouseInfo[h][HousePlacePosX]);
            cache_get_value_float(i, "PlacePosY", HouseInfo[h][HousePlacePosY]);
            cache_get_value_float(i, "PlacePosZ", HouseInfo[h][HousePlacePosZ]);

            cache_get_value_int(i, "Boombox", HouseInfo[h][HouseBoombox]);
            cache_get_value_int(i, "RentFee", HouseInfo[h][HouseRentFee]);
            cache_get_value_int(i, "Rentable", HouseInfo[h][HouseRentable]);

            new query[128];
            mysql_format(g_SQL, query, sizeof query, "SELECT * FROM furniture WHERE HouseID = %d", HouseInfo[h][HouseID]);
            mysql_tquery(g_SQL, query, "OnLoadFurniture", "d", h);

            if(HouseInfo[h][HouseLocked] == 0)
                HouseInfo[h][HouseLocked] = 1;

            UpdateHousePickup(h);
            h++;
        }
    }
    mysql_free_result();
    printf("* %d houses were loaded from the database.", rows);
    return 1;
}
try this
Reply
#9

Quote:
Originally Posted by UFF
Посмотреть сообщение
Код:
public OnGameModeInit()
{
    ....
    mysql_tquery(g_SQL, "SELECT * FROM houses", "Query_LoadHouses", "");
    ....
}

public Query_LoadHouses()
{
    new rows = cache_num_rows();
    mysql_store_result();
    if(rows)
  	{
    for(new i; i < rows; i++)
    {
            new h;
            h = cache_get_field_content_int(i, "ID");
            cache_get_field_content(i, "OwnerID", HouseInfo[h][HouseOwnerID]);
            HouseInfo[h][HouseMarketPrice] = cache_get_field_content_int(i, "hpass");
            HouseInfo[h][HouseExteriorX] = cache_get_field_content_float(i, "ExteriorX");
            HouseInfo[h][HouseExteriorY] = cache_get_field_content_float(i, "ExteriorY");
            HouseInfo[h][HouseExteriorZ] = cache_get_field_content_float(i, "ExteriorZ");
            HouseInfo[h][HouseExteriorA] = cache_get_field_content_float(i, "ExteriorA");
            HouseInfo[h][HouseExteriorInt] = cache_get_field_content_int(i, "ExteriorInt")
            HouseInfo[h][HouseExteriorVW] = cache_get_field_content_int(i, "ExteriorVW")
            HouseInfo[h][HouseInteriorX] = cache_get_field_content_float(i, "InteriorX");
            HouseInfo[h][HouseInteriorY] = cache_get_field_content_float(i, "InteriorY");
            HouseInfo[h][HouseInteriorZ] = cache_get_field_content_float(i, "InteriorZ");
            HouseInfo[h][HouseInteriorA] = cache_get_field_content_float(i, "InteriorA");
            HouseInfo[h][HouseInteriorInt] = cache_get_field_content_int(i, "InteriorInt");
            HouseInfo[h][HouseLocked] = cache_get_field_content_int(i, "Locked");
            HouseInfo[h][HouseCashBox] = cache_get_field_content_int(i, "CashBox");

            // I rrly do not like this code, but having a loop made the compiler cry :(
            cache_get_value_int(i, "Weapons0", HouseInfo[h][HouseWeapons][0]);
            cache_get_value_int(i, "Weapons1", HouseInfo[h][HouseWeapons][1]);
            cache_get_value_int(i, "Weapons2", HouseInfo[h][HouseWeapons][2]);
            cache_get_value_int(i, "Weapons3", HouseInfo[h][HouseWeapons][3]);
            cache_get_value_int(i, "Weapons4", HouseInfo[h][HouseWeapons][4]);
            cache_get_value_int(i, "Weapons5", HouseInfo[h][HouseWeapons][5]);
            cache_get_value_int(i, "Weapons6", HouseInfo[h][HouseWeapons][6]);
            cache_get_value_int(i, "Weapons7", HouseInfo[h][HouseWeapons][7]);
            cache_get_value_int(i, "Weapons8", HouseInfo[h][HouseWeapons][8]);
            cache_get_value_int(i, "Weapons9", HouseInfo[h][HouseWeapons][9]);
            cache_get_value_int(i, "Weapons10", HouseInfo[h][HouseWeapons][10]);
            cache_get_value_int(i, "Weapons11", HouseInfo[h][HouseWeapons][11]);
            cache_get_value_int(i, "Weapons12", HouseInfo[h][HouseWeapons][12]);
            cache_get_value_int(i, "Weapons13", HouseInfo[h][HouseWeapons][13]);
            cache_get_value_int(i, "Weapons14", HouseInfo[h][HouseWeapons][14]);
            cache_get_value_int(i, "Weapons15", HouseInfo[h][HouseWeapons][15]);
            cache_get_value_int(i, "Weapons16", HouseInfo[h][HouseWeapons][16]);
            cache_get_value_int(i, "Weapons17", HouseInfo[h][HouseWeapons][17]);
            cache_get_value_int(i, "Weapons18", HouseInfo[h][HouseWeapons][18]);
            cache_get_value_int(i, "Weapons19", HouseInfo[h][HouseWeapons][19]);
            cache_get_value_int(i, "Weapons20", HouseInfo[h][HouseWeapons][20]);

            // I rrly do not like this code, but having a loop made the compiler cry :(
            cache_get_value_int(i, "WeaponsAmmo0", HouseInfo[h][HouseWeaponsAmmo][0]);
            cache_get_value_int(i, "WeaponsAmmo1", HouseInfo[h][HouseWeaponsAmmo][1]);
            cache_get_value_int(i, "WeaponsAmmo2", HouseInfo[h][HouseWeaponsAmmo][2]);
            cache_get_value_int(i, "WeaponsAmmo3", HouseInfo[h][HouseWeaponsAmmo][4]);
            cache_get_value_int(i, "WeaponsAmmo5", HouseInfo[h][HouseWeaponsAmmo][5]);
            cache_get_value_int(i, "WeaponsAmmo6", HouseInfo[h][HouseWeaponsAmmo][6]);
            cache_get_value_int(i, "WeaponsAmmo7", HouseInfo[h][HouseWeaponsAmmo][7]);
            cache_get_value_int(i, "WeaponsAmmo8", HouseInfo[h][HouseWeaponsAmmo][8]);
            cache_get_value_int(i, "WeaponsAmmo9", HouseInfo[h][HouseWeaponsAmmo][9]);
            cache_get_value_int(i, "WeaponsAmmo10", HouseInfo[h][HouseWeaponsAmmo][10]);
            cache_get_value_int(i, "WeaponsAmmo11", HouseInfo[h][HouseWeaponsAmmo][11]);
            cache_get_value_int(i, "WeaponsAmmo12", HouseInfo[h][HouseWeaponsAmmo][12]);
            cache_get_value_int(i, "WeaponsAmmo13", HouseInfo[h][HouseWeaponsAmmo][13]);
            cache_get_value_int(i, "WeaponsAmmo14", HouseInfo[h][HouseWeaponsAmmo][14]);
            cache_get_value_int(i, "WeaponsAmmo15", HouseInfo[h][HouseWeaponsAmmo][15]);
            cache_get_value_int(i, "WeaponsAmmo16", HouseInfo[h][HouseWeaponsAmmo][16]);
            cache_get_value_int(i, "WeaponsAmmo17", HouseInfo[h][HouseWeaponsAmmo][17]);
            cache_get_value_int(i, "WeaponsAmmo18", HouseInfo[h][HouseWeaponsAmmo][18]);
            cache_get_value_int(i, "WeaponsAmmo19", HouseInfo[h][HouseWeaponsAmmo][19]);
            cache_get_value_int(i, "WeaponsAmmo20", HouseInfo[h][HouseWeaponsAmmo][20]);

            cache_get_value_float(i, "PlacePosX", HouseInfo[h][HousePlacePosX]);
            cache_get_value_float(i, "PlacePosY", HouseInfo[h][HousePlacePosY]);
            cache_get_value_float(i, "PlacePosZ", HouseInfo[h][HousePlacePosZ]);

            cache_get_value_int(i, "Boombox", HouseInfo[h][HouseBoombox]);
            cache_get_value_int(i, "RentFee", HouseInfo[h][HouseRentFee]);
            cache_get_value_int(i, "Rentable", HouseInfo[h][HouseRentable]);

            new query[128];
            mysql_format(g_SQL, query, sizeof query, "SELECT * FROM furniture WHERE HouseID = %d", HouseInfo[h][HouseID]);
            mysql_tquery(g_SQL, query, "OnLoadFurniture", "d", h);

            if(HouseInfo[h][HouseLocked] == 0)
                HouseInfo[h][HouseLocked] = 1;

            UpdateHousePickup(h);
            h++;
        }
    }
    mysql_free_result();
    printf("* %d houses were loaded from the database.", rows);
    return 1;
}
try this
That will not work, I'm using R40-4, you're using an the API of an older (incompaitable) version of MySQL.
Reply
#10

Can you show us which line is this? ./Source/Properties/House.pwn:877

Also, try placing countHouses++ outside the if statement and see if the number of houses changes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)