SA-MP Forums Archive
MySQL - not loading houses. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL - not loading houses. (/showthread.php?tid=502720)



MySQL - not loading houses. - Zeppo - 25.03.2014

Okay, so when I restart my server, the houses don't load and I can't find out why..
pawn Код:
LoadHouses()
{
    mysql_function_query(MySQLConnection, "SELECT * FROM `houses`", false, "HouseInformation", "i", THREAD_NO_RESULT);
    return true;
}
pawn Код:
forward HouseInformation(houseid);
public HouseInformation(houseid)
{
    cache_get_data(rows, fields);
    if(rows > 0)
    {
        for(new i = 0; i < rows; i++)
        {
            HouseInfo[i][HouseID] = cache_get_row_int(i, 0, MySQLConnection);
            cache_get_row(i, 1, HouseInfo[i][Owner], MySQLConnection, 24);
            HouseInfo[i][HouseEX] = cache_get_row_float(i, 2, MySQLConnection);
            HouseInfo[i][HouseEY] = cache_get_row_float(i, 3, MySQLConnection);
            HouseInfo[i][HouseEZ] = cache_get_row_float(i, 4, MySQLConnection);
            HouseInfo[i][HouseIX] = cache_get_row_float(i, 5, MySQLConnection);
            HouseInfo[i][HouseIY] = cache_get_row_float(i, 6, MySQLConnection);
            HouseInfo[i][HouseIZ] = cache_get_row_float(i, 7, MySQLConnection);
            HouseInfo[i][Weed] = cache_get_row_int(i, 8, MySQLConnection);
            HouseInfo[i][Money] = cache_get_row_int(i, 9, MySQLConnection);
            HouseInfo[i][Locked] = cache_get_row_int(i, 10, MySQLConnection);
            HouseInfo[i][Price] = cache_get_row_int(i, 11, MySQLConnection);
            HouseInfo[i][Interior] = cache_get_row_int(i, 12, MySQLConnection);
           
           
        }
    }
    return true;
}



Re: MySQL - not loading houses. - newbienoob - 25.03.2014

set the cache to true


Re: MySQL - not loading houses. - Zeppo - 25.03.2014

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
set the cache to true
Nope, still not. Help?


Re: MySQL - not loading houses. - Zeppo - 25.03.2014

Anyone?


Re: MySQL - not loading houses. - Konstantinos - 25.03.2014

You need cache and no arguments since you select all of them and use a loop later.

pawn Код:
stock LoadHouses()
{
    mysql_function_query(MySQLConnection, "SELECT * FROM houses", true, "OnHousesLoad", "");
}

forward OnHousesLoad();
public OnHousesLoad()
{
    new irows, ifields; // better as local
    cache_get_data(irows, ifields);
    for(new i = 0; i < rows; i++)
    {
        HouseInfo[i][HouseID] = cache_get_row_int(i, 0, MySQLConnection);
        cache_get_row(i, 1, HouseInfo[i][Owner], MySQLConnection, 24);
        HouseInfo[i][HouseEX] = cache_get_row_float(i, 2, MySQLConnection);
        HouseInfo[i][HouseEY] = cache_get_row_float(i, 3, MySQLConnection);
        HouseInfo[i][HouseEZ] = cache_get_row_float(i, 4, MySQLConnection);
        HouseInfo[i][HouseIX] = cache_get_row_float(i, 5, MySQLConnection);
        HouseInfo[i][HouseIY] = cache_get_row_float(i, 6, MySQLConnection);
        HouseInfo[i][HouseIZ] = cache_get_row_float(i, 7, MySQLConnection);
        HouseInfo[i][Weed] = cache_get_row_int(i, 8, MySQLConnection);
        HouseInfo[i][Money] = cache_get_row_int(i, 9, MySQLConnection);
        HouseInfo[i][Locked] = cache_get_row_int(i, 10, MySQLConnection);
        HouseInfo[i][Price] = cache_get_row_int(i, 11, MySQLConnection);
        HouseInfo[i][Interior] = cache_get_row_int(i, 12, MySQLConnection);
    }
}



Re: MySQL - not loading houses. - Zeppo - 25.03.2014

Nope, still not loading.


Re: MySQL - not loading houses. - iZN - 25.03.2014

Quote:
Originally Posted by Zeppo
Посмотреть сообщение
Nope, still not loading.
Post your MySQL debug.


Re: MySQL - not loading houses. - Zeppo - 25.03.2014

Код:
[20:22:43] [WARNING] cache_get_data - no active cache
[20:23:03] [ERROR] CMySQLQuery::Execute[Query] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`, `Cash` = 3500, `Accounts` SET `Admin` = 5, `HouseID` = 0 WHE' at line 1
I've fixed the second one.


Re: MySQL - not loading houses. - Zeppo - 25.03.2014

It seems to be from this:
pawn Код:
forward OnHousesLoad();
public OnHousesLoad()
{
    new irows, ifields;
    cache_get_data(irows, ifields);
    for(new i = 0; i < irows; i++)
    {
        HouseInfo[i][HouseID] = cache_get_row_int(i, 0, MySQLConnection);
        cache_get_row(i, 1, HouseInfo[i][Owner], MySQLConnection, 24);
        HouseInfo[i][HouseEX] = cache_get_row_float(i, 2, MySQLConnection);
        HouseInfo[i][HouseEY] = cache_get_row_float(i, 3, MySQLConnection);
        HouseInfo[i][HouseEZ] = cache_get_row_float(i, 4, MySQLConnection);
        HouseInfo[i][HouseIX] = cache_get_row_float(i, 5, MySQLConnection);
        HouseInfo[i][HouseIY] = cache_get_row_float(i, 6, MySQLConnection);
        HouseInfo[i][HouseIZ] = cache_get_row_float(i, 7, MySQLConnection);
        HouseInfo[i][Weed] = cache_get_row_int(i, 8, MySQLConnection);
        HouseInfo[i][Money] = cache_get_row_int(i, 9, MySQLConnection);
        HouseInfo[i][Locked] = cache_get_row_int(i, 10, MySQLConnection);
        HouseInfo[i][Price] = cache_get_row_int(i, 11, MySQLConnection);
        HouseInfo[i][Interior] = cache_get_row_int(i, 12, MySQLConnection);
    }
}



Re: MySQL - not loading houses. - Zeppo - 28.03.2014

anyone?