Fread to MYSQL
#1

Hello everyone!

What i'm trying to do, is convert this piece of code into mysql...
pawn Код:
new string[64];
    new File:handle, count;
    new filename[64], line[256], s, key[64];
    for(new i=1; i < MAX_DVEHICLES; i++)
    {
        format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", i);
        if(!fexist(filename)) continue;
        handle = fopen(filename, io_read);
        while(fread(handle, line))
        {
            StripNL(line);
            s = strfind(line, "=");
            if(!line[0] || s < 1) continue;
            strmid(key, line, 0, s++);
            if(strcmp(key, "Created") == 0) VehicleCreated[i] = strval(line[s]);
            else if(strcmp(key, "Model") == 0) VehicleModel[i] = strval(line[s]);
            else if(strcmp(key, "Pos") == 0) sscanf(line[s], "p,ffff", VehiclePos[i][0], VehiclePos[i][1],
                VehiclePos[i][2], VehiclePos[i][3]);
            else if(strcmp(key, "Colors") == 0) sscanf(line[s], "p,dd", VehicleColor[i][0], VehicleColor[i][1]);
            else if(strcmp(key, "Interior") == 0) VehicleInterior[i] = strval(line[s]);
            else if(strcmp(key, "VirtualWorld") == 0) VehicleWorld[i] = strval(line[s]);
            else if(strcmp(key, "Owner") == 0) strmid(VehicleOwner[i], line, s, sizeof(line));
            else if(strcmp(line, "NumberPlate=", false, 12) == 0) strmid(VehicleNumberPlate[i], line, 12, sizeof(line));
            else if(strcmp(key, "Value") == 0) VehicleValue[i] = strval(line[s]);
            else if(strcmp(key, "Trunk1") == 0) sscanf(line[s], "p,dd", VehicleTrunk[i][0][0], VehicleTrunk[i][0][1]);
            else if(strcmp(key, "Trunk2") == 0) sscanf(line[s], "p,dd", VehicleTrunk[i][1][0], VehicleTrunk[i][1][1]);
            else if(strcmp(key, "Trunk3") == 0) sscanf(line[s], "p,dd", VehicleTrunk[i][2][0], VehicleTrunk[i][2][1]);
            else if(strcmp(key, "Trunk4") == 0) sscanf(line[s], "p,dd", VehicleTrunk[i][3][0], VehicleTrunk[i][3][1]);
            else if(strcmp(key, "Trunk5") == 0) sscanf(line[s], "p,dd", VehicleTrunk[i][4][0], VehicleTrunk[i][4][1]);
            else if(strcmp(key, "Mod0") == 0) VehicleMods[i][0] = strval(line[s]);
            else if(strcmp(key, "Mod1") == 0) VehicleMods[i][1] = strval(line[s]);
This piece of code is from mademan's AVS system.
I Started something but everything i try today doesn't seem to work..

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)