Right now i finished the first version of my small and tiny offline object converter for SA:MP/MTA:SA, because our favourite map converter convertffs.com is dead.
The purpose of this program and tutorial is to create a simple object converter for myself but now i want to share it, maybe its useful for someone
Another reason is the huge amount of objects i want to convert and the conversion by using online converters takes a huge amount of time due to the upload/download speed of the client.Its meant to be a commandline tool because i love simple stuff and i love SSH/CMD so why not?
Most online converters were not able to convert more than 5000 objects because they stop working or you get some connection timeout because of the slow upload.
So i decided to create a small C based converter by using fscanf and sscanf to parse the values out of the input and convert it into the desired output.
My tool is available for Linux and Windows at the moment, a Mac OSX version is not planned.
Note! This program is in Beta state so it may contain bugs, please report them if you encounter any malfunction.
You can report bugs via E-Mail: webmaster@knogleinsi.de or by replying in this topic.
I did not pay attention of efficieny because even with 100.000 objects in worst case, meaning MTA:SA to SA:MP the average time for a conversion is around 1.6 seconds.
The execution time of this program is O(3n) in best case and O(6n) in the worst case (MTA:SA (XML) to SA:MP CreateObject)
The goal is to support features like the conversion of Vehicles,Peds/Actors, Pickups and more, like the MapConverter Plugin you can find in here.
I also want to cover more types of objects.
And the most important reason: I dont want to spent all my time, uploading and converting it somewhere.
Usage of this tool is quite simple.
Let’s check the readme..
[pastacode lang=”markdown” manual=”%20Copyright%20(C)%202017%20Fabian%20Druschke%20(Knogle)%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%20%20%20%20This%20program%20is%20free%20software%3A%20you%20can%20redistribute%20it%20and%2For%20modify%0A%20%20%20%20%20%20%20%20it%20under%20the%20terms%20of%20the%20GNU%20General%20Public%20License%20as%20published%20by%0A%20%20%20%20%20%20%20%20the%20Free%20Software%20Foundation%2C%20either%20version%203%20of%20the%20License%2C%20or%0A%20%20%20%20%20%20%20%20(at%20your%20option)%20any%20later%20version.%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%20%20%20%20This%20program%20is%20distributed%20in%20the%20hope%20that%20it%20will%20be%20useful%2C%0A%20%20%20%20%20%20%20%20but%20WITHOUT%20ANY%20WARRANTY%3B%20without%20even%20the%20implied%20warranty%20of%0A%20%20%20%20%20%20%20%20MERCHANTABILITY%20or%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE.%20%20See%20the%0A%20%20%20%20%20%20%20%20GNU%20General%20Public%20License%20for%20more%20details.%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%20%20%20%20You%20should%20have%20received%20a%20copy%20of%20the%20GNU%20General%20Public%20License%0A%20%20%20%20%20%20%20%20along%20with%20this%20program.%20%20If%20not%2C%20see%20%3Chttp%3A%2F%2Fwww.gnu.org%2Flicenses%2F%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20Compiler%20settings%3A%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20Linux%3A%20gcc%20simpleconverter.c%0A%20%20%20%20Windows%20MinGW%3A%20gcc%20simpleconverter.c%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20Usage%3A%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20Linux%3A%20.%2Fa.out%20foo.map%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20Windows%3A%20a%20foo.map%0A%20%20%20%20%E2%80%8B%0A%20%20%20%20Output%20file%20output.txt%20will%20be%20written%20into%20the%20same%20directory.” message=”” highlight=”” provider=”manual”/]
Running it..
Filename is converter.exe and the parameter the input filename.
(You can also use a batch file to execute it)
converter.exe objects.map
Now you choose the input objecttype and the desired output.
Now the conversion is done! Simple, isnt it?
Done!
Now you are ready to use this tool.
I did not use any XML Parser because for this simple use, because it would be way to difficult in to implement it in C!
Input sample, MTA SA 1.0 map:
[pastacode lang=”markdown” manual=”%3Cobject%20id%3D%22object%20(des_ebrigroad07)%20(1)%22%20breakable%3D%22true%22%20interior%3D%220%22%20alpha%3D%22255%22%20model%3D%2216358%22%20doublesided%3D%22false%22%20scale%3D%221%22%20dimension%3D%220%22%20posX%3D%22-1135.2%22%20posY%3D%22-866.29999%22%20posZ%3D%2262.5%22%20rotX%3D%220%22%20rotY%3D%220%22%20rotZ%3D%22314%22%3E%3C%2Fobject%3E%0A%20%20%20%20%20%20%20%20%3Cobject%20id%3D%22object%20(des_ebrigroad07)%20(2)%22%20breakable%3D%22true%22%20interior%3D%220%22%20alpha%3D%22255%22%20model%3D%2216358%22%20doublesided%3D%22false%22%20scale%3D%221%22%20dimension%3D%220%22%20posX%3D%22-1135.3%22%20posY%3D%22-866.20001%22%20posZ%3D%2272.7%22%20rotX%3D%220%22%20rotY%3D%220%22%20rotZ%3D%22313.995%22%3E%3C%2Fobject%3E%0A%20%20%20%20%20%20%20%20%3Cobject%20id%3D%22object%20(des_ebrigroad07)%20(3)%22%20breakable%3D%22true%22%20interior%3D%220%22%20alpha%3D%22255%22%20model%3D%2216358%22%20doublesided%3D%22false%22%20scale%3D%221%22%20dimension%3D%220%22%20posX%3D%22-1140.6%22%20posY%3D%22-871.40002%22%20posZ%3D%2266.1%22%20rotX%3D%2290%22%20rotY%3D%220%22%20rotZ%3D%22313.995%22%3E%3C%2Fobject%3E%0A%0A%E2%80%8B” message=”” highlight=”” provider=”manual”/]
And our PAWN SA-MP output.
[pastacode lang=”c” manual=”CreateObject(16358%2C-1135.199951%2C-866.299988%2C62.500000%2C0.000000%2C0.000000%2C314.000000)%3B%2F%2F%20(des_ebrigroad07)%0A%20%20%20%20CreateObject(16358%2C-1135.300049%2C-866.200012%2C72.699997%2C0.000000%2C0.000000%2C313.994995)%3B%2F%2F%20(des_ebrigroad07)%0A%20%20%20%20CreateObject(16358%2C-1140.599976%2C-871.400024%2C66.099998%2C90.000000%2C0.000000%2C313.994995)%3B%2F%2F%20(des_ebrigroad07)” message=”” highlight=”” provider=”manual”/]
I hope its useful for someone, like written in the license I will publish updates weekly in this topic and refresh the github repository.
Download:
https://github.com/Knogle/SimpleConverter
Source only:
http://pastebin.com/LAMxv5hi