Advertisement
black_truong

Mouiz' Map Editor v1.2 Released!

Jul 8th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #define FILTERSCRIPT
  4. #define COL_WHITE "{FFFFFF}"
  5. #define COL_GREEN "{00FF00}"
  6. #define ANIM_SAVE_FILE "Objects.txt"
  7. new object;
  8. new cobj;
  9. new pnam[MAX_PLAYER_NAME];
  10. new line[100];
  11. new create[MAX_PLAYERS];
  12. new c[MAX_PLAYERS];
  13.  
  14. public OnFilterScriptInit()
  15. {
  16. print("Map Editor Loaded");
  17. return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22. return 1;
  23. }
  24.  
  25. new model[MAX_OBJECTS];
  26.  
  27. stock SaveObjectToFile(playerid, modelid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  28. {
  29. new
  30. File:file;
  31. GetPlayerName(playerid, pnam, sizeof(pnam));
  32. if(!fexist(ANIM_SAVE_FILE))file = fopen(ANIM_SAVE_FILE, io_write);
  33. else file = fopen(ANIM_SAVE_FILE, io_append);
  34. format(line, 100, "CreateObject(%d, %f, %f, %f, %f, %f, %f);\r\n", modelid, fX, fY, fZ, fRotX, fRotY, fRotZ);
  35. fwrite(file, line);
  36. fclose(file);
  37. return 1;
  38. }
  39.  
  40. stock DeleteObject(playerid)
  41. {
  42. new
  43. File:file,
  44. writer[100];
  45. GetPlayerName(playerid, pnam, sizeof(pnam));
  46. if(!fexist(ANIM_SAVE_FILE))file = fopen(ANIM_SAVE_FILE, io_write);
  47. else file = fopen(ANIM_SAVE_FILE, io_append);
  48. format(writer, 100, "//--------------(Remove this and the previous line to apply the delete)--------------\r\n");
  49. fwrite(file, writer);
  50. fclose(file);
  51. return 1;
  52. }
  53.  
  54. stock EditingObject(playerid)
  55. {
  56. new
  57. File:file,
  58. editor[100];
  59. GetPlayerName(playerid, pnam, sizeof(pnam));
  60. if(!fexist(ANIM_SAVE_FILE))file = fopen(ANIM_SAVE_FILE, io_write);
  61. else file = fopen(ANIM_SAVE_FILE, io_append);
  62. format(editor, 100, "//--------------(Remove this and the previous line to apply the edit)--------------\r\n");
  63. fwrite(file, editor);
  64. fclose(file);
  65. return 1;
  66. }
  67.  
  68. CMD:createobject(playerid, params[])
  69. {
  70. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, ""COL_GREEN"Objects", ""COL_WHITE"Enter the object id you want to add", "OK", "Cancel");
  71. c[playerid] = 1;
  72. return 1;
  73. }
  74.  
  75. CMD:deleteobject(playerid, params[])
  76. {
  77. DestroyObject(cobj);
  78. if(c[playerid] == 0) return 0;
  79. DeleteObject(playerid);
  80. c[playerid] = 0;
  81. return 1;
  82. }
  83.  
  84. CMD:editobject(playerid, params[])
  85. {
  86. EditObject(playerid, cobj);
  87. EditingObject(playerid);
  88. }
  89.  
  90. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  91. {
  92. if(dialogid == 1)
  93. {
  94. if(response)
  95. {
  96. new Float:x, Float:y, Float:z;
  97. object = strval(inputtext);
  98. GetPlayerPos(playerid, x, y, z);
  99. cobj = CreateObject(object, x-5, y, z, 0.0, 0.0, 0.0);
  100. EditObject(playerid, cobj);
  101. model[cobj] = object;
  102. create[playerid] = 1;
  103. }
  104. }
  105. return 1;
  106. }
  107.  
  108. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  109. {
  110. if(response == EDIT_RESPONSE_FINAL)
  111. {
  112. SaveObjectToFile(playerid, model[objectid], fX, fY, fZ, fRotX, fRotY, fRotZ);
  113. }
  114. if(response == EDIT_RESPONSE_CANCEL)
  115. {
  116. DestroyObject(cobj);
  117. }
  118. return 1;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement