Cache_get_row does not get anything!
#1

Hello so i have this:
pawn Код:
forward OnPlayerHousesVehiclesLoad(playerid, houseid_);
public OnPlayerHousesVehiclesLoad(playerid, houseid_)
{
    printf( "OnPlayerHousesVehiclesLoad::houseid_ = %d", houseid_ );
    new rows, fields;
    cache_get_data( rows, fields, Handle );

    if( rows )
    {
        print("There are rows - Vehicles");
        new
        idx = 0,
        cmodel2, Float: cx2, Float: cy2, Float: cz2, Float: crot2, ccol1, ccol2, _carid
        ;
        while( rows > idx )
        {
            _carid = cache_get_row_int(idx, 2);
            cmodel2 = cache_get_row_int( idx, 3 );
            cx2 = cache_get_row_float( idx, 4 );
            cy2 = cache_get_row_float( idx, 5 );
            cz2 = cache_get_row_float( idx, 6 );
            crot2 = cache_get_row_float( idx, 7 );
            ccol1 = cache_get_row_int( idx, 8 );
            ccol2 = cache_get_row_int( idx, 9 );

            printf("House_AddVehicle(%d,%d,%f,%f,%f,%f,%d,%d, %d);", houseid_, cmodel2, cx2, cy2, cz2, crot2, ccol1, ccol2, _carid);
            House_AddVehicle(houseid_, cmodel2, cx2, cy2, cz2, crot2, ccol1, ccol2, _carid);
            print("Car loaded");

            idx++;
        }
    }
    return 1;
}
Now this line doesnt work:
Код:
		_carid = cache_get_row_int(idx, 2);
But the problem is _Carid is always zero while theres a 0 and a 1 in the database:


Uploaded with ImageShack.us
Reply
#2

Show your select query too

#e: Or are you using simply SELECT * FROM table?
Reply
#3

pawn Код:
forward OnPlayerHousesLoad(playerid);
public OnPlayerHousesLoad(playerid)
{
    new
        rows,
        fields
    ;
    cache_get_data( rows, fields, Handle );

    if( rows )
    {
        print("There are rows - Houses"); // Debugging
        new idx = 0, string[128];
        while( rows > idx )
        {
            APlayerData[playerid][Houses][idx] = cache_get_row_int( idx, 0 );
            format(string, sizeof(string), "SELECT * FROM `Vehicles` WHERE `HouseID`= %d", APlayerData[playerid][Houses][idx]);
            mysql_function_query( Handle, string, true, "OnPlayerHousesVehiclesLoad", "dd", playerid, APlayerData[playerid][Houses][idx] );
            idx++;
        }
    }
    return 1;
}
Reply
#4

Fields indexes start from 0. On 2 you have owner name

pawn Код:
_carid = cache_get_row_int(idx, 2);
//change it to
_carid = cache_get_row_int(idx, 1);
Reply
#5

Thank you so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)