SA-MP Forums Archive
Help MySQL rows - 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: Help MySQL rows (/showthread.php?tid=499785)



Help MySQL rows - shulk - 09.03.2014

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;
}



Re: Help MySQL rows - shulk - 10.03.2014

Anybody know the problem?


AW: Help MySQL rows - Macronix - 10.03.2014

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)


Re: AW: Help MySQL rows - Vince - 10.03.2014

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 );
    }
}



Re: Help MySQL rows - shulk - 10.03.2014

Thanks Rep+, Can i kiss you? :*