[PROBLEM] Splitting rows with sscanf
#1

This is the code I have:
pawn Код:
new Query[80];
    for(new i=0; i < MAX_BIZ; i++)
    {
        format(Query, sizeof(Query), "SELECT * FROM `Business` WHERE 'bID' = '%d' ",i);
        mysql_query(Query);
        mysql_store_result();
        mysql_fetch_row_format(Query, "|");
        sscanf(Query, "e<p<|>iiis[24]iiiffffffffiiiiiis[128]>", BusinessInfo[i]);
        BusinessInfo[i][bOutsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[i][bEntranceX], BusinessInfo[i][bEntranceY], BusinessInfo[i][bEntranceZ], BusinessInfo[i][bWorld]); //Creates a pickup at the business entrance.
        BusinessInfo[i][bInsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[i][bExitX], BusinessInfo[i][bExitY], BusinessInfo[i][bExitZ], BusinessInfo[i][bInsideWorld]); //Creates a pickup at the exit(Inside the interior)
        printf("EntranceX: %f\nEntranceY: %f\nEntranceZ: %f",BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]);
        mysql_free_result();
    }
And the enum:
pawn Код:
enum bInfo {
    bID,
    bOwned,
    bPrice,
    bOwner[MAX_PLAYER_NAME],
    bType,
    bLocked,
    bMoney,
    Float:bEntranceX,
    Float:bEntranceY,
    Float:bEntranceZ,
    Float:bEntranceA,
    Float:bExitX,
    Float:bExitY,
    Float:bExitZ,
    Float:bExitA,
    bInt,
    bWorld,
    bInsideInt,
    bInsideWorld,
    bInsideIcon,
    bOutsideIcon,
    bName[128]
}
When loading, the X,Y and Z positions are always 0 and I have no idea why
Reply
#2

pawn Код:
sscanf(Query, "p<|>e<iiis[24]iiiffffffffiiiiiis[128]>", BusinessInfo[i]);
I might be wrong tho.
Reply
#3

Same, doesn't work.
Reply
#4

Quote:
Originally Posted by zombieking
Посмотреть сообщение
Same, doesn't work.
It's only the floats that don't load ?
Reply
#5

The floats do save correctly but do not load. Other stats load fine.
EDIT: Actually, nothing loads correctly.
Reply
#6

You do know you use 'P' for that now?

At least thats what I read in a update by Y Less
Reply
#7

Quote:
Originally Posted by zombieking
Посмотреть сообщение
The floats do save correctly but do not load. Other stats load fine.
EDIT: Actually, nothing loads correctly.
Maybe the query isn't executed successfully ? Did you try looking into mysql_log ? To see if the query works ? ;-?

@Riddy

"You can now have optional delimiters using "P" (upper case "p" to match other "optional" specifiers). These are optional in the sense that you specify multiple delimiters and any one of them can be used to end the next symbol:"


ps. yea you just told me nothing loads.. did you check mysql_log?

pss. Try changing your query to

pawn Код:
SELECT * FROM `Business` WHERE bID = %d
Reply
#8

Nothing loads correctly, not even the integers
EDIT: Just saw your post:
Код:
CMySQLHandler::Query(SELECT * FROM `Business` WHERE 'bID' = '1' ) - Successfully executed.

[21:02:07] >> mysql_store_result( Connection handle: 1 )
That's exactly how my query looks like.

EDIT: Changing my query to what you suggested works! Thank you very much! +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)