Mysql Loading
#1

I have this code:

pawn Код:
stock LoadBusiness()
{
    new Query[400]; new string[128];
    for(new id = 1; id < MAX_BUSINESS; id++)
    {
        format(Query, sizeof(Query), "SELECT * From Business WHERE ID = %d", id);
        mysql_query(Query);
        mysql_store_result();
        if(mysql_num_rows())
        if(mysql_fetch_row_format(Query,"|"))
        {
            sscanf(Query, "p<|>is[32]ddffffffiid", BusinessInfo[id][ID], BusinessInfo[id][Name], BusinessInfo[id][Type], BusinessInfo[id][BBank], BusinessInfo[id][Posx], BusinessInfo[id][Posy], BusinessInfo[id][Posz], BusinessInfo[id][EPosx], BusinessInfo[id][EPosy], BusinessInfo[id][EPosz], BusinessInfo[id][Price]);
            Total_Business_Created++;
            printf("Business: %d",Total_Business_Created);
            format(string, sizeof(string), "%s \nPrice: %d \nEnter by using 'Crouch'",BusinessInfo[id][Name],BusinessInfo[id][Price]);
            BusinessInfo[id][LabelID] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BusinessInfo[id][Posx],BusinessInfo[id][Posy],BusinessInfo[id][Posz], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
            BusinessInfo[id][PickupID] = CreateDynamicPickup(1239, 23, BusinessInfo[id][Posx],BusinessInfo[id][Posy],BusinessInfo[id][Posz], 0, 0, -1, 250);

        }
    }
    return 1;
}
In the 3D text, it only shows the name, not the price. So somehow the price isn't loading, i added a printf under the loading to test, and it always come out as 0, how could I fix this?
Reply
#2

I think what causes it not to is, because there are two useless integers which might cause it.
pawn Код:
sscanf(Query, "p<|>is[32]iiffffffi", BusinessInfo[id][ID], BusinessInfo[id][Name], BusinessInfo[id][Type], BusinessInfo[id][BBank], BusinessInfo[id][Posx], BusinessInfo[id][Posy], BusinessInfo[id][Posz], BusinessInfo[id][EPosx], BusinessInfo[id][EPosy], BusinessInfo[id][EPosz], BusinessInfo[id][Price]);
Reply
#3

Args, Thank you, Yet again another simple issue, I forgot I removed two variables i wasn't using, forgot to edit the sscanf, I should script more carefully.
Reply
#4

Quote:
Originally Posted by Abreezy
Посмотреть сообщение
Args, Thank you, Yet again another simple issue, I forgot I removed two variables i wasn't using, forgot to edit the sscanf, I should script more carefully.
Yes, that is the annoying part when scripting, simple issues that aren't visible well and like making our lives hard.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)