Code:
#include <stdio.h>
/*
(1) CreateObject
(2) CreateDynamicObject
(3) XML (MTA)
*/
int inputtype=0;
int outputtype=0;
objecttype()
{
printf("\nValid Object types\n");
printf("CreateObject: (1)\n");
printf("CreateDynamicObject: (2)\n");
printf("XML (MTA): (3)\n");
}
int main ( int argc, char *argv[] )
{
if ( argc != 2 )
{
printf( "Usage: %s [filename]\n", argv[0] );
}
else
{
FILE *fIn = fopen(argv[1], "r");
if ( fIn == 0 )
{
printf( "Could not open file\n" );
}
else
{
int inputtype=0;
int i=0;
int model = 0, items = 0;
float pos[3] = {0}, rot[3] = {0};
objecttype();
printf("\nSpecify input object type:\n");
scanf("%i",&inputtype);
if(inputtype != 1 || inputtype != 2 || inputtype != 3)
{
objecttype();
}
int outputtype=0;
printf("\nSpecify output object type:\n");
scanf("%i",&outputtype);
if(outputtype != 1 || inputtype != 2 || inputtype != 3)
{
objecttype();
}
if(outputtype == inputtype)
{
printf("You cannot convert objects into the same type!");
}
else
{
FILE *fOut = fopen("output.txt", "wb");
if(inputtype == 1)//CreateObject Inputtype
{
while ((items = fscanf(fIn, "%*[^-0123456789]%d%*[,]%f%*[,]%f%*[,]%f%*[,]%f%*[,]%f%*[,]%f%*s", &model, &pos[0], &pos[1], &pos[2], &rot[0], &rot[1], &rot[2])) != EOF)
{
if(outputtype == 3)
{
if (items == 7)
{
fprintf(fOut, "<object id=\"object (Konvert)(%d)\" breakable=\"true\" interior=\"0\" collisions=\"true\" alpha=\"255\" model=\"%d\" doublesided=\"false\" scale=\"1\" dimension=\"0\" posX=\"%.7g\" posY=\"%.7g\" posZ=\"%.7g\" rotX=\"%.7g\" rotY=\"%.7g\" rotZ=\"%.7g\"></object>\n", i,model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]);
}
}
if(outputtype == 2)
{
if (items == 7)
{
fprintf(fOut, "CreateDynamicObject(%d,%f,%f,%f,%f,%f,%f);// Object (%d)\n",model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2],i);
}
}
i++;
}
}
if(inputtype == 2)//CreateDynamicObject Inputtype
{
while ((items = fscanf(fIn, "%*[^-0123456789]%d%*[,]%f%*[,]%f%*[,]%f%*[,]%f%*[,]%f%*[,]%f%*s", &model, &pos[0], &pos[1], &pos[2], &rot[0], &rot[1], &rot[2])) != EOF)
{
if(outputtype == 3)
{
if (items == 7)
{
fprintf(fOut, "<object id=\"object (Konvert)(%d)\" breakable=\"true\" interior=\"0\" collisions=\"true\" alpha=\"255\" model=\"%d\" doublesided=\"false\" scale=\"1\" dimension=\"0\" posX=\"%.7g\" posY=\"%.7g\" posZ=\"%.7g\" rotX=\"%.7g\" rotY=\"%.7g\" rotZ=\"%.7g\"></object>\n", i,model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]);
}
}
if(outputtype == 1)
{
if (items == 7)
{
fprintf(fOut, "CreateObject(%d,%f,%f,%f,%f,%f,%f);// Object (%d)\n",model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2],i);
}
}
i++;
}
}
if(inputtype == 3)//XML Inputtype !!!! NOTE!!!! NOT WORKING
{
while ((items = fscanf(fIn, "%*[^-0123456789 a-zA-Z ><\]%d%f%f%f%f%f%f%",&model, &pos[0], &pos[1], &pos[2], &rot[0], &rot[1], &rot[2])) != EOF)
{
if(outputtype == 3)
{
if (items == 7)
{
fprintf(fOut, "<object id=\"object (Konvert)(%d)\" breakable=\"true\" interior=\"0\" collisions=\"true\" alpha=\"255\" model=\"%d\" doublesided=\"false\" scale=\"1\" dimension=\"0\" posX=\"%.7g\" posY=\"%.7g\" posZ=\"%.7g\" rotX=\"%.7g\" rotY=\"%.7g\" rotZ=\"%.7g\"></object>\n", i,model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]);
}
}
if(outputtype == 2)
{
if (items == 7)
{
fprintf(fOut, "CreateDynamicObjectObject(%d,%f,%f,%f,%f,%f,%f);// Object (%d)\n",model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2],i);
}
}
if(outputtype == 1)
{
if (items == 7)
{
fprintf(fOut, "CreateObject(%d,%f,%f,%f,%f,%f,%f);// Object (%d)\n",model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2],i);
}
}
i++;
}
}
fclose(fOut);
fclose(fIn);
printf("%d Objekt(e) konvertiert.\n\n",i);
return 0;
}
}
}
}
I hope my second post is being activated as well heh.