Can someone help me with sscanf?
#4

pawn Код:
forward Convert(const file[]);
public Convert(const file[])
{
    new File:openfile = fopen(file,io_read);
    if(!openfile) return printf("File %s was not found. Please make sure you have placed it on your ScriptFiles folder.", file);

    new File:newfile = fopen("Objects.pwn",io_write);
    fwrite(newfile, "public OnGameModeInit()\r\n{\r\n");

    new string[350], idx;

    while(fread(openfile, string))
    {
        if(idk >= sizeof(rObj)) break;
        if(!sscanf(string, "'model=\"'p<\">d'posX=\"'p<\">f'posY=\"'p<\">f'posZ=\"'p<\">f'rotX=\"'p<\">f'rotY=\"'p<\">f'rotZ=\"'p<\">f",rObj[idx][modelid_],rObj[idx][x_],rObj[idx][y_],rObj[idx][z_],rObj[idx][rX], rObj[idx][rY], rObj[idx][rZ]))
        {
            format(string,sizeof(string),"\tCreateObject(%d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f);\r\n",rObj[idx][modelid_],rObj[idx][x_],rObj[idx][y_],rObj[idx][z_],rObj[idx][rX], rObj[idx][rY], rObj[idx][rZ]);
            fwrite(newfile,string);
            idx++;
        }
    }
    fwrite(newfile, "\treturn 1;\r\n}");
    fclose(openfile);
    fclose(newfile);
    printf("%d objects were converted from '%s' to Converted.pwn (Saved in Scriptfiles folder)",idx, file);
    return idx;
}
Reply


Messages In This Thread
Can someone help me with sscanf? - by Magic_Time - 05.08.2013, 23:12
Re: Can someone help me with sscanf? - by Jefff - 05.08.2013, 23:24
Re: Can someone help me with sscanf? - by Magic_Time - 05.08.2013, 23:35
Re: Can someone help me with sscanf? - by Jefff - 06.08.2013, 00:14
Re: Can someone help me with sscanf? - by ThePhenix - 06.08.2013, 04:48

Forum Jump:


Users browsing this thread: 1 Guest(s)