loading houses
#1

Hi all again,

Im new in MySQL, so I can find where's the problem: Server saves all server houses, but it dont load any house. I added a loaded house count - and its always 0

Function:

pawn Код:
stock LoadHouses( )
{
    mysql_query( "SELECT * FROM `namudb` " );
    mysql_store_result( );
    new
        Query[ 750 ],
        House = 1,
        hCount = 0
    ;
    while( mysql_fetch_row( Query ) == 1 && House < 49 )
    {
        sscanf( Query, "ffffffllls[24]s[24]dddd", NamuDB[ House ][ hIsejimas ][ 0 ], NamuDB[ House ][ hIsejimas ][ 1 ], NamuDB[ House ][ hIsejimas ][ 2 ],
        NamuDB[ House ][ hIeimas ][ 0 ], NamuDB[ House ][ hIeimas ][ 1 ], NamuDB[ House ][ hIeimas ][ 2 ], NamuDB[ House ][ hParduodamas ], NamuDB[ House ][ hUzrakintas ], NamuDB[ House ][ hRaktai ], NamuDB[ House ][ hSavininkas ], NamuDB[ House ][ hRSavininkas ], NamuDB[ House ][ hInterior ], NamuDB[ House ][ hNamoID ], NamuDB[ House ][ hPinigai ],
        NamuDB[ House ][ hKaina ] );

        if( NamuDB[ House ][ hParduodamas ] == 1 )
        {
            format( Query, 157, "{FFFFFF}Рis namas {6EF83C}yra {FFFFFF}parduodamas.\nKaina: {FF0000}$%d\n{FFFFFF}Namo numeris: {FF0000}%d\n", NamuDB[ House ][ hKaina ], NamuDB[ House ][ hNamoID ] );
            NamuDB[ House ][ hText ] = Create3DTextLabel( Query, -1, NamuDB[ House ][ hIsejimas ][ 0 ], NamuDB[ House ][ hIsejimas ][ 1 ], NamuDB[ House ][ hIsejimas ][ 2 ], 25, 0, 0 );
        }
        else
        {
            format( Query, 108, "{FFFFFF}Рis namas {FF0000}nлra {FFFFFF}parduodamas.\n{FFFFFF}Savininkas: {FF0000}%s", NamuDB[ House ][ hSavininkas ] );
            NamuDB[ House ][ hText ] = Create3DTextLabel( Query, -1, NamuDB[ House ][ hIsejimas ][ 0 ], NamuDB[ House ][ hIsejimas ][ 1 ], NamuDB[ House ][ hIsejimas ][ 2 ], 25, 0, 0 );
            if( NamuDB[ House ][ hRaktai ] == 1 )
            {
                format( Query, 108, "{FFFFFF}Рis namas {FF0000}nлra {FFFFFF}parduodamas.\n{FFFFFF}Savininkas: {FF0000}%s\n{FFFFFF}Namo raktus turi: {FFFF00}%s", NamuDB[ House ][ hSavininkas ], NamuDB[ House ][ hRSavininkas ] );
                Update3DTextLabelText( NamuDB[ House ][ hText ], -1, Query );
            }
        }
        hCount ++;
        Itter_Add(fNamai, House);
    }
    mysql_free_result( );
    return printf( "[NAMШ SISTEMA]: Iрviso pakrauta namш - %d", hCount );
}
Reply
#2

Do some debugging, specifically print out the contents of the "Query" variable just before using sscanf.
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Do some debugging, specifically print out the contents of the "Query" variable just before using sscanf.
How can I add any prints, if when I turn on my server its just prints that count of loaded houses is 0? mysql_log = clear
Reply
#4

pawn Код:
//On the top of your function
mysql_debug(1);
//On the end of your function
mysql_debug(0);
Reply
#5

I did that already..

pawn Код:
[00:40:38] >> mysql_ping( Connection handle: 1 )

[00:40:38] CMySQLHandler::Ping() - Connection is still alive.

[00:40:38] >> mysql_query( Connection handle: 1 )

[00:40:38] CMySQLHandler::Query(SELECT * FROM `namudb` ) - Successfully executed.

[00:40:38] >> mysql_store_result( Connection handle: 1 )

[00:40:38] CMySQLHandler::StoreResult() - Result was stored.

[00:40:38] >> mysql_fetch_row_format( Connection handle: 1 )

[00:40:38] >> mysql_free_result( Connection handle: 1 )

[00:40:38] CMySQLHandler::FreeResult() - Result was successfully free'd.

[00:40:41] >> mysql_close( Connection handle: 1 )

[00:40:41] CMySQLHandler::~CMySQLHandler() - deconstructor called.

[00:40:41] CMySQLHandler::FreeResult() - The result is already empty.

[00:40:41] CMySQLHandler::Disconnect() - Connection was closed.
Reply
#6

Quote:
Originally Posted by Gh0sT_
Посмотреть сообщение
How can I add any prints, if when I turn on my server its just prints that count of loaded houses is 0? mysql_log = clear
I explained it already, here is the code containing the print for you:

pawn Код:
stock LoadHouses( )
{
    mysql_query( "SELECT * FROM `namudb` " );
    mysql_store_result( );
    new
        Query[ 750 ],
        House = 1,
        hCount = 0
    ;
    while( mysql_fetch_row( Query ) == 1 && House < 49 )
    {
        printf("House %d || Query: %s", House, Query);
        sscanf( Query, "ffffffllls[24]s[24]dddd", NamuDB[ House ][ hIsejimas ][ 0 ], NamuDB[ House ][ hIsejimas ][ 1 ], NamuDB[ House ][ hIsejimas ][ 2 ],
        NamuDB[ House ][ hIeimas ][ 0 ], NamuDB[ House ][ hIeimas ][ 1 ], NamuDB[ House ][ hIeimas ][ 2 ], NamuDB[ House ][ hParduodamas ], NamuDB[ House ][ hUzrakintas ], NamuDB[ House ][ hRaktai ], NamuDB[ House ][ hSavininkas ], NamuDB[ House ][ hRSavininkas ], NamuDB[ House ][ hInterior ], NamuDB[ House ][ hNamoID ], NamuDB[ House ][ hPinigai ],
        NamuDB[ House ][ hKaina ] );

        if( NamuDB[ House ][ hParduodamas ] == 1 )
        {
            format( Query, 157, "{FFFFFF}Рis namas {6EF83C}yra {FFFFFF}parduodamas.\nKaina: {FF0000}$%d\n{FFFFFF}Namo numeris: {FF0000}%d\n", NamuDB[ House ][ hKaina ], NamuDB[ House ][ hNamoID ] );
            NamuDB[ House ][ hText ] = Create3DTextLabel( Query, -1, NamuDB[ House ][ hIsejimas ][ 0 ], NamuDB[ House ][ hIsejimas ][ 1 ], NamuDB[ House ][ hIsejimas ][ 2 ], 25, 0, 0 );
        }
        else
        {
            format( Query, 108, "{FFFFFF}Рis namas {FF0000}nлra {FFFFFF}parduodamas.\n{FFFFFF}Savininkas: {FF0000}%s", NamuDB[ House ][ hSavininkas ] );
            NamuDB[ House ][ hText ] = Create3DTextLabel( Query, -1, NamuDB[ House ][ hIsejimas ][ 0 ], NamuDB[ House ][ hIsejimas ][ 1 ], NamuDB[ House ][ hIsejimas ][ 2 ], 25, 0, 0 );
            if( NamuDB[ House ][ hRaktai ] == 1 )
            {
                format( Query, 108, "{FFFFFF}Рis namas {FF0000}nлra {FFFFFF}parduodamas.\n{FFFFFF}Savininkas: {FF0000}%s\n{FFFFFF}Namo raktus turi: {FFFF00}%s", NamuDB[ House ][ hSavininkas ], NamuDB[ House ][ hRSavininkas ] );
                Update3DTextLabelText( NamuDB[ House ][ hText ], -1, Query );
            }
        }
        hCount ++;
        Itter_Add(fNamai, House);
    }
    mysql_free_result( );
    return printf( "[NAMШ SISTEMA]: Iрviso pakrauta namш - %d", hCount );
}
Debugging is how we find problems with our script and solve them!
Reply
#7

Oh.

House creating >

[14:26:44] HOUSE CREATED! ID - 1

Houses saving >

[14:31:21] Succesfully saved 1 houses

Houses loading >

[14:32:04] Succesfully loaded 1 houses


And there's no print about query or houseid(I have added before sscanf:

printf( "SOME HOUSE - LOADED. ID: %d AND QUERY: %s", House, Query );
Reply
#8

Try changing your query to:

pawn Код:
while(mysql_fetch_row( Query ) && House < 49 )
Or why do you need to check the house count at all? Just do:

pawn Код:
while( mysql_fetch_row( Query ) )
Reply
#9

K, I will test that a bit later.

Now I can't understand, why GetPlayerIp returns 255.255.255.255 not 127.0.0.1?

Function:

pawn Код:
stock GetPlayerIpEx( playerid )
{
    new
        rIP[ 16 ]
    ;
    GetPlayerIp( playerid, rIP, 16 );
    return rIP;
}
Reply
#10

Under what callback are you using that function and how are you using it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)