leong124

Tutorial on adding custom objects to MTA:SA

Oct 5th, 2011
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. First of all you'll need to put your custom objects (DFF, TXD and COL) into MTA San Andreas 1.1\server\mods\deathmatch\resources\[editor]\editor_main\.
  2.  
  3. Then open MTA San Andreas 1.1\server\mods\deathmatch\resources\[editor]\editor_main\meta.xml and add these like the other objects:
  4. [code]
  5. <file src="yourobject.dff" />
  6. <file src="yourobject.col" />
  7. <file src="yourobject.txd" />
  8. [/code]
  9.  
  10. After that, open samp_models_lsoffice.lua in the same folder (or create a new file if you want).
  11. Add this like the other objects:
  12. [code]
  13. txd1000 = engineLoadTXD('yourobject.txd')
  14. engineImportTXD(txd1000, the_replaced_object_model_id)
  15. col1000 = engineLoadCOL('yourobject.col')
  16. dff1000 = engineLoadDFF('yourobject.dff', 0)
  17. engineReplaceCOL(txd1000, the_replaced_object_model_id)
  18. engineReplaceModel(txd1000, the_replaced_object_model_id)
  19. engineReplaceCOL(txd1000, the_replaced_object_model_id)
  20. [/code]
  21. If you create a new script instead of editing samp_models_lsoffice.lua, you'll need to do this:
  22. [code]
  23. rootElement = getRootElement()
  24. function loadobj(resource)
  25. if resource ~= getThisResource() then return end
  26. txd1000 = engineLoadTXD('yourobject.txd')
  27. engineImportTXD(txd1000, the_replaced_object_id)
  28. col1000 = engineLoadCOL('yourobject.col')
  29. dff1000 = engineLoadDFF('yourobject.dff', 0)
  30. engineReplaceCOL(txd1000, the_replaced_object_id)
  31. engineReplaceModel(txd1000, the_replaced_object_id)
  32. engineReplaceCOL(txd1000, the_replaced_object_id)
  33. end
  34. addEventHandler('onClientResourceStart', rootElement, loadobj)
  35. [/code]
  36. and then go back to MTA San Andreas 1.1\server\mods\deathmatch\resources\[editor]\editor_main\meta.xml and add/uncomment the script so that it can be loaded in map editor:
  37. [code]
  38. <!--SA-MP Objects -->
  39. <script src="samp_models_lsoffice.lua" type="client"/>
  40. <script src="your_own_script_name_if_you_create_a_new_one.lua" type="client"/>
  41. <!--<script src="samp_models_rc3_1.lua" type="client"/>-->
  42. <!--<script src="samp_models_rc3_2.lua" type="client"/>-->
  43. <!--<script src="samp_models_rc4.lua" type="client"/>-->
  44. <!--<script src="samp_models_rc5.lua" type="client"/>-->
  45. [/code]
  46. Then open MTA San Andreas 1.1\server\mods\deathmatch\resources\[editor]\editor_gui\client\browser\objects.xml
  47. and add a new category, or append to the old categories if you want to:
  48. [code]
  49. <group name="Custom objects">
  50. <object model="the_replaced_object_model_id" name="Your first custom object in MTA:SA" keywords=""/>
  51. </group>
  52. <group name="Enterable LS Building">
  53. <object model="4587" name="LSOffice1" keywords=""/>
  54. <object model="3781" name="LSOffice1Floors" keywords=""/>
  55. <object model="4605" name="LSOffice1Glass" keywords=""/>
  56. </group>
  57. [/code]
  58. Done. Note that I use MTA:SA 1.1 as example. If you use 1.0.5, the path will be a little bit different, but I think it is not hard to find the folder of the map editor.
Advertisement
Add Comment
Please, Sign In to add comment