Sscanf Not Stopping At Delimiter (I Think)
#1

I'm new to sscanf, so I'm not sure what exactly is going on, but it looks like first string isn't stopping at the delimiter.

Everything after the first string is being skipped until the very end, which applies cUnused to cParkTicket.

pawn Код:
sscanf(row, "p<|>e<ddffffdds[64]ds[15]ddddddddddddddddddds[64]d>", CarInfo[carid]);
Enum:
pawn Код:
enum cInfo
{
    cID,
    cModel,
    Float:cLocationx,
    Float:cLocationy,
    Float:cLocationz,
    Float:cAngle,
    cColorOne,
    cColorTwo,
    cOwner[MAX_PLAYER_NAME],
    cOwned,
    cPlate[15],
    cLock,
    cPaintjob,
    cVirWorld,
    cUnused,
    cComponent0,
    cComponent1,
    cComponent2,
    cComponent3,
    cComponent4,
    cComponent5,
    cComponent6,
    cComponent7,
    cComponent8,
    cComponent9,
    cComponent10,
    cComponent11,
    cComponent12,
    cComponent13,
    cCode,
    cTicketer[MAX_PLAYER_NAME],
    cParkTicket
};

new CarInfo[MAX_VEHICLES][cInfo];
Any help is greatly appreciated.

EDIT: I know it's sscanf, as I have it print the row from the SQL query with print(row); and it's printing it correctly.
Reply
#2

Here's the whole thing:
pawn Код:
public LoadCar()
{
    mysql_query("SELECT * FROM samp_vehicles");
    mysql_store_result();
    new row[4000], carid;
    while(mysql_fetch_row(row))
    {
        carid ++;
        sscanf(row, "p<|>e<ddffffdds[64]ds[15]ddddddddddddddddddds[64]d>", CarInfo[carid]);
        ownedcar[carid] = AddStaticVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz], CarInfo[carid][cColorOne], CarInfo[carid][cColorTwo],100);  
        if(CarInfo[carid][cPaintjob] != 999)
        {
            ChangeVehiclePaintjob(carid, CarInfo[carid][cPaintjob]);
        }
        SetVehicleVirtualWorld(carid, CarInfo[carid][cVirWorld]);
        SetVehicleNumberPlate(carid, CarInfo[carid][cPlate]);
        SetVehicleModifications(carid);
        print(row);
    }
    mysql_free_result();
   
    print("[SCRIPT]: Loaded Cars");
    return 1;
}
an example of a row:
1|520|1200|100|344|90|0|0|Josh|1|plate|1|999|0|0|1 0|11|12|13|14|15|16|17|18|19|20|21|22|23|1234|Bob| 9000
Reply
#3

I know. I'm asking what the correct way would be, as this is the first time using sscanf, and I'm not sure which specifier you mean.
Reply
#4

Yes! Thank you very much! Didn't realize the string length had to match.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)