06.08.2013, 00:14
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;
}