Help MySQL rows
#1

Hey, when i load it dont work... Just load me the first interior in the databes... I dont know the problem..
Under the OnGameModeInit i have the:

pawn Code:
mysql_function_query( dbHandle,"SELECT * FROM db_interiors", true, "CheckInterior", "" );
pawn Code:
function CheckInterior() {

    new
        rows,
        fields;

    cache_get_data( rows, fields );
    if( !rows )
    {
        print( "[WARNING][MySQL] Nije moguce pronaci podatke za Interiore!( no interiors )" );
    }
    else
    {
        InteriorInfo[ rows ][ iVirtualWorld ] = cache_get_field_content_int( 0, "iVirtualWorld" );
        InteriorInfo[ rows ][ iType ] = cache_get_field_content_int( 0, "iType" );
        InteriorInfo[ rows ][ iX ] = cache_get_field_content_float( 0, "iX" );
        InteriorInfo[ rows ][ iY ] = cache_get_field_content_float( 0, "iY" );
        InteriorInfo[ rows ][ iZ ] = cache_get_field_content_float( 0, "iZ" );

        AddStaticPickup( INTERIOR_PICKUP, INTERIOR_PICKUP_TYPE, InteriorInfo[ rows ][ iX ], InteriorInfo[ rows ][ iY ], InteriorInfo[ rows ][ iZ ], INTERIOR_PICKUP_VIRTUAL_WORLD );
    }

    return true;
}
Reply
#2

Anybody know the problem?
Reply
#3

Mh, you should specifiy an individual ID for every interior and then load it through a loop, something like CheckInterior(interiorid).
The mysql query has to be "SELECT * FROM db_interiors WHERE id = %d" in a for-loop, where the %d is replaced by i from the loop (the unique interior ID)
Reply
#4

Quote:
Originally Posted by Macronix
View Post
Mh, you should specifiy an individual ID for every interior and then load it through a loop, something like CheckInterior(interiorid).
The mysql query has to be "SELECT * FROM db_interiors WHERE id = %d" in a for-loop, where the %d is replaced by i from the loop (the unique interior ID)
Not at all! This is the absolute WORST way to load data. You merely need a loop to go through the results;

pawn Code:
if( !rows )
{
    print( "[WARNING][MySQL] Nije moguce pronaci podatke za Interiore!( no interiors )" );
}
else
{
    for(new i; i < rows; i++)
    {
        InteriorInfo[ i ][ iVirtualWorld ] = cache_get_field_content_int( i, "iVirtualWorld" );
        InteriorInfo[ i ][ iType ] = cache_get_field_content_int( i, "iType" );
        InteriorInfo[ i ][ iX ] = cache_get_field_content_float( i, "iX" );
        InteriorInfo[ i ][ iY ] = cache_get_field_content_float( i, "iY" );
        InteriorInfo[ i ][ iZ ] = cache_get_field_content_float( i, "iZ" );

        AddStaticPickup( INTERIOR_PICKUP, INTERIOR_PICKUP_TYPE, InteriorInfo[ i ][ iX ], InteriorInfo[ i ][ iY ], InteriorInfo[ i ][ iZ ], INTERIOR_PICKUP_VIRTUAL_WORLD );
    }
}
Reply
#5

Thanks Rep+, Can i kiss you? :*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)