mysql_retrieve_row()
#1

i am not sure about how this work in R7+, anyone know how i can get my custom housescript to work?
here is my code:
new(that i cant get to work)
pawn Код:
public LoadHouses()
{
    new savingstring[20], houseid;
    while(mysql_retrieve_row())
    {
        cache_get_field_content(0, "id", savingstring); houseid = strval(savingstring);
        cache_get_field_content(0, "iconx", savingstring); hInfo[houseid][iconx] = floatstr(savingstring);
        cache_get_field_content(0, "icony", savingstring); hInfo[houseid][icony] = floatstr(savingstring);
        cache_get_field_content(0, "iconz", savingstring); hInfo[houseid][iconz] = floatstr(savingstring);
        cache_get_field_content(0, "interiorX", savingstring); hInfo[houseid][InteriorX] = floatstr(savingstring);
        cache_get_field_content(0, "interiorY", savingstring); hInfo[houseid][InteriorY] = floatstr(savingstring);
        cache_get_field_content(0, "interiorZ", savingstring); hInfo[houseid][InteriorZ] = floatstr(savingstring);
        cache_get_field_content(0, "interior", savingstring); hInfo[houseid][Interior] = strval(savingstring);
        cache_get_field_content(0, "price", savingstring); hInfo[houseid][Cost] = strval(savingstring);
        cache_get_field_content(0, "sellprice", savingstring); hInfo[houseid][Sell] = strval(savingstring);
        cache_get_field_content(0, "virtualworld", savingstring); hInfo[houseid][Virtualworld] = strval(savingstring);
        cache_get_field_content(0, "locked", savingstring); hInfo[houseid][Locked] = strval(savingstring);
        if(strcmp(hInfo[houseid][HName],"ForSale",true)==0)
        {
            HousePickup[houseid] = CreatePickup(1273, 23, hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz]);//not bought
            HouseIcon[houseid] = CreateDynamicMapIcon(hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz], 31, 0, 0, 0, -1, 300.0);
        }
        else
        {
            HousePickup[houseid] = CreatePickup(1272, 23, hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz]);//bought
            HouseIcon[houseid] = CreateDynamicMapIcon(hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz], 32, 0, 0, 0, -1, 300.0);
        }
        printf("Loaded house %d Owner: %s", houseid, hInfo[houseid][HName]);
    }
    return 1;
}
The problem is that it doesnt load row 0 as it should

OLD(that worked):
pawn Код:
public LoadHouses()//acctully it was a stock in the old
{
    new savingstring[20], houseid;
    mysql_query("SELECT * FROM houses");
    mysql_store_result();
    while(mysql_retrieve_row())
    {
        mysql_fetch_field_row(savingstring, "id"); houseid = strval(savingstring);
        mysql_fetch_field_row(savingstring, "iconx"); hInfo[houseid][iconx] = floatstr(savingstring);
        mysql_fetch_field_row(savingstring, "icony"); hInfo[houseid][icony] = floatstr(savingstring);
        mysql_fetch_field_row(savingstring, "iconz"); hInfo[houseid][iconz] = floatstr(savingstring);
        mysql_fetch_field_row(savingstring, "interiorX"); hInfo[houseid][InteriorX] = floatstr(savingstring);
        mysql_fetch_field_row(savingstring, "interiorY"); hInfo[houseid][InteriorY] = floatstr(savingstring);
        mysql_fetch_field_row(savingstring, "interiorZ"); hInfo[houseid][InteriorZ] = floatstr(savingstring);
        mysql_fetch_field_row(savingstring, "interior"); hInfo[houseid][Interior] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "price"); hInfo[houseid][Cost] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "sellprice"); hInfo[houseid][Sell] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "virtualworld"); hInfo[houseid][Virtualworld] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "locked"); hInfo[houseid][Locked] = strval(savingstring);
        mysql_fetch_field_row(hInfo[houseid][HName], "owner");
        if(strcmp(hInfo[houseid][HName],"ForSale",true)==0)
        {
            HousePickup[houseid] = CreatePickup(1273, 23, hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz]);//not bought
            HouseIcon[houseid] = CreateDynamicMapIcon(hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz], 31, 0, 0, 0, -1, 300.0);
        }
        else
        {
            HousePickup[houseid] = CreatePickup(1272, 23, hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz]);//bought
            HouseIcon[houseid] = CreateDynamicMapIcon(hInfo[houseid][iconx], hInfo[houseid][icony], hInfo[houseid][iconz], 32, 0, 0, 0, -1, 300.0);
        }
        printf("Loaded house %d Owner: %s", houseid, hInfo[houseid][HName]);
    }
    mysql_free_result();
    return 1;
}
Reply
#2

You only need use the cache_* functions if the cache is enabled.
pawn Код:
new
    rows,
    fields;

cache_get_data(rows, fields);

for(new i; i < rows; i++)
{
    // load row data
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)