05.08.2013, 23:12
Hi,
Sorry for my ignorance at sscanf.
I'm trying to make a converter from MTA code to samp but it doesn't work..
Sorry for my ignorance at sscanf.
I'm trying to make a converter from MTA code to samp but it doesn't work..
PHP код:
forward Convert(file[]);
public Convert(file[])
{
if (!fexist(file)) return printf("File %s was not found. Please make sure you have placed it on your ScriptFiles folder.", file);
new File:openfile = fopen(file);
new string[4000], string2[4000], playerid, objcount;
while(fread(openfile, string))
{
for(new idk = 0; idk < sizeof(rObj); idk++)
{
if(!sscanf(string, "'model='d'posX='f'posY='f'posZ='f'rX='f'rY='f'rZ='f",rObj[idk][modelid_],rObj[idk][x_],rObj[idk][y_],rObj[idk][z_],rObj[idk][rX], rObj[idk][rY], rObj[idk][rZ]))
{
objcount++;
new File:newfile = fopen("Objects.pwn",io_write);
fwrite(newfile, "public OnGameModeInit()\n{\n");
format(string,sizeof(string)," CreateObject(%d, %f, %f, %f, %f, %f, %f);\n",rObj[idk][modelid_], rObj[idk][x_], rObj[idk][y_], rObj[idk][z_], rObj[idk][rX], rObj[idk][rY], rObj[idk][rZ]);
strcat(string2,string);
printf("%s", string);
fwrite(newfile,string2);
fwrite(newfile, " return 1;\n}");
fclose(newfile);
}
}
}
fclose(openfile);
printf("%d objects were converted from '%s' to Converted.pwn (Saved in Scriptfiles folder)",objcount, file);
return objcount;
}