Sscanf not splitting string according to Variables
#1

Code:
pawn Код:
for(new i=0;i<5;i++)
    {
        Toys[playerid][i][IsUsed] = 1;
        format(Toys[playerid][i][utoyname],30,"None");
        format(Query,sizeof(Query),"SELECT `Code` FROM `Toys` WHERE `Username` = '%s' AND `Slot` = %d LIMIT 1",PlayerName(playerid),i);
        mysql_query(Query);
        mysql_store_result();
        if(mysql_num_rows())
        {
            mysql_fetch_row(Query);
            sscanf(Query,"p<,>dffffffds",
            Toys[playerid][i][utObjectID],
            Toys[playerid][i][utx],
            Toys[playerid][i][uty],
            Toys[playerid][i][utz],
            Toys[playerid][i][utrx],
            Toys[playerid][i][utry],
            Toys[playerid][i][utrz],
            Toys[playerid][i][utbone],
            Toys[playerid][i][utoyname]);
            Toys[playerid][i][IsUsed] = 1;
           
            //DEBUG
            printf("Slot: %d | Obj: %d | Pos: %f %f %f | Rotation: %f %f %f | Bone: %d | Name: %s",i,Toys[playerid][i][utObjectID],
            Toys[playerid][i][utx],
            Toys[playerid][i][uty],
            Toys[playerid][i][utz],
            Toys[playerid][i][utrx],
            Toys[playerid][i][utry],
            Toys[playerid][i][utrz],
            Toys[playerid][i][utbone],
            Toys[playerid][i][utoyname]);
        }
        mysql_free_result();
    }
Data sent from MySQL.
Код:
[21:16:56] CMySQLHandler::Query(SELECT `Code` FROM `Toys` WHERE `Username` = '[MG]Dimi' AND `Slot` = 0 LIMIT 1) - Successfully executed.
[21:16:56] >> mysql_store_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::StoreResult() - Result was stored.
[21:16:56] >> mysql_num_rows( Connection handle: 1 )
[21:16:56] CMySQLHandler::NumRows() - Returned 1 row(s)
[21:16:56] >> mysql_fetch_row_format( Connection handle: 1 )
[21:16:56] CMySQLHandler::FetchRow() - Return: 18636,0.000,0.000,0.000,0.000,0.000,0.000,2,PoliceCap1
[21:16:56] >> mysql_free_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::FreeResult() - Result was successfully free'd.
[21:16:56] >> mysql_query( Connection handle: 1 )
[21:16:56] CMySQLHandler::Query(SELECT `Code` FROM `Toys` WHERE `Username` = '[MG]Dimi' AND `Slot` = 1 LIMIT 1) - Successfully executed.
[21:16:56] >> mysql_store_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::StoreResult() - Result was stored.
[21:16:56] >> mysql_num_rows( Connection handle: 1 )
[21:16:56] CMySQLHandler::NumRows() - Returned 1 row(s)
[21:16:56] >> mysql_fetch_row_format( Connection handle: 1 )
[21:16:56] CMySQLHandler::FetchRow() - Return: 346,0.000,0.000,0.000,0.000,0.000,0.000,8,9mm
[21:16:56] >> mysql_free_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::FreeResult() - Result was successfully free'd.
[21:16:56] >> mysql_query( Connection handle: 1 )
[21:16:56] CMySQLHandler::Query(SELECT `Code` FROM `Toys` WHERE `Username` = '[MG]Dimi' AND `Slot` = 2 LIMIT 1) - Successfully executed.
[21:16:56] >> mysql_store_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::StoreResult() - Result was stored.
[21:16:56] >> mysql_num_rows( Connection handle: 1 )
[21:16:56] CMySQLHandler::NumRows() - Returned 1 row(s)
[21:16:56] >> mysql_fetch_row_format( Connection handle: 1 )
[21:16:56] CMySQLHandler::FetchRow() - Return: 355,0.000,0.000,0.000,0.000,0.000,0.000,1,AK47
[21:16:56] >> mysql_free_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::FreeResult() - Result was successfully free'd.
[21:16:56] >> mysql_query( Connection handle: 1 )
[21:16:56] CMySQLHandler::Query(SELECT `Code` FROM `Toys` WHERE `Username` = '[MG]Dimi' AND `Slot` = 3 LIMIT 1) - Successfully executed.
[21:16:56] >> mysql_store_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::StoreResult() - Result was stored.
[21:16:56] >> mysql_num_rows( Connection handle: 1 )
[21:16:56] CMySQLHandler::NumRows() - Returned 0 row(s)
[21:16:56] >> mysql_free_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::FreeResult() - Result was successfully free'd.
[21:16:56] >> mysql_query( Connection handle: 1 )
[21:16:56] CMySQLHandler::Query(SELECT `Code` FROM `Toys` WHERE `Username` = '[MG]Dimi' AND `Slot` = 4 LIMIT 1) - Successfully executed.
[21:16:56] >> mysql_store_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::StoreResult() - Result was stored.
[21:16:56] >> mysql_num_rows( Connection handle: 1 )
[21:16:56] CMySQLHandler::NumRows() - Returned 0 row(s)
[21:16:56] >> mysql_free_result( Connection handle: 1 )
[21:16:56] CMySQLHandler::FreeResult() - Result was successfully free'd.
Debug:
Код:
[21:16:56] Slot: 0 | Obj: 0 | Pos: 0.000000 0.000000 0.000000 | Rotation: 0.000000 0.000000 0.000000 | Bone: 0 | Name: None
[21:16:56] Slot: 1 | Obj: 0 | Pos: 0.000000 0.000000 0.000000 | Rotation: 0.000000 0.000000 0.000000 | Bone: 0 | Name: None
[21:16:56] Slot: 2 | Obj: 0 | Pos: 0.000000 0.000000 0.000000 | Rotation: 0.000000 0.000000 0.000000 | Bone: 0 | Name: None
From Log and Debug I can determine sscanf is problem. Any solutions?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)