50p Posted July 13, 2010 Author Share Posted July 13, 2010 You can remove these 4 lines completely. I added it for map resource creation but I decided to leave it the old way and didn't remove the code. So, if you remove these 4 lines, it will still work and will not give you error. I'll upload the updated version soon, just let me know if you get more errors. Link to comment
Faw[Ful] Posted July 13, 2010 Share Posted July 13, 2010 Now ! Im destroying your script, wich lines I have to delete ? I delete like 10 error lines under, so I d'ont want to destroye all the lines ! Link to comment
50p Posted July 13, 2010 Author Share Posted July 13, 2010 Delete only these: on resourceName entered newPath do ( setResourcesFolder( newPath ); ) Link to comment
Faw[Ful] Posted July 13, 2010 Share Posted July 13, 2010 now this : I delete these lines on resourceName entered newPath do ( setResourcesFolder( newPath ); ) Look in this part of the script im sure the problem is there : --edittext resourcesFolder "Resources folder:" text:RES_FOLDER labelOnTop:true width:95; --button searchFolderBtn "..." width: 30 offset:[50, -24]; group "Export MTA:SA map:" ( button showGTAMap "Set map location..." width: 120; --edittext resourceName "Resource name:" labelOnTop:true; checkBox exportMetaXMLBox "Generate meta.xml" checked:true checkBox exportLuaScriptBox "Generate .lua script" checked:true checkBox exportDFF "Export DFF files" checked:true button exportBtn "Export to .map" width: 120; on showGTAMap pressed do ( createDialog gtaMapCanvas 600 635; gtaMapCanvas.mapMarker.pos = selectedLocation; ) ) on exportBtn pressed do ( if $ != undefined then ( out_name = getSaveFilename #export caption:"Export to .map file" types:"MTA:SA map file (*.map)|*.map|" --((GetDir #export)+"/mapa.map") if out_name != undefined then ( modelid = _MODELID; out_file = createFile out_name filePathArray = filterString out_name "\\"; fileName = filePathArray[ filePathArray.count ]; mapName = subString fileName 1 ( fileName.count - 4 ); -- take away ".map" so we know map name folderPath = subString out_name 1 ( out_name.count - fileName.count ) -- get folder path out_Lua = ( folderPath + mapName + ".lua" ) if exportLuaScriptBox.checked then ( out_Lua = createFile out_Lua; format "%" HEADER_LUA_SCRIPT to:out_Lua; for obj in $ do ( format "\"map/%\", " obj.name to:out_Lua; ) format "}\n\n" to:out_Lua; format "%" MAIN_LUA_SCRIPT to:out_Lua; ) if exportMetaXMLBox.checked then ( metaXML = createFile ( folderPath + "meta.xml" ); if metaXML != undefined then ( format "%" META_HEADER to:metaXML; format "<meta>\n\t<info author=\"\" gamemodes=\"race\" name=\"%\" type=\"map\"/>\n" mapName to:metaXML; format "\t<script src=\"%\" type=\"client\" />\n" ( mapName + ".lua" ) to:metaXML; format "\t<map src=\"%\" dimension=\"0\" />\n\n" fileName to:metaXML; ) ) format "<map mod=\"deathmatch\">\n" to:out_file; makeDir (folderPath + "\\map" ) CurrSelection = $selection as Array; local doUndo = false; for obj in CurrSelection do ( clearSelection(); -- deselect whatever object is currently being exported selectMore ( obj ); -- select object (from selection) for export (to separate file) if classOf obj.baseObject == Editable_Mesh or classOf obj.baseObject == Editable_Poly then ( if metaXML != undefined then ( format "\t<file src=\"map/%.dff\" />\n" obj.name to:metaXML; format "\t<file src=\"map/%.col\" />\n" obj.name to:metaXML; ) if obj.material == undefined then ( doUndo = true; undo label:"Material Assignment" on ( format "material assign\n" to:listener obj.material = GTA_Material(); ) ) X = obj.pos.X; Y = obj.pos.Y; Z = obj.pos.Z; rotX = obj.rotation.x_rotation rotY = obj.rotation.y_rotation rotZ = obj.rotation.z_rotation undo label: "Reset XForm" on -- reset XForm and set object to center of the scene ( resetXForm obj; obj.pos.X = 0.0; obj.pos.Y = 0.0; obj.pos.Z = 0.0; ) format "\t<object name=\"%\" model=\"%\" posX=\"%\" posY=\"%\" posZ=\"%\" rotX=\"%\" rotY=\"%\" rotZ=\"%\" />\n" obj.name modelid ( X + gtaCoords[1] ) ( Y + gtaCoords[2] ) Z rotX rotY rotZ to:out_file modelid = modelid + 1 if( exportDFF.checked ) then ( dffFile = fOpen (folderPath + "\\map\\" + obj.name + ".dff") "wb" if dffFile != undefined then ( DFFout dffFile $selection false true true true 1.0 0x1803FFFF undefined 1 false; format "DFF (%) exported successfully\n" obj.name to:listener if doUndo then max undo; -- undo material assignment max undo; -- undo resetXForm doUndo = false; ) fFlush dffFile; fClose dffFile; ) ) ) format "</map>\n" to:out_file close out_file if metaXML != undefined then ( format "</meta>" to:metaXML; close metaXML; ) if exportLuaScriptBox.checked then close out_Lua clearSelection(); -- deselect whatever object is currently being exported for obj in CurrSelection do ( selectMore( obj ); -- re-select all export objects ) --clearSelection(); ) ) else ( messagebox "Select the models, before you hit export." title:"Nothing to export" ) ) on searchFolderBtn pressed do ( savePath = resourcesFolder.text; if savePath == undefined then ( savePath = getSavePath caption: "Find your MTA:SA resources folder:" ) else ( savePath = getSavePath caption: "Find your MTA:SA resources folder:" initialDir: savePath ) if savePath != undefined then ( resourcesFolder.text = savePath; setResourcesFolder (savePath); ) ) ) function updateResourcesPath = ( resPath = getResourcesFolder() as string; if resPath != undefined then ( Fiftys_Scripts.resourcesFolder.text = resPath; ) ) openUtility Fiftys_Scripts Link to comment
50p Posted July 13, 2010 Author Share Posted July 13, 2010 group "Export MTA:SA map:" ( button showGTAMap "Set map location..." width: 120; --edittext resourceName "Resource name:" labelOnTop:true; checkBox exportMetaXMLBox "Generate meta.xml" checked:true checkBox exportLuaScriptBox "Generate .lua script" checked:true checkBox exportDFF "Export DFF files" checked:true button exportBtn "Export to .map" width: 120; ) on showGTAMap pressed do ( createDialog gtaMapCanvas 600 635; gtaMapCanvas.mapMarker.pos = selectedLocation; ) Link to comment
Faw[Ful] Posted July 14, 2010 Share Posted July 14, 2010 OK ! I forget the little ) ... oups ! Now when I run it nothing happen, but I see this : So its a good new ! Thanks ! Now you can release the new without errors here the complete script : -- Copyright (c) 50p 2010-- 50p's MTA:SA Script -- v0.3-- 18/05/2010 if DFFinInfo == undefined then fileIn (scriptspath+"\\GTA_Tools\\CharDFFimp.mse") quiet:trueelse if DFFinInfo() != 051215 then fileIn (scriptspath+"\\GTA_Tools\\CharDFFimp.mse") quiet:trueif DFFoutInfo == undefined then fileIn (scriptspath+"\\GTA_Tools\\CharDFFexp.mse") quiet:trueelse if DFFoutInfo() != 051219 then fileIn (scriptspath+"\\GTA_Tools\\CharDFFexp.mse") quiet:true if DFFinInfo() != 051215 then messagebox "You didn't have the right import function to run this script!\nTry Install it again!" title:"Import Function Error"if DFFoutInfo() != 051219 then messagebox "You didn't have the right export function to run this script!\nTry Install it again!" title:"Export Function Error" _MAXSCRIPT = "50p's MTA:SA MAXScript v0.3 (18/05/2010)" _MODELID = int( 4000 ); META_HEADER ="<!-- Meta.xml generated with " + _MAXSCRIPT + " -->\n" HEADER_LUA_SCRIPT ="-- Script generated with-- " + _MAXSCRIPT + " local modelNames = { " MAIN_LUA_SCRIPT = 0;MAIN_LUA_SCRIPT = "function reloadModels( ) for i, modelName in ipairs( modelNames ) do local temp = engineLoadDFF( modelName .. \".dff\", 0 ); engineReplaceModel( temp, (i-1) + " + (_MODELID as string) + " ); temp = engineLoadCOL( modelName .. \".col\" ); engineReplaceCOL( temp, (i-1) + " + (_MODELID as string) + " ); endendaddEventHandler( \"onClientResourceStart\", getResourceRootElement(), reloadModels );addCommandHandler( \"reload\", reloadModels );" MAP_WIDTH = MAP_HEIGHT = 600MARKER_WIDTH = MARKER_HEIGHT = 24;MARKER_CENTER = Point2 4 23 global selectedLocation;global gtaCoords = Point2 0.0 0.0;selectedLocation = Point2 -MARKER_WIDTH -MARKER_HEIGHT function getResourcesFolder = ( p = ( getDir #defaults ) + "/50pMTAscript.ini"; iniFilename = getIniSetting p "Directories" "ResourcesDir" if iniFilename != undefined then ( return iniFilename; )) function setResourcesFolder resPath = ( p = ( getDir #defaults ) + "/50pMTAscript.ini"; success = setIniSetting p "Directories" "ResourcesDir" resPath if success == false then ( messagebox "Failed to set resources folder" )) --RES_FOLDER = getResourcesFolder(); function getXFromGTAX x = ( return ( ( x * 512 ) / 6000 + ( MAP_WIDTH / 2 ) )) function getYFromGTAY y =( return ( ( -1 * x * 512 ) / 6000 + ( MAP_HEIGHT / 2 ) )) function getRelativeCoords pos =( return Point2 ( pos[ 1 ] / ( MAP_WIDTH / 2 ) ) ( pos[ 2 ] / ( MAP_HEIGHT / 2 ) )) function convertToGrid pos =( return Point2 ( pos[ 1 ] - ( MAP_WIDTH / 2 ) ) ( ( pos[ 2 ] - ( MAP_HEIGHT / 2 ) ) * -1 )) global gtaMapCanvas;try(destroyDialog gtaMapCanvas) catch() rollout gtaMapCanvas "Select the location where you want your map to be loaded in MTA:SA"( local gtaMap = openBitmap ( ( getDir #scripts ) + "/MapExporter/gtasa-map-small.jpg" ); --gtaMap as bitmap 600 600 bitmap: gtaMap; --pos: [ 0 , 0 ]; local marker = openBitmap ( ( getDir #scripts ) + "/MapExporter/marker.tga" ); imgTag mapTag "mapTag" bitmap: gtaMap align:#center width:MAP_WIDTH height:MAP_HEIGHT pos: [ 0, 0 ]; imgTag mapMarker "mapMarker" bitmap: marker align:#center width:MARKER_WIDTH height:MARKER_HEIGHT transparent: ( color 255 255 255 ) pos: [ -MARKER_WIDTH, -MARKER_HEIGHT ]; editText coordX "X:" readonly:true width: 100 pos:[ 10, 610 ]; editText coordY "Y:" readonly:true width: 100 pos:[ 120, 610 ]; on mapTag lbuttondown pos flag do ( local pos2 = Point2 ( pos[ 1 ] - MARKER_CENTER[ 1 ] ) ( pos[ 2 ] - MARKER_CENTER[ 2 ] ); local gridPos = convertToGrid( pos ); local relCoords = getRelativeCoords( gridPos ); gtaCoords = Point2 ( relCoords[ 1 ] * 3000 ) ( relCoords[ 2 ] * 3000 ) selectedLocation = pos2; mapMarker.pos = pos2; coordX.text = gtaCoords[ 1 ] as string; coordY.text = gtaCoords[ 2 ] as string; )) utility Fiftys_Scripts "50p's MTA:SA Scripts"( --edittext resourcesFolder "Resources folder:" text:RES_FOLDER labelOnTop:true width:95; --button searchFolderBtn "..." width: 30 offset:[50, -24]; group "Export MTA:SA map:" ( button showGTAMap "Set map location..." width: 120; --edittext resourceName "Resource name:" labelOnTop:true; checkBox exportMetaXMLBox "Generate meta.xml" checked:true checkBox exportLuaScriptBox "Generate .lua script" checked:true checkBox exportDFF "Export DFF files" checked:true button exportBtn "Export to .map" width: 120; ) on showGTAMap pressed do ( createDialog gtaMapCanvas 600 635; gtaMapCanvas.mapMarker.pos = selectedLocation; ) on exportBtn pressed do ( if $ != undefined then ( out_name = getSaveFilename #export caption:"Export to .map file" types:"MTA:SA map file (*.map)|*.map|" --((GetDir #export)+"/mapa.map") if out_name != undefined then ( modelid = _MODELID; out_file = createFile out_name filePathArray = filterString out_name "\\"; fileName = filePathArray[ filePathArray.count ]; mapName = subString fileName 1 ( fileName.count - 4 ); -- take away ".map" so we know map name folderPath = subString out_name 1 ( out_name.count - fileName.count ) -- get folder path out_Lua = ( folderPath + mapName + ".lua" ) if exportLuaScriptBox.checked then ( out_Lua = createFile out_Lua; format "%" HEADER_LUA_SCRIPT to:out_Lua; for obj in $ do ( format "\"map/%\", " obj.name to:out_Lua; ) format "}\n\n" to:out_Lua; format "%" MAIN_LUA_SCRIPT to:out_Lua; ) if exportMetaXMLBox.checked then ( metaXML = createFile ( folderPath + "meta.xml" ); if metaXML != undefined then ( format "%" META_HEADER to:metaXML; format "<meta>\n\t<info author=\"\" gamemodes=\"race\" name=\"%\" type=\"map\"/>\n" mapName to:metaXML; format "\t<script src=\"%\" type=\"client\" />\n" ( mapName + ".lua" ) to:metaXML; format "\t<map src=\"%\" dimension=\"0\" />\n\n" fileName to:metaXML; ) ) format "<map mod=\"deathmatch\">\n" to:out_file; makeDir (folderPath + "\\map" ) CurrSelection = $selection as Array; local doUndo = false; for obj in CurrSelection do ( clearSelection(); -- deselect whatever object is currently being exported selectMore ( obj ); -- select object (from selection) for export (to separate file) if classOf obj.baseObject == Editable_Mesh or classOf obj.baseObject == Editable_Poly then ( if metaXML != undefined then ( format "\t<file src=\"map/%.dff\" />\n" obj.name to:metaXML; format "\t<file src=\"map/%.col\" />\n" obj.name to:metaXML; ) if obj.material == undefined then ( doUndo = true; undo label:"Material Assignment" on ( format "material assign\n" to:listener obj.material = GTA_Material(); ) ) X = obj.pos.X; Y = obj.pos.Y; Z = obj.pos.Z; rotX = obj.rotation.x_rotation rotY = obj.rotation.y_rotation rotZ = obj.rotation.z_rotation undo label: "Reset XForm" on -- reset XForm and set object to center of the scene ( resetXForm obj; obj.pos.X = 0.0; obj.pos.Y = 0.0; obj.pos.Z = 0.0; ) format "\t<object name=\"%\" model=\"%\" posX=\"%\" posY=\"%\" posZ=\"%\" rotX=\"%\" rotY=\"%\" rotZ=\"%\" />\n" obj.name modelid ( X + gtaCoords[1] ) ( Y + gtaCoords[2] ) Z rotX rotY rotZ to:out_file modelid = modelid + 1 if( exportDFF.checked ) then ( dffFile = fOpen (folderPath + "\\map\\" + obj.name + ".dff") "wb" if dffFile != undefined then ( DFFout dffFile $selection false true true true 1.0 0x1803FFFF undefined 1 false; format "DFF (%) exported successfully\n" obj.name to:listener if doUndo then max undo; -- undo material assignment max undo; -- undo resetXForm doUndo = false; ) fFlush dffFile; fClose dffFile; ) ) ) format "</map>\n" to:out_file close out_file if metaXML != undefined then ( format "</meta>" to:metaXML; close metaXML; ) if exportLuaScriptBox.checked then close out_Lua clearSelection(); -- deselect whatever object is currently being exported for obj in CurrSelection do Link to comment
Thehookerkiller01 Posted July 16, 2010 Share Posted July 16, 2010 Where can I find 3DS Max? Link to comment
50p Posted July 16, 2010 Author Share Posted July 16, 2010 Where can I find 3DS Max? Google is your friend. Autodesk.com Link to comment
Faw[Ful] Posted August 3, 2010 Share Posted August 3, 2010 For the next version, im sure you will add the col export, but I would like to keep the fact that you need to select all the models you want to export, because its a good thing if a dude like me want to convert just a part of the map Link to comment
50p Posted August 4, 2010 Author Share Posted August 4, 2010 For the next version, im sure you will add the col export, but I would like to keep the fact that you need to select all the models you want to export, because its a good thing if a dude like me want to convert just a part of the map I would love to add col exporting but I really doubt it will be added in the future because as I said somewhere, I have no idea what function KAM scripts use to export collision mesh since the script is encoded and I have no access to its source code. I said function because I'm pretty sure Kam made a function that will do all the exporting for me. I can't even get in touch with Kam who made the the KAM scripts to find out what should I use. Link to comment
Faw[Ful] Posted August 4, 2010 Share Posted August 4, 2010 Question ! Do we have to center the .col model in 3ds max to export it after or we have to keep the .dff position of the object model ? Is the position they have when I select them all to use your tool after. I know if I make the wrong choice, the col would be at the wrong place. If I fail I need to export again one by one my 78 col for my 78 objects models, its why I very wait for a col export for your tool. The mapper who made alien city make too small objects models and its a wrong choice, akina have 6 models and for the same size with alien city I have 78 OMG !!! Link to comment
50p Posted August 4, 2010 Author Share Posted August 4, 2010 Question ! Do we have to center the .col model in 3ds max to export it after or we have to keep the .dff position of the object model ? Is the position they have when I select them all to use your tool after. I know if I make the wrong choice, the col would be at the wrong place. If I fail I need to export again one by one my 78 col for my 78 objects models, its why I very wait for a col export for your tool.The mapper who made alien city make too small objects models and its a wrong choice, akina have 6 models and for the same size with alien city I have 78 OMG !!! If the models are not big then you can attach them before exporting. Nothing wrong will happen if you attach them but make sure that bounding box is not greater than 512x512x512. Yes, you have to center the col mesh before you export the col. It doesn't matter which one you export first. My export script centers the model before it's written to .dff then moves it back to the position where it was before exporting. As I said, I'd love to include col export feature but I can't. I was aware of people making loads of models and exporting them one by one is pain in the butt that's why I made this script but unfortunately you still have to export collision yourself. Link to comment
Faw[Ful] Posted August 4, 2010 Share Posted August 4, 2010 (edited) Question ! Do we have to center the .col model in 3ds max to export it after or we have to keep the .dff position of the object model ? Is the position they have when I select them all to use your tool after. I know if I make the wrong choice, the col would be at the wrong place. If I fail I need to export again one by one my 78 col for my 78 objects models, its why I very wait for a col export for your tool.The mapper who made alien city make too small objects models and its a wrong choice, akina have 6 models and for the same size with alien city I have 78 OMG !!! If the models are not big then you can attach them before exporting. Nothing wrong will happen if you attach them but make sure that bounding box is not greater than 512x512x512. Yes, you have to center the col mesh before you export the col. It doesn't matter which one you export first. My export script centers the model before it's written to .dff then moves it back to the position where it was before exporting. As I said, I'd love to include col export feature but I can't. I was aware of people making loads of models and exporting them one by one is pain in the butt that's why I made this script but unfortunately you still have to export collision yourself. ok, thanks attach them is possible, so thats is a great idea, I dont know if the corona lights attached to the .dff will work and the smoke effects, but I need to test. Edited August 4, 2010 by Guest Link to comment
50p Posted August 4, 2010 Author Share Posted August 4, 2010 ok, thanks attach them is possible, so thats is a great idea, I dont know if the corona lights attached to the .dff will work and the smoke effects, but I need to test. Unfortunately MTA doesn't support lights (coronas), smoke effects nor animated textures. Good luck. Link to comment
Faw[Ful] Posted August 4, 2010 Share Posted August 4, 2010 ok, thanks attach them is possible, so thats is a great idea, I dont know if the corona lights attached to the .dff will work and the smoke effects, but I need to test. Unfortunately MTA doesn't support lights (coronas), smoke effects nor animated textures. Good luck. But if MTA can accept these effects with the default gta sa models it can with new models, I try to export a .dff with med editor and the smoke effects attached to this dff work in MTA I dont try with corona lights and maybe kams script cant export these things and med editor can. The hard job is too remove all the lod in 3ds max, they are at the same place with the normal models Do u know if I can attach selected models in one object ? Link to comment
50p Posted August 4, 2010 Author Share Posted August 4, 2010 ...Do u know if I can attach selected models in one object ? What do you mean? 3DS Max? Lua script? Map editor? Link to comment
50p Posted August 4, 2010 Author Share Posted August 4, 2010 I mean 3ds max Ok, you mean you want to select a few models and export them as 1 model? No you can't do this because I export all selected models separately. You can select 1 object (Editable mesh or Editable poly) and use the Attach button to attach other models or click the little "window" button next to Attach button to get a list of models that you can select and attach. Then you can export the new model. Link to comment
Faw[Ful] Posted August 4, 2010 Share Posted August 4, 2010 Ok ! thats is what I think, so I cant select a group of objects in 3ds max and attach them all in one click to make one . I use the attach one by one when I creat my model, but with 78 imported models with map IO its would be too exagerate too attache them to have like 6 objects, but if I can thats would be awesome So good work in your 3D modeling !!! Link to comment
50p Posted August 5, 2010 Author Share Posted August 5, 2010 As I said, you can attach more than 1 models only with the little "window" button next to "Attach" button, you will see list of all the models in the scene which you can select (hold Ctrl to select more than 1 item or Shift to select all the models between 1st selected and last selected). This is the only way. I'm not going to implement models attachment in my script because there is no point. Link to comment
Faw[Ful] Posted August 5, 2010 Share Posted August 5, 2010 Cool, so I can attach them all, attach like 1000 objects in one and splite the one into 6 objects, but maybe 3ds will crash, I will try Link to comment
50p Posted August 5, 2010 Author Share Posted August 5, 2010 If it won't crash with 1000 object then why should it crash with 6 models but with the same amount of polygons? And what splite is? Link to comment
Faw[Ful] Posted August 6, 2010 Share Posted August 6, 2010 Just crash, because I attache 1000 in one time, I say that, because 1000 its alot for me The split. The name say it, I can splite a object into 2 with maya so im sure I can do it in 3ds max Link to comment
50p Posted August 6, 2010 Author Share Posted August 6, 2010 Just crash, because I attache 1000 in one time, I say that, because 1000 its alot for meThe split. The name say it, I can splite a object into 2 with maya so im sure I can do it in 3ds max Oh split... There is no splite in English that's why I was confused. Anyway, don't attach them all at the same time.. From the list of models, select like 100, if it still crashes then select 80, if it still crashes, keep dropping down by 20 and you'll see how many objects you can attach at once. It won't take you long to attach all 1000 by attaching smaller amounts of models at once. Link to comment
Jorge_F Posted December 5, 2010 Share Posted December 5, 2010 I just wanted to say, thx for this awesome script! Together with the fixed version further on in this topic I managed to get it working smoothly! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now