Advertisement
Guest User

Untitled

a guest
Dec 8th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 102.66 KB | None | 0 0
  1. /*
  2.  
  3.  
  4. _____ _ _
  5. | __ \ | | (_)
  6. | | | |_ __ ___| |__ _ _ __
  7. | | | | '__/ _ \ '_ \| | '_ \
  8. | |__| | | | __/ |_) | | | | |
  9. |_____/|_| \___|_.__/|_|_| |_|
  10.  
  11. ObjectEditor v1.0.0
  12.  
  13. ©Drebin 2012
  14.  
  15.  
  16. */
  17.  
  18. #define FILTERSCRIPT
  19.  
  20. #include <a_samp>
  21. #include <dini>
  22. #include <zcmd>
  23. #include <sscanf2>
  24. //==============================================================================
  25. // > D E F I N E S <
  26. //
  27. // true = enabled/yes | false = disabled/no
  28. //==============================================================================
  29. #define RCON_ADMINS_ONLY false //Restrict the usage of the editor to RCON admins
  30. #define TOGGLED_ONLY false //If true, an admin has to /toggleeditor the player first before they can use the editor.
  31. #define ALLOW_USE_3D_LABELS true //Allow the user to enable 3D text labels attached to objects
  32. #define USE_COMMAND_SHORTCUTS true //Allow the usage of command shortcuts (eg. /createnewobject -> /cno)
  33. #define USE_MAX_CREATE_DISTANCE true //Restrict the distance an object is create from the player
  34. #define USE_MAX_MOVE_DISTANCE true //Restict the max. distance a player can move the object
  35. #define MAX_CREATE_DISTANCE 200.0 //The max. distance a player can enter when he creates an object (only if USEMAX_CREATE_DISTANCE is enabled)
  36. #define MAX_MOVE_DISTANCE 400.0 //The max. distance a player can move an object (only if MAX_CREATE_DISTANCE is enabled)
  37. #define ALLOW_EXPORT_MAP_FILE true //Allow normal players to export an object file? (if disabled, only RCON admins can)
  38. #define ALLOW_EDIT_OBJECT_ON_DUPLICATE true //Allow a player to enable the auto edition of an object after it has been duplicated
  39. #define ALLOW_USE_MATERIAL_CHANGE_DIALOG true //Allow the player to use the material change dialog (recommended)
  40. #define ALLOW_EDIT_OBJECT_ON_CREATE true //Allow a player to enable the auto edition of an object after creating it
  41. #define ALLOW_KEEP_MATERIAL false //Allow a player to enable a function which keeps the cusrom texture after changing the model of the object
  42. #define ALLOW_USE_CROSS true //Allow a player to enable the fade cross when he's in the flyeditor
  43. #define ALLOW_TRANSFER_MATERIAL true //If a player duplicates an object with a custom material(texture) on it, this allows him to
  44. //-> enable a setting which automatically transfers the material to the duplicated object
  45. //==============================================================================
  46. // > D I A L O G I D S <
  47. //==============================================================================
  48. #define DIALOG_MAINMENU 1693
  49. #define DIALOG_MAP_SAVENAME 1694
  50. #define DIALOG_MAP_EXPORTNAME 1695
  51. #define DIALOG_MAP_LOAD 1696
  52. #define DIALOG_SELECTMENU 1697
  53. #define DIALOG_CHANGEMODEL 1698
  54. #define DIALOG_MATERIALS 1699
  55. #define DIALOG_MATERIALINDEX 1700
  56. #define DIALOG_MODELID 1701
  57. #define DIALOG_TXDNAME 1702
  58. #define DIALOG_TEXTURENAME 1703
  59. #define DIALOG_COLOR 1704
  60. #define DIALOG_SETTINGS 1705
  61. #define DIALOG_EDITORCOMMANDS 1706
  62. #define DIALOG_EDITORCOMMANDS2 1707
  63. #define DIALOG_SETTINGSHELP 1708
  64. //==============================================================================
  65. // > C O L O R D E F I N E S <
  66. //==============================================================================
  67. #define COLOR_USAGE 0x91FF91FF //{91FF91} - The color of the command usage
  68. #define COLOR_USAGE2 0x87FF87FF //{87FF87} - The color of the command parameter explanation
  69. #define COLOR_WARNING 0xF58282FF //{F58282} - The color of the red error messages
  70. #define COLOR_INFO 0xF5F582FF //{F5F582} - The color of the info messages
  71. //{A9C4E4} - default dialog color
  72. //==============================================================================
  73.  
  74. //==============================================================================
  75. //------------------------------------------------------------------------------
  76. // !!! D O N O T C H A N G E V A L U E S B E L O W T H I S L I N E !!!
  77. //------------------------------------------------------------------------------
  78. //==============================================================================
  79. #define INVALID_OBJECT_NUMBER (-1)
  80. #define MAX_CREATED_OBJECTS 400
  81.  
  82. #define MOVE_FORWARD 1
  83. #define MOVE_BACK 2
  84. #define MOVE_LEFT 3
  85. #define MOVE_RIGHT 4
  86. #define MOVE_FORWARD_LEFT 5
  87. #define MOVE_FORWARD_RIGHT 6
  88. #define MOVE_BACK_LEFT 7
  89. #define MOVE_BACK_RIGHT 8
  90.  
  91. #define MOVE_SPEED 100.0
  92. #define ACCEL_RATE 0.03
  93.  
  94. enum objectenum
  95. {
  96. created,
  97. objectID,
  98. modelID,
  99. Float:XLoc,
  100. Float:YLoc,
  101. Float:ZLoc,
  102. Float:XRot,
  103. Float:YRot,
  104. Float:ZRot,
  105. usesmaterial,
  106. indexused,
  107. modelused,
  108. txdused,
  109. textureused,
  110. colorused,
  111. matindex,
  112. matmodel,
  113. PlayerText3D:labelID
  114. };
  115.  
  116. enum playerenum
  117. {
  118. bool:EditObjectOnCreate,
  119. bool:EditObjectOnDuplicate,
  120. bool:UseMaterialDialog,
  121. bool:TransferMaterial,
  122. bool:KeepMaterial,
  123. bool:UseCross,
  124. bool:UseLabels,
  125. bool:editing,
  126. totalobjects,
  127. editobject,
  128. flyeditor,
  129. flyobject,
  130. mode,
  131. lrold,
  132. udold,
  133. lastmove,
  134. Float:accelmul,
  135. Float:poX,
  136. Float:poY,
  137. Float:poZ,
  138. canuse
  139. };
  140.  
  141. new pInfo[MAX_PLAYERS][playerenum];
  142. new oInfo[MAX_PLAYERS][MAX_CREATED_OBJECTS][objectenum];
  143.  
  144. new PlayerText:Cross[2];
  145.  
  146. #if defined FILTERSCRIPT
  147.  
  148. public OnFilterScriptInit()
  149. {
  150. print("-----------------------------------------------------------------------------\n");
  151. print(" > Drebin's Object Editor < ");
  152. print(" v1.0.0 ");
  153. print(" ");
  154. print(" ©Drebin 2012 ");
  155. print(" ");
  156. print("-----------------------------------------------------------------------------\n");
  157. return 1;
  158. }
  159.  
  160. public OnFilterScriptExit()
  161. {
  162. for(new i = 0; i <= MAX_PLAYERS; i++)
  163. {
  164. if(IsPlayerConnected(i))
  165. Endflyeditor(i);
  166. }
  167. return 1;
  168. }
  169.  
  170. #endif
  171.  
  172. public OnPlayerConnect(playerid)
  173. {
  174. ResetAllValues(playerid);
  175. pInfo[playerid][canuse] = false;
  176. pInfo[playerid][EditObjectOnCreate] = false;
  177. pInfo[playerid][EditObjectOnDuplicate] = false;
  178. pInfo[playerid][UseMaterialDialog] = true;
  179. pInfo[playerid][TransferMaterial] = true;
  180. pInfo[playerid][KeepMaterial] = true;
  181. pInfo[playerid][UseCross] = false;
  182. pInfo[playerid][lrold] = 0;
  183. pInfo[playerid][udold] = 0;
  184. pInfo[playerid][mode] = 0;
  185. pInfo[playerid][lastmove] = 0;
  186. pInfo[playerid][accelmul] = 0.0;
  187. Cross[0] = CreatePlayerTextDraw(playerid, 320.000000, 221.000000, "_");
  188. PlayerTextDrawAlignment(playerid, Cross[0], 2);
  189. PlayerTextDrawBackgroundColor(playerid, Cross[0], 255);
  190. PlayerTextDrawFont(playerid, Cross[0], 1);
  191. PlayerTextDrawLetterSize(playerid, Cross[0], 0.500000, 1.400000);
  192. PlayerTextDrawColor(playerid, Cross[0], -1);
  193. PlayerTextDrawSetOutline(playerid, Cross[0], 0);
  194. PlayerTextDrawSetProportional(playerid, Cross[0], 1);
  195. PlayerTextDrawSetShadow(playerid, Cross[0], 1);
  196. PlayerTextDrawUseBox(playerid, Cross[0], 1);
  197. PlayerTextDrawBoxColor(playerid, Cross[0], -1);
  198. PlayerTextDrawTextSize(playerid, Cross[0], 0.000000, -3.000000);
  199.  
  200. Cross[1] = CreatePlayerTextDraw(playerid, 320.000000, 229.000000, "_");
  201. PlayerTextDrawAlignment(playerid, Cross[1], 2);
  202. PlayerTextDrawBackgroundColor(playerid, Cross[1], 255);
  203. PlayerTextDrawFont(playerid, Cross[1], 1);
  204. PlayerTextDrawLetterSize(playerid, Cross[1], 0.500000, -0.400000);
  205. PlayerTextDrawColor(playerid, Cross[1], -1);
  206. PlayerTextDrawSetOutline(playerid, Cross[1], 0);
  207. PlayerTextDrawSetProportional(playerid, Cross[1], 1);
  208. PlayerTextDrawSetShadow(playerid, Cross[1], 1);
  209. PlayerTextDrawUseBox(playerid, Cross[1], 1);
  210. PlayerTextDrawBoxColor(playerid, Cross[1], -1);
  211. PlayerTextDrawTextSize(playerid, Cross[1], 0.000000, 13.000000);
  212. return 1;
  213. }
  214.  
  215. public OnPlayerDisconnect(playerid, reason)
  216. {
  217. Endflyeditor(playerid);
  218. ResetAllValues(playerid);
  219. pInfo[playerid][canuse] = false;
  220. return 1;
  221. }
  222.  
  223. CMD:openeditor(playerid, params[])
  224. {
  225. #if RCON_ADMINS_ONLY == true
  226. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WARNING,"Sorry, the object editor is for RCON admins only.");
  227. #endif
  228. #if TOGGLED_ONLY == true
  229. if(pInfo[playerid][canuse] != 1) return SendClientMessage(playerid, COLOR_WARNING, "Sorry, you have to ask an admin first before you can use the object editor.");
  230. #endif
  231. if(pInfo[playerid][editing] == false)
  232. {
  233. SendClientMessage(playerid, -1, "[Editor {91FF91}ON{FFFFFF}]");
  234. SendClientInfoMessage(playerid, "You have entered the object editor.");
  235. pInfo[playerid][editing] = true;
  236. }
  237. else
  238. {
  239. SendClientMessage(playerid, -1, "[Editor {F58282}OFF{FFFFFF}]");
  240. DeleteAllObjects(playerid);
  241. ResetAllValues(playerid);
  242. SendClientInfoMessage(playerid, "You have left the editor. | All your objects have been automatically deleted.");
  243. pInfo[playerid][editing] = false;
  244. }
  245. return 1;
  246. }
  247.  
  248. CMD:cno(playerid, params[])
  249. {
  250. #if USE_COMMAND_SHORTCUTS == true
  251. return cmd_createnewobject(playerid, params);
  252. #else
  253. SendClientErrorMessage(playerid, 8);
  254. #endif
  255. }
  256.  
  257. CMD:createnewobject(playerid, params[])
  258. {
  259. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  260. new model, Float:distance;
  261. if(sscanf(params, "iF(10.0)", model, distance))
  262. {
  263. SendClientMessage(playerid, COLOR_USAGE, "Usage: /createnewobject [modelid] <distance>");
  264. SendClientMessage(playerid, COLOR_USAGE2, "> Creates a new object using the defined model ID and distance.");
  265. SendClientMessage(playerid, COLOR_USAGE2, "> If no distance is entered, the default value of 10.0m is used.");
  266. #if USE_COMMAND_SHORTCUTS == true
  267. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /cno.");
  268. #endif
  269. }
  270. else
  271. {
  272. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  273. {
  274. #if USE_MAX_CREATE_DISTANCE == true
  275. if(distance > MAX_CREATE_DISTANCE) return SendClientErrorMessage(playerid, 5);
  276. #endif
  277. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  278. {
  279. if(oInfo[playerid][i][created] == 0)
  280. {
  281. oInfo[playerid][i][created] = 1;
  282. if(pInfo[playerid][flyeditor] == 1)
  283. {
  284. new
  285. Float:fPX, Float:fPY, Float:fPZ,
  286. Float:fVX, Float:fVY, Float:fVZ;
  287. GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
  288. GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
  289. oInfo[playerid][i][modelID] = model;
  290. oInfo[playerid][i][XLoc] = fPX + floatmul(fVX, distance);
  291. oInfo[playerid][i][YLoc] = fPY + floatmul(fVY, distance);
  292. oInfo[playerid][i][ZLoc] = fPZ + floatmul(fVZ, distance);
  293. oInfo[playerid][i][XRot] = 0.0;
  294. oInfo[playerid][i][YRot] = 0.0;
  295. oInfo[playerid][i][ZRot] = 0.0;
  296. oInfo[playerid][i][objectID] = CreateObject(model,oInfo[playerid][i][XLoc], oInfo[playerid][i][YLoc], oInfo[playerid][i][ZLoc],0,0,0);
  297. pInfo[playerid][totalobjects] ++;
  298. new string[100];
  299. format(string, sizeof(string), "Created object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) %.1f meter infront of you.", i, oInfo[playerid][i][modelID], distance);
  300. SendClientMessage(playerid, COLOR_INFO, string);
  301. }
  302. else
  303. {
  304. new Float:X, Float:Y, Float:Z;
  305. new Float:rot;
  306. GetPlayerPos(playerid, X, Y, Z);
  307. if(IsPlayerInAnyVehicle(playerid))
  308. GetVehicleZAngle(GetPlayerVehicleID(playerid), rot);
  309. else
  310. GetPlayerFacingAngle(playerid, rot);
  311. oInfo[playerid][i][modelID] = model;
  312. oInfo[playerid][i][XLoc] = X + (distance * floatsin(-rot, degrees));
  313. oInfo[playerid][i][YLoc] = Y + (distance * floatcos(-rot, degrees));
  314. oInfo[playerid][i][ZLoc] = Z;
  315. oInfo[playerid][i][XRot] = 0.0;
  316. oInfo[playerid][i][YRot] = 0.0;
  317. oInfo[playerid][i][ZRot] = 0.0;
  318. oInfo[playerid][i][objectID] = CreateObject(model,X + (distance * floatsin(-rot, degrees)), Y + (distance * floatcos(-rot, degrees)), Z,0,0,0);
  319. pInfo[playerid][totalobjects] ++;
  320. new string[100];
  321. format(string, sizeof(string), "Created object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) %.1f meter infront of you.", i, oInfo[playerid][i][modelID], distance);
  322. SendClientMessage(playerid, COLOR_INFO, string);
  323. }
  324. #if ALLOW_EDIT_OBJECT_ON_CREATE == true
  325. if(pInfo[playerid][EditObjectOnCreate] == true)
  326. {
  327. pInfo[playerid][editobject] = i;
  328. EditObject(playerid, oInfo[playerid][i][objectID]);
  329. }
  330. #endif
  331. #if ALLOW_USE_3D_LABELS == true
  332. if(pInfo[playerid][UseLabels] == true)
  333. {
  334. new labeltext[200];
  335. format(labeltext, 200, "Object Number: %i\nModel ID: %i\nRotation: 0.0, 0.0, 0.0", i, model);
  336. oInfo[playerid][i][labelID] = CreatePlayer3DTextLabel(playerid, labeltext, -1, oInfo[playerid][i][XLoc], oInfo[playerid][i][YLoc], oInfo[playerid][i][ZLoc], 10.0, 0, 0, 0);
  337. }
  338. #endif
  339. break;
  340. }
  341. }
  342. }
  343. else
  344. {
  345. SendClientErrorMessage(playerid, 2);
  346. }
  347. }
  348. return 1;
  349. }
  350.  
  351. CMD:deo(playerid, params[])
  352. {
  353. #if USE_COMMAND_SHORTCUTS == true
  354. return cmd_deleteobject(playerid, params);
  355. #else
  356. SendClientErrorMessage(playerid, 8);
  357. #endif
  358. }
  359.  
  360. CMD:deleteobject(playerid, params[])
  361. {
  362. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  363. new object;
  364. if(sscanf(params, "i", object))
  365. {
  366. SendClientMessage(playerid, COLOR_USAGE, "Usage: /deleteobject [object number]");
  367. SendClientMessage(playerid, COLOR_USAGE2, "> Deleted the defined object number.");
  368. #if USE_COMMAND_SHORTCUTS == true
  369. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /deo.");
  370. #endif
  371. }
  372. else
  373. {
  374. if(pInfo[playerid][totalobjects] !=0)
  375. {
  376. if(oInfo[playerid][object][created] == 1)
  377. {
  378. DestroyObject(oInfo[playerid][object][objectID]);
  379. pInfo[playerid][totalobjects]--;
  380. new string[100];
  381. format(string, sizeof(string), "You have succesfully deleted object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}).", object, oInfo[playerid][object][modelID]);
  382. SendClientMessage(playerid, COLOR_INFO, string);
  383. oInfo[playerid][object][created] = 0;
  384. oInfo[playerid][object][objectID] = INVALID_OBJECT_ID;
  385. oInfo[playerid][object][modelID] = 0;
  386. oInfo[playerid][object][XLoc] = 0.0;
  387. oInfo[playerid][object][YLoc] = 0.0;
  388. oInfo[playerid][object][ZLoc] = 0.0;
  389. oInfo[playerid][object][XRot] = 0.0;
  390. oInfo[playerid][object][YRot] = 0.0;
  391. oInfo[playerid][object][ZRot] = 0.0;
  392. oInfo[playerid][object][indexused] = 0;
  393. oInfo[playerid][object][modelused] = 0;
  394. oInfo[playerid][object][txdused] = 0;
  395. oInfo[playerid][object][textureused] = 0;
  396. oInfo[playerid][object][colorused] = 0;
  397. oInfo[playerid][object][matindex] = -1;
  398. oInfo[playerid][object][matmodel] = -1;
  399. new str1[15], str2[15], str3[15];
  400. format(str1, sizeof(str1), "%i_txdname", object);
  401. format(str2, sizeof(str2), "%i_texturename", object);
  402. format(str3, sizeof(str3), "%i_color", object);
  403. DeletePVar(playerid, str1);
  404. DeletePVar(playerid, str2);
  405. DeletePVar(playerid, str3);
  406. oInfo[playerid][object][usesmaterial] = 0;
  407. }
  408. else
  409. {
  410. SendClientErrorMessage(playerid, 0);
  411. }
  412. }
  413. else
  414. {
  415. SendClientErrorMessage(playerid, 1);
  416. }
  417. }
  418. return 1;
  419. }
  420.  
  421. CMD:deao(playerid, params[])
  422. {
  423. #if USE_COMMAND_SHORTCUTS == true
  424. return cmd_deleteallobjects(playerid, params);
  425. #else
  426. SendClientErrorMessage(playerid, 8);
  427. #endif
  428. }
  429.  
  430. CMD:deleteallobjects(playerid, params[])
  431. {
  432. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  433. if(pInfo[playerid][totalobjects] !=0)
  434. {
  435. DeleteAllObjects(playerid);
  436. SendClientInfoMessage(playerid, "You have successfully deleted all objects.");
  437. }
  438. else SendClientErrorMessage(playerid, 1);
  439. return 1;
  440. }
  441.  
  442. CMD:neo(playerid, params[])
  443. {
  444. #if USE_COMMAND_SHORTCUTS == true
  445. return cmd_nearestobject(playerid, params);
  446. #else
  447. SendClientErrorMessage(playerid, 8);
  448. #endif
  449. }
  450.  
  451. CMD:nearestobject(playerid, params[])
  452. {
  453. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  454. if(pInfo[playerid][totalobjects] != 0)
  455. {
  456. if(pInfo[playerid][flyeditor] == 1) return SendClientErrorMessage(playerid, 9);
  457. new Float: px, Float: py, Float: pz;
  458. new Float: oX, Float: oY, Float: oZ;
  459. GetPlayerPos(playerid, px, py, pz);
  460. new Float:currentdistance, Float:distance = 99999999.9;
  461. new object;
  462. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  463. {
  464. GetObjectPos(oInfo[playerid][i][objectID], oX, oY, oZ);
  465. currentdistance = GetPlayerDistanceFromPoint(playerid, oX, oY, oZ);
  466. if(currentdistance < distance)
  467. {
  468. object = i;
  469. distance = currentdistance;
  470. }
  471. }
  472. new string[128];
  473. format(string,sizeof(string),"The closest object to you is object number {F58282}%i{F5F582} (Distance: %.1fm).", object, distance);
  474. SendClientInfoMessage(playerid, string);
  475. }
  476. else
  477. {
  478. SendClientErrorMessage(playerid, 1);
  479. }
  480. return 1;
  481. }
  482.  
  483. CMD:goo(playerid, params[])
  484. {
  485. #if USE_COMMAND_SHORTCUTS == true
  486. return cmd_gotoobject(playerid, params);
  487. #else
  488. SendClientErrorMessage(playerid, 8);
  489. #endif
  490. }
  491.  
  492. CMD:gotoobject(playerid, params[])
  493. {
  494. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  495. if(pInfo[playerid][flyeditor] == 1) return SendClientErrorMessage(playerid, 9);
  496. new object;
  497. if(sscanf(params, "i", object))
  498. {
  499. SendClientMessage(playerid, COLOR_USAGE, "Usage: /gotoobject [object number]");
  500. SendClientMessage(playerid, COLOR_USAGE2, "> Teleports you to the defined object number.");
  501. #if USE_COMMAND_SHORTCUTS == true
  502. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /goo.");
  503. #endif
  504. }
  505. else
  506. {
  507. if(pInfo[playerid][totalobjects] != 0)
  508. {
  509. if(oInfo[playerid][object][created] == 1)
  510. {
  511. new Float:X, Float:Y, Float:Z;
  512. new string[100];
  513. GetObjectPos(oInfo[playerid][object][objectID], X, Y, Z);
  514. SetPlayerPos(playerid, X + 1.0, Y + 1.0, Z + 5.0);
  515. format(string, sizeof(string), "You have teleported yourself to object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}).", object, oInfo[playerid][object][modelID]);
  516. SendClientInfoMessage(playerid, string);
  517. }
  518. else
  519. {
  520. SendClientErrorMessage(playerid, 0);
  521. }
  522. }
  523. else
  524. {
  525. SendClientErrorMessage(playerid, 1);
  526. }
  527. }
  528. return 1;
  529. }
  530.  
  531. CMD:rpom(playerid, params[])
  532. {
  533. #if USE_COMMAND_SHORTCUTS == true
  534. return cmd_replaceobjectmodel(playerid, params);
  535. #else
  536. SendClientErrorMessage(playerid, 8);
  537. #endif
  538. }
  539.  
  540. CMD:replaceobjectmodel(playerid, params[])
  541. {
  542. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  543. new object, model, oldmodel;
  544. if(sscanf(params, "ii", object, model))
  545. {
  546. SendClientMessage(playerid, COLOR_USAGE, "Usage: /replaceobjectmodel [object number] [new model]");
  547. SendClientMessage(playerid, COLOR_USAGE2, "> Replaces the model of the defined object number with the new model.");
  548. #if USE_COMMAND_SHORTCUTS == true
  549. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /rpom.");
  550. #endif
  551. }
  552. else
  553. {
  554. if(pInfo[playerid][totalobjects] != 0)
  555. {
  556. if(oInfo[playerid][object][created] == 1)
  557. {
  558. oldmodel = oInfo[playerid][object][modelID];
  559. DestroyObject(oInfo[playerid][object][objectID]);
  560. oInfo[playerid][object][objectID] = CreateObject(model, oInfo[playerid][object][XLoc],oInfo[playerid][object][YLoc],oInfo[playerid][object][ZLoc],oInfo[playerid][object][XRot],oInfo[playerid][object][YRot],oInfo[playerid][object][ZRot]);
  561. oInfo[playerid][object][modelID] = model;
  562. if(oInfo[playerid][object][usesmaterial] == 1){
  563. if(pInfo[playerid][KeepMaterial] == true){
  564. ChangeObjectMaterial(playerid, object);
  565. }
  566. else
  567. ResetObjectMaterial(playerid, object);
  568. }
  569. new string[135];
  570. format(string, sizeof(string), "You succesfully replaced the model of object {F58282}%i{F5F582} (Model: {F58282}%i{F5F582}) with model {F58282}%i{F5F582}.", object, oldmodel, model);
  571. SendClientInfoMessage(playerid, string);
  572. }
  573. else
  574. {
  575. SendClientErrorMessage(playerid, 0);
  576. }
  577. }
  578. else
  579. {
  580. SendClientErrorMessage(playerid, 1);
  581. }
  582. }
  583. return 1;
  584. }
  585.  
  586. CMD:saveobjects(playerid, params[])
  587. {
  588. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  589. {
  590. new dg1[60];
  591. format(dg1, sizeof(dg1), "Enter the name of the file you want to save the objects in:");
  592. ShowPlayerDialog(playerid, DIALOG_MAP_SAVENAME, DIALOG_STYLE_INPUT,"Save objects",dg1,"Save","Cancel");
  593. }
  594. return 1;
  595. }
  596.  
  597. CMD:exportobjects(playerid, params[])
  598. {
  599. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  600. #if ALLOW_EXPORT_MAP_FILE == false
  601. if(IsPlayerAdmin(playerid))
  602. {
  603. new dg1[65];
  604. format(dg1, sizeof(dg1), "Enter the name of the file you want to export the objects to:");
  605. ShowPlayerDialog(playerid, DIALOG_MAP_EXPORTNAME, DIALOG_STYLE_INPUT,"Export name",dg1,"Export","Cancel");
  606. }
  607. else return SendClientErrorMessage(playerid, 3);
  608. #else
  609. new dg1[65];
  610. format(dg1, sizeof(dg1), "Enter the name of the file you want to export the objects to:");
  611. ShowPlayerDialog(playerid, DIALOG_MAP_EXPORTNAME, DIALOG_STYLE_INPUT,"Export name",dg1,"Export","Cancel");
  612. #endif
  613. return 1;
  614. }
  615.  
  616. CMD:loadobjects(playerid, params[])
  617. {
  618. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  619. ShowPlayerDialog(playerid, DIALOG_MAP_LOAD, DIALOG_STYLE_INPUT, "Load map","Enter the name of the file you want to load:","Load","Cancel");
  620. return 1;
  621. }
  622.  
  623. CMD:edo(playerid, params[])
  624. {
  625. #if USE_COMMAND_SHORTCUTS == true
  626. return cmd_editobject(playerid, params);
  627. #else
  628. SendClientErrorMessage(playerid, 8);
  629. #endif
  630. }
  631.  
  632. CMD:editobject(playerid, params[])
  633. {
  634. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  635. new object;
  636. if(sscanf(params, "i", object))
  637. {
  638. SendClientMessage(playerid, COLOR_USAGE, "Usage: /editobject [object number]");
  639. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to modify the position and rotation of the defined object number with your mouse.");
  640. #if USE_COMMAND_SHORTCUTS == true
  641. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /edo.");
  642. #endif
  643. }
  644. else
  645. {
  646. if(pInfo[playerid][totalobjects] !=0)
  647. {
  648. if(oInfo[playerid][object][created] == 1)
  649. {
  650. EditObject(playerid, oInfo[playerid][object][objectID]);
  651. pInfo[playerid][editobject] = object;
  652. }
  653. else
  654. {
  655. SendClientErrorMessage(playerid, 0);
  656. }
  657. }
  658. else
  659. {
  660. SendClientErrorMessage(playerid, 1);
  661. }
  662. }
  663. return 1;
  664. }
  665.  
  666. CMD:seo(playerid, params[])
  667. {
  668. #if USE_COMMAND_SHORTCUTS == true
  669. return cmd_selectobject(playerid, params);
  670. #else
  671. SendClientErrorMessage(playerid, 8);
  672. #endif
  673. }
  674.  
  675. CMD:selectobject(playerid, params[])
  676. {
  677. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  678. if(pInfo[playerid][totalobjects] !=0)
  679. {
  680. SelectObject(playerid);
  681. SendClientInfoMessage(playerid, "You can now select an object by clicking onto it with your cursor.");
  682. }
  683. else SendClientErrorMessage(playerid, 1);
  684. return 1;
  685. }
  686.  
  687. CMD:soxo(playerid, params[])
  688. {
  689. #if USE_COMMAND_SHORTCUTS == true
  690. return cmd_setobjectxoffset(playerid, params);
  691. #else
  692. SendClientErrorMessage(playerid, 8);
  693. #endif
  694. }
  695.  
  696. CMD:setobjectxoffset(playerid, params[])
  697. {
  698. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  699. new object, Float:offset;
  700. if(sscanf(params, "if", object, offset))
  701. {
  702. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectxoffset [object number] [value]");
  703. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to move the chosen object number on the X axis.");
  704. SendClientMessage(playerid, COLOR_USAGE2, "> Positive values will move the object eastbound, negative values westbound.");
  705. #if USE_COMMAND_SHORTCUTS == true
  706. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /soxo.");
  707. #endif
  708. }
  709. else
  710. {
  711. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  712. {
  713. #if USE_MAX_MOVE_DISTANCE == true
  714. if(offset > MAX_MOVE_DISTANCE) return SendClientErrorMessage(playerid, 6);
  715. #endif
  716. if(oInfo[playerid][object][created] == 1)
  717. {
  718. oInfo[playerid][object][XLoc]+=offset;
  719. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  720. new string[130];
  721. format(string, sizeof(string), "You have moved object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) {F58282}%.2f{F5F582}m on the X plane.", object, oInfo[playerid][object][modelID], offset);
  722. SendClientInfoMessage(playerid, string);
  723. }
  724. else SendClientErrorMessage(playerid, 0);
  725. }
  726. else
  727. {
  728. SendClientErrorMessage(playerid, 2);
  729. }
  730. }
  731. return 1;
  732. }
  733.  
  734. CMD:soyo(playerid, params[])
  735. {
  736. #if USE_COMMAND_SHORTCUTS == true
  737. return cmd_setobjectyoffset(playerid, params);
  738. #else
  739. SendClientErrorMessage(playerid, 8);
  740. #endif
  741. }
  742.  
  743. CMD:setobjectyoffset(playerid, params[])
  744. {
  745. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  746. new object, Float:offset;
  747. if(sscanf(params, "if", object, offset))
  748. {
  749. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectyoffset [object number] [value]");
  750. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to move the chosen object number on the Y axis.");
  751. SendClientMessage(playerid, COLOR_USAGE2, "> Positive values will move the object northbound, negative values southbound.");
  752. #if USE_COMMAND_SHORTCUTS == true
  753. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /soyo.");
  754. #endif
  755. }
  756. else
  757. {
  758. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  759. {
  760. #if USE_MAX_MOVE_DISTANCE == true
  761. if(offset > MAX_MOVE_DISTANCE) return SendClientErrorMessage(playerid, 6);
  762. #endif
  763. if(oInfo[playerid][object][created] == 1)
  764. {
  765. oInfo[playerid][object][YLoc]+=offset;
  766. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  767. new string[128];
  768. format(string, sizeof(string), "You have moved object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) {F58282}%.2f{F5F582}m on the Y plane.", object, oInfo[playerid][object][modelID], offset);
  769. SendClientInfoMessage(playerid, string);
  770. }
  771. else SendClientErrorMessage(playerid, 0);
  772. }
  773. else
  774. {
  775. SendClientErrorMessage(playerid, 2);
  776. }
  777. }
  778. return 1;
  779. }
  780.  
  781. CMD:sozo(playerid, params[])
  782. {
  783. #if USE_COMMAND_SHORTCUTS == true
  784. return cmd_setobjectzoffset(playerid, params);
  785. #else
  786. SendClientErrorMessage(playerid, 8);
  787. #endif
  788. }
  789.  
  790. CMD:setobjectzoffset(playerid, params[])
  791. {
  792. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  793. new object, Float:offset;
  794. if(sscanf(params, "if", object, offset))
  795. {
  796. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectzoffset [object number] [value]");
  797. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to move the chosen object number on the Z axis.");
  798. SendClientMessage(playerid, COLOR_USAGE2, "> Positive values will move the object up, negative values down.");
  799. #if USE_COMMAND_SHORTCUTS == true
  800. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /soyo.");
  801. #endif
  802. }
  803. else
  804. {
  805. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  806. {
  807. #if USE_MAX_MOVE_DISTANCE == true
  808. if(offset > MAX_MOVE_DISTANCE) return SendClientErrorMessage(playerid, 6);
  809. #endif
  810. if(oInfo[playerid][object][created] == 1)
  811. {
  812. oInfo[playerid][object][ZLoc]+=offset;
  813. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  814. new string[128];
  815. format(string, sizeof(string), "You have moved object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) {F58282}%.2f{F5F582}m on the Z plane.", object, oInfo[playerid][object][modelID], offset);
  816. SendClientInfoMessage(playerid, string);
  817. }
  818. else SendClientErrorMessage(playerid, 0);
  819. }
  820. else
  821. {
  822. SendClientErrorMessage(playerid, 2);
  823. }
  824. }
  825. return 1;
  826. }
  827.  
  828. CMD:soxr(playerid, params[])
  829. {
  830. #if USE_COMMAND_SHORTCUTS == true
  831. return cmd_setobjectxrotation(playerid, params);
  832. #else
  833. SendClientErrorMessage(playerid, 8);
  834. #endif
  835. }
  836.  
  837. CMD:setobjectxrotation(playerid, params[])
  838. {
  839. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  840. new object, Float:rotation;
  841. if(sscanf(params, "if", object, rotation))
  842. {
  843. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectxrotation [object number] [value]");
  844. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to set the X rotation value of the defined object number.");
  845. #if USE_COMMAND_SHORTCUTS == true
  846. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /soxr.");
  847. #endif
  848. }
  849. else
  850. {
  851. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  852. {
  853. if(oInfo[playerid][object][created] == 1)
  854. {
  855. oInfo[playerid][object][XRot] = rotation;
  856. SetObjectRot(oInfo[playerid][object][objectID], oInfo[playerid][object][XRot], oInfo[playerid][object][YRot], oInfo[playerid][object][ZRot]);
  857. new string[140];
  858. format(string, sizeof(string), "You have set the X rotation of object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) to {F58282}%.2f{F5F582} degrees.", object, oInfo[playerid][object][modelID], rotation);
  859. SendClientInfoMessage(playerid, string);
  860. }
  861. else SendClientErrorMessage(playerid, 0);
  862. }
  863. else
  864. {
  865. SendClientErrorMessage(playerid, 2);
  866. }
  867. }
  868. return 1;
  869. }
  870.  
  871. CMD:soyr(playerid, params[])
  872. {
  873. #if USE_COMMAND_SHORTCUTS == true
  874. return cmd_setobjectyrotation(playerid, params);
  875. #else
  876. SendClientErrorMessage(playerid, 8);
  877. #endif
  878. }
  879.  
  880. CMD:setobjectyrotation(playerid, params[])
  881. {
  882. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  883. new object, Float:rotation;
  884. if(sscanf(params, "if", object, rotation))
  885. {
  886. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectyrotation [object number] [value]");
  887. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to set the Y rotation value of the defined object number.");
  888. #if USE_COMMAND_SHORTCUTS == true
  889. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /soyr.");
  890. #endif
  891. }
  892. else
  893. {
  894. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  895. {
  896. if(oInfo[playerid][object][created] == 1)
  897. {
  898. oInfo[playerid][object][YRot] = rotation;
  899. SetObjectRot(oInfo[playerid][object][objectID], oInfo[playerid][object][XRot], oInfo[playerid][object][YRot], oInfo[playerid][object][ZRot]);
  900. new string[140];
  901. format(string, sizeof(string), "You have set the Y rotation of object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) to {F58282}%.2f{F5F582} degrees.", object, oInfo[playerid][object][modelID], rotation);
  902. SendClientInfoMessage(playerid, string);
  903. }
  904. else SendClientErrorMessage(playerid, 0);
  905. }
  906. else
  907. {
  908. SendClientErrorMessage(playerid, 2);
  909. }
  910. }
  911. return 1;
  912. }
  913.  
  914. CMD:sozr(playerid, params[])
  915. {
  916. #if USE_COMMAND_SHORTCUTS == true
  917. return cmd_setobjectzrotation(playerid, params);
  918. #else
  919. SendClientErrorMessage(playerid, 8);
  920. #endif
  921. }
  922.  
  923. CMD:setobjectzrotation(playerid, params[])
  924. {
  925. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  926. new object, Float:rotation;
  927. if(sscanf(params, "if", object, rotation))
  928. {
  929. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectzrotation [object number] [value]");
  930. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to set the Z rotation value of the defined object number.");
  931. #if USE_COMMAND_SHORTCUTS == true
  932. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /sozr.");
  933. #endif
  934. }
  935. else
  936. {
  937. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  938. {
  939. if(oInfo[playerid][object][created] == 1)
  940. {
  941. oInfo[playerid][object][ZRot] = rotation;
  942. SetObjectRot(oInfo[playerid][object][objectID], oInfo[playerid][object][XRot], oInfo[playerid][object][YRot], oInfo[playerid][object][ZRot]);
  943. new string[140];
  944. format(string, sizeof(string), "You have set the Z rotation of object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) to {F58282}%.2f{F5F582} degrees.", object, oInfo[playerid][object][modelID], rotation);
  945. SendClientInfoMessage(playerid, string);
  946. }
  947. else SendClientErrorMessage(playerid, 0);
  948. }
  949. else
  950. {
  951. SendClientErrorMessage(playerid, 2);
  952. }
  953. }
  954. return 1;
  955. }
  956.  
  957. CMD:sop(playerid, params[])
  958. {
  959. #if USE_COMMAND_SHORTCUTS == true
  960. return cmd_setobjectpos(playerid, params);
  961. #else
  962. SendClientErrorMessage(playerid, 8);
  963. #endif
  964. }
  965.  
  966. CMD:setobjectpos(playerid, params[])
  967. {
  968. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  969. new object, Float:X, Float:Y, Float:Z;
  970. if(sscanf(params, "ifff", object, X, Y, Z))
  971. {
  972. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectpos [object number] [X] [Y] [Z]");
  973. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to set the position of the defined object number to a certain coordinate.");
  974. #if USE_COMMAND_SHORTCUTS == true
  975. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /sop.");
  976. #endif
  977. }
  978. else
  979. {
  980. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  981. {
  982. if(oInfo[playerid][object][created] == 1)
  983. {
  984. oInfo[playerid][object][XLoc] = X;
  985. oInfo[playerid][object][YLoc] = Y;
  986. oInfo[playerid][object][ZLoc] = Z;
  987. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  988. new string[175];
  989. format(string, sizeof(string), "You have set the position of object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) to {F58282}%.2f{F5F582}, {F58282}%.2f{F5F582}, {F58282}%.2f{F5F582}.", object, oInfo[playerid][object][modelID], X, Y, Z);
  990. SendClientInfoMessage(playerid, string);
  991. }
  992. else SendClientErrorMessage(playerid, 0);
  993. }
  994. else
  995. {
  996. SendClientErrorMessage(playerid, 2);
  997. }
  998. }
  999. return 1;
  1000. }
  1001.  
  1002. CMD:saoxo(playerid, params[])
  1003. {
  1004. #if USE_COMMAND_SHORTCUTS == true
  1005. return cmd_setallobjectsxoffset(playerid, params);
  1006. #else
  1007. SendClientErrorMessage(playerid, 8);
  1008. #endif
  1009. }
  1010.  
  1011. CMD:setallobjectsxoffset(playerid, params[])
  1012. {
  1013. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1014. new Float:offset;
  1015. if(sscanf(params, "f", offset))
  1016. {
  1017. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setallobjectsxoffset [value]");
  1018. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to move all your created objects on the X axis using the defined value.");
  1019. SendClientMessage(playerid, COLOR_USAGE2, "> Positive values will move the objects eastbound, negative values westbound.");
  1020. #if USE_COMMAND_SHORTCUTS == true
  1021. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /saoxo.");
  1022. #endif
  1023. }
  1024. else
  1025. {
  1026. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  1027. {
  1028. #if USE_MAX_MOVE_DISTANCE == true
  1029. if(offset > MAX_MOVE_DISTANCE) return SendClientErrorMessage(playerid, 6);
  1030. #endif
  1031. for(new object = 0; object < MAX_CREATED_OBJECTS; object++)
  1032. {
  1033. if(oInfo[playerid][object][created] == 1)
  1034. {
  1035. oInfo[playerid][object][XLoc]+=offset;
  1036. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  1037. }
  1038. }
  1039. new string[90];
  1040. format(string, sizeof(string), "You have moved all objects you created {F58282}%.2f{F5F582}m on the X plane.", offset);
  1041. SendClientInfoMessage(playerid, string);
  1042. }
  1043. else
  1044. {
  1045. SendClientErrorMessage(playerid, 2);
  1046. }
  1047. }
  1048. return 1;
  1049. }
  1050.  
  1051. CMD:saoyo(playerid, params[])
  1052. {
  1053. #if USE_COMMAND_SHORTCUTS == true
  1054. return cmd_setallobjectsyoffset(playerid, params);
  1055. #else
  1056. SendClientErrorMessage(playerid, 8);
  1057. #endif
  1058. }
  1059.  
  1060. CMD:setallobjectsyoffset(playerid, params[])
  1061. {
  1062. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1063. new Float:offset;
  1064. if(sscanf(params, "f", offset))
  1065. {
  1066. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setallobjectsyoffset [value]");
  1067. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to move all your created objects on the Y axis using the defined value.");
  1068. SendClientMessage(playerid, COLOR_USAGE2, "> Positive values will move the objects northbound, negative values southbound.");
  1069. #if USE_COMMAND_SHORTCUTS == true
  1070. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /saoyo.");
  1071. #endif
  1072. }
  1073. else
  1074. {
  1075. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  1076. {
  1077. #if USE_MAX_MOVE_DISTANCE == true
  1078. if(offset > MAX_MOVE_DISTANCE) return SendClientErrorMessage(playerid, 6);
  1079. #endif
  1080. for(new object = 0; object < MAX_CREATED_OBJECTS; object++)
  1081. {
  1082. if(oInfo[playerid][object][created] == 1)
  1083. {
  1084. oInfo[playerid][object][YLoc]+=offset;
  1085. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  1086. }
  1087. }
  1088. new string[90];
  1089. format(string, sizeof(string), "You have moved all objects you created {F58282}%.2f{F5F582}m on the Y plane.", offset);
  1090. SendClientInfoMessage(playerid, string);
  1091. }
  1092. else
  1093. {
  1094. SendClientErrorMessage(playerid, 2);
  1095. }
  1096. }
  1097. return 1;
  1098. }
  1099.  
  1100. CMD:saozo(playerid, params[])
  1101. {
  1102. #if USE_COMMAND_SHORTCUTS == true
  1103. return cmd_setallobjectszoffset(playerid, params);
  1104. #else
  1105. SendClientErrorMessage(playerid, 8);
  1106. #endif
  1107. }
  1108.  
  1109. CMD:setallobjectszoffset(playerid, params[])
  1110. {
  1111. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1112. new Float:offset;
  1113. if(sscanf(params, "f", offset))
  1114. {
  1115. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setallobjectszoffset [value]");
  1116. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to move all your created objects on the Z axis using the defined value.");
  1117. SendClientMessage(playerid, COLOR_USAGE2, "> Positive values will move the objects up, negative values down.");
  1118. #if USE_COMMAND_SHORTCUTS == true
  1119. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /saozo.");
  1120. #endif
  1121. }
  1122. else
  1123. {
  1124. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  1125. {
  1126. #if USE_MAX_MOVE_DISTANCE == true
  1127. if(offset > MAX_MOVE_DISTANCE) return SendClientErrorMessage(playerid, 6);
  1128. #endif
  1129. for(new object = 0; object < MAX_CREATED_OBJECTS; object++)
  1130. {
  1131. if(oInfo[playerid][object][created] == 1)
  1132. {
  1133. oInfo[playerid][object][ZLoc]+=offset;
  1134. SetObjectPos(oInfo[playerid][object][objectID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc]);
  1135. }
  1136. }
  1137. new string[90];
  1138. format(string, sizeof(string), "You have moved all objects you created {F58282}%.2f{F5F582}m on the Z plane.", offset);
  1139. SendClientInfoMessage(playerid, string);
  1140. }
  1141. else
  1142. {
  1143. SendClientErrorMessage(playerid, 2);
  1144. }
  1145. }
  1146. return 1;
  1147. }
  1148.  
  1149. CMD:duo(playerid, params[])
  1150. {
  1151. #if USE_COMMAND_SHORTCUTS == true
  1152. return cmd_duplicateobject(playerid, params);
  1153. #else
  1154. SendClientErrorMessage(playerid, 8);
  1155. #endif
  1156. }
  1157.  
  1158. CMD:duplicateobject(playerid, params[])
  1159. {
  1160. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1161. new object, Float:X, Float:Y, Float:Z;
  1162. if(sscanf(params, "ifff", object, X, Y, Z))
  1163. {
  1164. SendClientMessage(playerid, COLOR_USAGE, "Usage: /duplicateobject [object number] [X Offset] [Y Offset] [Z Offset]");
  1165. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to \"copy\" and object with a defined distance from the original object.");
  1166. #if USE_COMMAND_SHORTCUTS == true
  1167. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /duo.");
  1168. #endif
  1169. }
  1170. else
  1171. {
  1172. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  1173. {
  1174. if(oInfo[playerid][object][created] == 1)
  1175. {
  1176. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  1177. {
  1178. if(oInfo[playerid][i][created] == 0)
  1179. {
  1180. pInfo[playerid][editobject] = i;
  1181. oInfo[playerid][i][created] = 1;
  1182. oInfo[playerid][i][XLoc] = oInfo[playerid][object][XLoc] + X;
  1183. oInfo[playerid][i][YLoc] = oInfo[playerid][object][YLoc] + Y;
  1184. oInfo[playerid][i][ZLoc] = oInfo[playerid][object][ZLoc] + Z;
  1185. oInfo[playerid][i][XRot] = oInfo[playerid][object][XRot];
  1186. oInfo[playerid][i][YRot] = oInfo[playerid][object][YRot];
  1187. oInfo[playerid][i][ZRot] = oInfo[playerid][object][ZRot];
  1188. oInfo[playerid][i][modelID] = oInfo[playerid][object][modelID];
  1189. oInfo[playerid][i][objectID] = CreateObject(oInfo[playerid][i][modelID], oInfo[playerid][i][XLoc], oInfo[playerid][i][YLoc], oInfo[playerid][i][ZLoc], oInfo[playerid][i][XRot], oInfo[playerid][i][YRot], oInfo[playerid][i][ZRot]);
  1190. if(pInfo[playerid][TransferMaterial] == true)
  1191. {
  1192. if(oInfo[playerid][object][usesmaterial] == 1)
  1193. {
  1194. oInfo[playerid][i][usesmaterial] = 1;
  1195. oInfo[playerid][i][matindex] = oInfo[playerid][object][matindex];
  1196. oInfo[playerid][i][matmodel] = oInfo[playerid][object][matmodel];
  1197. oInfo[playerid][i][indexused] = 1;
  1198. oInfo[playerid][i][modelused] = 1;
  1199. oInfo[playerid][i][txdused] = 1;
  1200. oInfo[playerid][i][textureused] = 1;
  1201. oInfo[playerid][i][colorused] = 1;
  1202. new str[12], str2[16], str3[10];
  1203. new newf[20], newf2[20], newf3[20];
  1204. new txdname[25], texturename[25], color[25];
  1205. format(str, sizeof(str), "%i_txdname", object);
  1206. format(str2, sizeof(str2), "%i_texturename", object);
  1207. format(str3, sizeof(str3), "%i_color", object);
  1208. GetPVarString(playerid, str, txdname, sizeof(txdname));
  1209. GetPVarString(playerid, str2, texturename, sizeof(texturename));
  1210. GetPVarString(playerid, str3, color, sizeof(color));
  1211. format(newf, sizeof(newf), "%i_txdname", i);
  1212. format(newf2, sizeof(newf2), "%i_texturename", i);
  1213. format(newf3, sizeof(newf3), "%i_color", i);
  1214. SetPVarString(playerid, newf, txdname);
  1215. SetPVarString(playerid, newf2, texturename);
  1216. SetPVarString(playerid, newf3, color);
  1217. ChangeObjectMaterial(playerid, i);
  1218. }
  1219. }
  1220. else
  1221. oInfo[playerid][i][usesmaterial] = 0;
  1222. pInfo[playerid][totalobjects]++;
  1223. new dupinfo[180], numinfo[70];
  1224. format(dupinfo, sizeof(dupinfo), "You have duplicated object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) with the offset {F58282}%.2f{F5F582}m, {F58282}%.2f{F5F582}m, {F58282}%.2f{F5F582}m.", object, oInfo[playerid][object][modelID], X, Y, Z);
  1225. format(numinfo, sizeof(numinfo), "The number of the new created object is {F58282}%i{F5F582}.", i);
  1226. SendClientInfoMessage(playerid, dupinfo);
  1227. SendClientInfoMessage(playerid, numinfo);
  1228. #if ALLOW_EDIT_OBJECT_ON_DUPLICATE == true
  1229. if(pInfo[playerid][EditObjectOnDuplicate] == true)
  1230. {
  1231. pInfo[playerid][editobject] = i;
  1232. EditObject(playerid, oInfo[playerid][i][objectID]);
  1233. }
  1234. #endif
  1235. break;
  1236. }
  1237. }
  1238. }
  1239. else SendClientErrorMessage(playerid, 0);
  1240. }
  1241. else
  1242. {
  1243. SendClientErrorMessage(playerid, 2);
  1244. }
  1245. }
  1246. return 1;
  1247. }
  1248.  
  1249. CMD:som(playerid, params[])
  1250. {
  1251. #if USE_COMMAND_SHORTCUTS == true
  1252. return cmd_setobjectmaterial(playerid, params);
  1253. #else
  1254. SendClientErrorMessage(playerid, 8);
  1255. #endif
  1256. }
  1257.  
  1258. CMD:setobjectmaterial(playerid, params[])
  1259. {
  1260. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1261. if(pInfo[playerid][UseMaterialDialog] == true)
  1262. {
  1263. new object;
  1264. if(sscanf(params, "i", object))
  1265. {
  1266. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectmaterial [object number]");
  1267. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to change the texture of the defined object number.");
  1268. #if USE_COMMAND_SHORTCUTS == true
  1269. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /som.");
  1270. #endif
  1271. }
  1272. else
  1273. {
  1274. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  1275. {
  1276. if(oInfo[playerid][object][created] == 1)
  1277. {
  1278. pInfo[playerid][editobject] = object;
  1279. ShowPlayerMaterialDialog(playerid, object);
  1280. }
  1281. else SendClientErrorMessage(playerid, 0);
  1282. }
  1283. else
  1284. {
  1285. SendClientErrorMessage(playerid, 2);
  1286. }
  1287. }
  1288. }
  1289. else
  1290. {
  1291. new object, materialindex, mamodel, txdname[50], texturename[50], color[50];
  1292. if(sscanf(params, "iiis[50]s[50]s[50]", object, materialindex, mamodel, txdname, texturename, color))
  1293. {
  1294. SendClientMessage(playerid, COLOR_USAGE, "Usage: /setobjectmaterial [object number] [materialindex] [modelid] [txdname] [texturename] [color]");
  1295. SendClientMessage(playerid, COLOR_USAGE2, "> Allows you to change the texture of the defined object number.");
  1296. SendClientMessage(playerid, COLOR_USAGE2, "> Materialindex = The part of the object you want to change.");
  1297. SendClientMessage(playerid, COLOR_USAGE2, "> Modelid = The ID of the model the replacement texture is from (Use \"0\" for transparent).");
  1298. SendClientMessage(playerid, COLOR_USAGE2, "> Txdname = The name of the .txd file which contains the texture (Use \"none\" for transparent).");
  1299. SendClientMessage(playerid, COLOR_USAGE2, "> Texturename = The name of the texture (Use \"none\" for transparent).");
  1300. SendClientMessage(playerid, COLOR_USAGE2, "> Color = The color you want to paint the texture with in AABBGGRR format. (Use \"0\" for default texture color).");
  1301. #if USE_COMMAND_SHORTCUTS == true
  1302. SendClientMessage(playerid, COLOR_USAGE2, "> The shortcut for this command is /som.");
  1303. #endif
  1304. }
  1305. else
  1306. {
  1307. if(pInfo[playerid][totalobjects] < MAX_CREATED_OBJECTS)
  1308. {
  1309. if(oInfo[playerid][object][created] == 1)
  1310. {
  1311. pInfo[playerid][editobject] = object;
  1312. oInfo[playerid][pInfo[playerid][editobject]][matindex] = materialindex;
  1313. oInfo[playerid][pInfo[playerid][editobject]][matmodel] = mamodel;
  1314. oInfo[playerid][pInfo[playerid][editobject]][txdused] = 1;
  1315. oInfo[playerid][pInfo[playerid][editobject]][textureused] = 1;
  1316. oInfo[playerid][pInfo[playerid][editobject]][colorused] = 1;
  1317. oInfo[playerid][pInfo[playerid][editobject]][modelused] = 1;
  1318. oInfo[playerid][pInfo[playerid][editobject]][indexused] = 1;
  1319. new str[20];
  1320. format(str, sizeof(str), "%i_txdname", pInfo[playerid][editobject]);
  1321. SetPVarString(playerid, str, txdname);
  1322. new str2[20];
  1323. format(str2, sizeof(str2), "%i_texturename", pInfo[playerid][editobject]);
  1324. SetPVarString(playerid, str2, texturename);
  1325. new str3[20];
  1326. format(str3, sizeof(str3), "%i_color", pInfo[playerid][editobject]);
  1327. if(!strlen(color))
  1328. SetPVarString(playerid, str3, "0");
  1329. else
  1330. SetPVarString(playerid, str3, color);
  1331. ChangeObjectMaterial(playerid, pInfo[playerid][editobject]);
  1332. }
  1333. else SendClientErrorMessage(playerid, 0);
  1334. }
  1335. else
  1336. {
  1337. SendClientErrorMessage(playerid, 2);
  1338. }
  1339. }
  1340. }
  1341. return 1;
  1342. }
  1343.  
  1344. CMD:editorsettings(playerid, params[])
  1345. {
  1346. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1347. ShowPlayerSettingsMenu(playerid);
  1348. return 1;
  1349. }
  1350.  
  1351. CMD:editorcommands(playerid, params[])
  1352. {
  1353. ShowPlayerCommandHelp(playerid);
  1354. return 1;
  1355. }
  1356.  
  1357. CMD:esettingshelp(playerid, params[])
  1358. {
  1359. ShowPlayerSettingsHelp(playerid);
  1360. return 1;
  1361. }
  1362.  
  1363. CMD:fm(playerid, params[])
  1364. {
  1365. #if USE_COMMAND_SHORTCUTS == true
  1366. return cmd_flyeditor(playerid, params);
  1367. #else
  1368. SendClientErrorMessage(playerid, 8);
  1369. #endif
  1370. }
  1371.  
  1372. CMD:flyeditor(playerid, params[])
  1373. {
  1374. if(pInfo[playerid][editing] != true) return SendClientErrorMessage(playerid, 7);
  1375. if(pInfo[playerid][flyeditor] == 0)
  1376. Startflyeditor(playerid);
  1377. else
  1378. Endflyeditor(playerid);
  1379. return 1;
  1380. }
  1381.  
  1382. CMD:toggleeditor(playerid, params[])
  1383. {
  1384. #if TOGGLED_ONLY == true
  1385. new pID;
  1386. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WARNING, "Sorry, this command can only be used by RCON admins.");
  1387. if(sscanf(params, "r", pID))
  1388. {
  1389. SendClientMessage(playerid, COLOR_USAGE, "Usage: /toggleeditor [playerid]");
  1390. SendClientMessage(playerid, COLOR_USAGE2, "> Allows a player to use the object editor.");
  1391. }
  1392. else
  1393. {
  1394. if(IsPlayerConnected(pID))
  1395. {
  1396. if(pInfo[playerid][canuse] == 0)
  1397. {
  1398. pInfo[playerid][canuse] = 1;
  1399. new togglename[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
  1400. GetPlayerName(pID, togglename, MAX_PLAYER_NAME);
  1401. GetPlayerName(playerid, adminname, MAX_PLAYER_NAME);
  1402. new string[100], string2[100];
  1403. format(string, sizeof(string), "You have allowed %s to use the object editor.", togglename);
  1404. format(string2, sizeof(string2), "Admin %s has allowed you to use the object editor.", adminname);
  1405. SendClientInfoMessage(playerid, string);
  1406. SendClientInfoMessage(pID, string2);
  1407. }
  1408. else
  1409. {
  1410. pInfo[playerid][canuse] = 0;
  1411. new togglename[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
  1412. GetPlayerName(pID, togglename, MAX_PLAYER_NAME);
  1413. GetPlayerName(playerid, adminname, MAX_PLAYER_NAME);
  1414. new string[100], string2[100];
  1415. format(string, sizeof(string), "You have taken %s the permission to use the object editor.", togglename);
  1416. format(string2, sizeof(string2), "Admin %s has taken you the permission to use the object editor.", adminname);
  1417. SendClientInfoMessage(playerid, string);
  1418. SendClientInfoMessage(pID, string2);
  1419. if(pInfo[pID][editing] == true)
  1420. {
  1421. SendClientMessage(playerid, -1, "[Editor {F58282}OFF{FFFFFF}]");
  1422. DeleteAllObjects(playerid);
  1423. ResetAllValues(playerid);
  1424. SendClientInfoMessage(playerid, "You have left the editor. | All your objects have been automatically deleted.");
  1425. pInfo[playerid][editing] = false;
  1426. }
  1427. }
  1428. }
  1429. else SendClientErrorMessage(playerid, 10);
  1430. }
  1431. #else
  1432. SendClientMessage(playerid, COLOR_WARNING, "The editor is free for everyone, you don't have to give permissions.");
  1433. #endif
  1434. return 1;
  1435. }
  1436.  
  1437. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  1438. {
  1439. if((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
  1440. {
  1441. if((pInfo[playerid][flyeditor] == 1) && (pInfo[playerid][editing] == true))
  1442. {
  1443. if(pInfo[playerid][totalobjects] == 0) return SendClientErrorMessage(playerid, 1);
  1444. SelectObject(playerid);
  1445. }
  1446. }
  1447. return 1;
  1448. }
  1449.  
  1450. public OnPlayerUpdate(playerid)
  1451. {
  1452. if((pInfo[playerid][editing] == true) && (pInfo[playerid][flyeditor] == 1))
  1453. {
  1454. new keys,ud,lr;
  1455. GetPlayerKeys(playerid,keys,ud,lr);
  1456. if(pInfo[playerid][mode] && (GetTickCount() - pInfo[playerid][lastmove] > 100))
  1457. {
  1458. MoveCamera(playerid);
  1459. }
  1460.  
  1461. if(pInfo[playerid][udold] != ud || pInfo[playerid][lrold] != lr)
  1462. {
  1463. if((pInfo[playerid][udold] != 0 || pInfo[playerid][lrold] != 0) && ud == 0 && lr == 0)
  1464. {
  1465. StopPlayerObject(playerid, pInfo[playerid][flyobject]);
  1466. pInfo[playerid][mode] = 0;
  1467. pInfo[playerid][accelmul] = 0.0;
  1468. }
  1469. else
  1470. {
  1471.  
  1472. pInfo[playerid][mode] = GetMoveDirectionFromKeys(ud, lr);
  1473. MoveCamera(playerid);
  1474. }
  1475. }
  1476. pInfo[playerid][udold] = ud; pInfo[playerid][lrold] = lr;
  1477. return 0;
  1478. }
  1479. return 1;
  1480. }
  1481.  
  1482. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1483. {
  1484. switch(dialogid)
  1485. {
  1486. case DIALOG_MAP_SAVENAME:
  1487. {
  1488. if(response)
  1489. {
  1490. if(strlen(inputtext))
  1491. {
  1492. SaveMap(playerid, inputtext);
  1493. }
  1494. else
  1495. {
  1496. new dg1[101];
  1497. format(dg1, sizeof(dg1), "Enter the name of the file you want to save the objects in:\n\n{F58282}You need to enter a file name.");
  1498. ShowPlayerDialog(playerid, DIALOG_MAP_SAVENAME, DIALOG_STYLE_INPUT,"Save name",dg1,"Save","Cancel");
  1499. }
  1500. }
  1501. }
  1502. case DIALOG_MAP_EXPORTNAME:
  1503. {
  1504. if(response)
  1505. {
  1506. if(strlen(inputtext))
  1507. {
  1508. ExportMap(playerid, inputtext);
  1509. }
  1510. else
  1511. {
  1512. new dg1[103];
  1513. format(dg1, sizeof(dg1), "Enter the name of the file you want to export the objects to:\n\n{F58282}You need to enter a file name.");
  1514. ShowPlayerDialog(playerid, DIALOG_MAP_EXPORTNAME, DIALOG_STYLE_INPUT,"Export name",dg1,"Export","Cancel");
  1515. }
  1516. }
  1517. }
  1518. case DIALOG_MAP_LOAD:
  1519. {
  1520. if(response)
  1521. {
  1522. if(strlen(inputtext))
  1523. {
  1524. LoadMap(playerid, inputtext);
  1525. }
  1526. else
  1527. {
  1528. new dg1[86];
  1529. format(dg1, sizeof(dg1), "Enter the name of the file you want to load:\n\n{F58282}You need to enter a file name.");
  1530. ShowPlayerDialog(playerid, DIALOG_MAP_LOAD, DIALOG_STYLE_INPUT, "Load map",dg1,"Load","Cancel");
  1531. }
  1532. }
  1533. }
  1534. case DIALOG_SELECTMENU:
  1535. {
  1536. if(response)
  1537. {
  1538. switch(listitem)
  1539. {
  1540. case 0:
  1541. {
  1542. EditObject(playerid, oInfo[playerid][pInfo[playerid][editobject]][objectID]);
  1543. }
  1544. case 1:
  1545. {
  1546. ShowPlayerDialog(playerid, DIALOG_CHANGEMODEL, DIALOG_STYLE_INPUT,"Replacement model","Enter the model ID you want to replace the object with","Replace","Cancel");
  1547. }
  1548. case 2:
  1549. {
  1550. new object = pInfo[playerid][editobject];
  1551. DestroyObject(oInfo[playerid][object][objectID]);
  1552. pInfo[playerid][totalobjects]--;
  1553. new string[88];
  1554. format(string, sizeof(string), "You have succesfully deleted object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}).", object, oInfo[playerid][object][modelID]);
  1555. SendClientMessage(playerid, COLOR_INFO, string);
  1556. oInfo[playerid][object][created] = 0;
  1557. oInfo[playerid][object][objectID] = INVALID_OBJECT_ID;
  1558. oInfo[playerid][object][modelID] = 0;
  1559. oInfo[playerid][object][XLoc] = 0.0;
  1560. oInfo[playerid][object][YLoc] = 0.0;
  1561. oInfo[playerid][object][ZLoc] = 0.0;
  1562. oInfo[playerid][object][XRot] = 0.0;
  1563. oInfo[playerid][object][YRot] = 0.0;
  1564. oInfo[playerid][object][ZRot] = 0.0;
  1565. oInfo[playerid][object][indexused] = 0;
  1566. oInfo[playerid][object][modelused] = 0;
  1567. oInfo[playerid][object][txdused] = 0;
  1568. oInfo[playerid][object][textureused] = 0;
  1569. oInfo[playerid][object][colorused] = 0;
  1570. oInfo[playerid][object][matindex] = -1;
  1571. oInfo[playerid][object][matmodel] = -1;
  1572. new str1[20], str2[20], str3[20];
  1573. format(str1, sizeof(str1), "%i_txdname", object);
  1574. format(str2, sizeof(str2), "%i_texturename", object);
  1575. format(str3, sizeof(str3), "%i_color", object);
  1576. DeletePVar(playerid, str1);
  1577. DeletePVar(playerid, str2);
  1578. DeletePVar(playerid, str3);
  1579. oInfo[playerid][object][usesmaterial] = 0;
  1580. }
  1581. }
  1582. }
  1583. }
  1584. case DIALOG_CHANGEMODEL:
  1585. {
  1586. if(response)
  1587. {
  1588. if(strlen(inputtext))
  1589. {
  1590. if(IsNumeric(inputtext))
  1591. {
  1592. new model, oldmodel;
  1593. new object = pInfo[playerid][editobject];
  1594. oldmodel = oInfo[playerid][object][modelID];
  1595. model = strval(inputtext);
  1596. DestroyObject(oInfo[playerid][object][objectID]);
  1597. oInfo[playerid][object][objectID] = CreateObject(model, oInfo[playerid][object][XLoc],oInfo[playerid][object][YLoc],oInfo[playerid][object][ZLoc],oInfo[playerid][object][XRot],oInfo[playerid][object][YRot],oInfo[playerid][object][ZRot]);
  1598. oInfo[playerid][object][modelID] = model;
  1599. new string[128];
  1600. if(pInfo[playerid][KeepMaterial] == true)
  1601. ChangeObjectMaterial(playerid, object);
  1602. else
  1603. ResetObjectMaterial(playerid, object);
  1604. format(string, sizeof(string), "You succesfully replaced the model of object {F58282}%i{F5F582} (Model: {F58282}%i{F5F582}) with model {F58282}%i{F5F582}.", object, oldmodel, model);
  1605. SendClientInfoMessage(playerid, string);
  1606. }
  1607. else ShowPlayerDialog(playerid, DIALOG_CHANGEMODEL, DIALOG_STYLE_INPUT,"Replacement model","Enter the model ID you want to replace the object with\n\n{91FF91}You may enter numbers only.","Replace","Cancel");
  1608. }
  1609. else ShowPlayerDialog(playerid, DIALOG_CHANGEMODEL, DIALOG_STYLE_INPUT,"Replacement model","Enter the model ID you want to replace the object with\n\n{91FF91}You need to enter a value.","Replace","Cancel");
  1610. }
  1611. }
  1612. case DIALOG_SETTINGS:
  1613. {
  1614. if(response)
  1615. {
  1616. switch(listitem)
  1617. {
  1618. case 0:
  1619. {
  1620. #if ALLOW_EDIT_OBJECT_ON_CREATE == true
  1621. if(pInfo[playerid][EditObjectOnCreate] == true)
  1622. pInfo[playerid][EditObjectOnCreate] = false;
  1623. else
  1624. pInfo[playerid][EditObjectOnCreate] = true;
  1625. #endif
  1626. }
  1627. case 1:
  1628. {
  1629. #if ALLOW_EDIT_OBJECT_ON_DUPLICATE == true
  1630. if(pInfo[playerid][EditObjectOnDuplicate] == true)
  1631. pInfo[playerid][EditObjectOnDuplicate] = false;
  1632. else
  1633. pInfo[playerid][EditObjectOnDuplicate] = true;
  1634. #endif
  1635. }
  1636. case 2:
  1637. {
  1638. #if ALLOW_USE_MATERIAL_CHANGE_DIALOG == true
  1639. if(pInfo[playerid][UseMaterialDialog] == true)
  1640. pInfo[playerid][UseMaterialDialog] = false;
  1641. else
  1642. pInfo[playerid][UseMaterialDialog] = true;
  1643. #endif
  1644. }
  1645. case 3:
  1646. {
  1647. #if ALLOW_TRANSFER_MATERIAL == true
  1648. if(pInfo[playerid][TransferMaterial] == true)
  1649. pInfo[playerid][TransferMaterial] = false;
  1650. else
  1651. pInfo[playerid][TransferMaterial] = true;
  1652. #endif
  1653. }
  1654. case 4:
  1655. {
  1656. #if ALLOW_KEEP_MATERIAL == true
  1657. if(pInfo[playerid][KeepMaterial] == true)
  1658. pInfo[playerid][KeepMaterial] = false;
  1659. else
  1660. pInfo[playerid][KeepMaterial] = true;
  1661. #endif
  1662. }
  1663. case 5:
  1664. {
  1665. #if ALLOW_USE_CROSS == true
  1666. if(pInfo[playerid][UseCross] == true)
  1667. {
  1668. pInfo[playerid][UseCross] = false;
  1669. PlayerTextDrawHide(playerid, Cross[0]);
  1670. PlayerTextDrawHide(playerid, Cross[1]);
  1671. }
  1672. else
  1673. {
  1674. pInfo[playerid][UseCross] = true;
  1675. if(pInfo[playerid][flyeditor] == 1)
  1676. {
  1677. PlayerTextDrawShow(playerid, Cross[0]);
  1678. PlayerTextDrawShow(playerid, Cross[1]);
  1679. }
  1680. }
  1681. #endif
  1682. }
  1683. case 6:
  1684. {
  1685. #if ALLOW_USE_3D_LABELS == true
  1686. if(pInfo[playerid][UseLabels] == true)
  1687. {
  1688. if(pInfo[playerid][totalobjects] == 0) return 1;
  1689. ShowAllLabels(playerid);
  1690. pInfo[playerid][UseLabels] = false;
  1691. }
  1692. else
  1693. {
  1694. if(pInfo[playerid][totalobjects] == 0) return 1;
  1695. HideAllLabels(playerid);
  1696. pInfo[playerid][UseLabels] = true;
  1697. }
  1698. #endif
  1699. }
  1700. }
  1701. ShowPlayerSettingsMenu(playerid);
  1702. }
  1703. }
  1704. case DIALOG_MATERIALS:
  1705. {
  1706. if(response)
  1707. {
  1708. switch(listitem)
  1709. {
  1710. case 0: //materialindex
  1711. {
  1712. ShowPlayerDialog(playerid, DIALOG_MATERIALINDEX, DIALOG_STYLE_INPUT, "Materialindex","Enter the index (part) you want to change of the object:","Set","Back");
  1713. }
  1714. case 1: //modelid
  1715. {
  1716. new dg1[135];
  1717. format(dg1, sizeof(dg1), "Enter the model ID of the object on which the replacement texture is located\n\n{F5F582}Note: {A9C4E4}Use \"0\" for alpha (transparent)");
  1718. ShowPlayerDialog(playerid, DIALOG_MODELID, DIALOG_STYLE_INPUT,"Model ID",dg1,"Set","Back");
  1719. }
  1720. case 2: //txdname
  1721. {
  1722. new dg1[131];
  1723. format(dg1, sizeof(dg1), "Enter the name of the .txd file the replacement texture is located at\n\n{F5F582}Note: {A9C4E4}Use \"none\" for alpha (transparent)");
  1724. ShowPlayerDialog(playerid, DIALOG_TXDNAME, DIALOG_STYLE_INPUT,"TXD file name",dg1,"Set","Back");
  1725. }
  1726. case 3: //texturename
  1727. {
  1728. new dg1[121];
  1729. format(dg1, sizeof(dg1), "Enter the name of the texture you want to put on the object\n\n{F5F582}Note: {A9C4E4}Use \"none\" for alpha (transparent)");
  1730. ShowPlayerDialog(playerid, DIALOG_TEXTURENAME, DIALOG_STYLE_INPUT,"Texture name",dg1,"Set","Back");
  1731. }
  1732. case 4: //color
  1733. {
  1734. new dg1[64], dg2[150], dg3[64], dial[300];
  1735. format(dg1, sizeof(dg1), "Enter a color you want to pain the texture with");
  1736. format(dg2, sizeof(dg2), "{F58282}Important: {A9C4E4}The color has to be in {FFFFFF}AA{0069FF}BB{00FF00}GG{FF0000}RR {A9C4E4}format.\nExample: FF00FF00 (green)");
  1737. format(dg3, sizeof(dg3), "\n{F5F582}Note: {A9C4E4}Use \"0\" to use the default color of the texture.");
  1738. format(dial, sizeof(dial), "%s\n%s\n%s", dg1, dg2, dg3);
  1739. ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_INPUT,"Color",dial,"Set","Back");
  1740. }
  1741. case 5: //continue
  1742. {
  1743. if(IsAllFilledOut(playerid, pInfo[playerid][editobject]))
  1744. ChangeObjectMaterial(playerid, pInfo[playerid][editobject]);
  1745. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1746. }
  1747. case 6: //remove texture
  1748. {
  1749. if(oInfo[playerid][pInfo[playerid][editobject]][usesmaterial] == 1)
  1750. ResetObjectMaterial(playerid, pInfo[playerid][editobject]);
  1751. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1752. }
  1753. }
  1754. }
  1755. }
  1756. case DIALOG_MATERIALINDEX:
  1757. {
  1758. if(response)
  1759. {
  1760. if(strlen(inputtext))
  1761. {
  1762. if(IsNumeric(inputtext))
  1763. {
  1764. oInfo[playerid][pInfo[playerid][editobject]][indexused] = 1;
  1765. oInfo[playerid][pInfo[playerid][editobject]][matindex] = strval(inputtext);
  1766. ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1767. }
  1768. else ShowPlayerDialog(playerid, DIALOG_MATERIALINDEX, DIALOG_STYLE_INPUT, "Materialindex","Enter the index (part) you want to change of the object:\n{F58282}You may enter numbers only.","Set","Back");
  1769. }
  1770. else ShowPlayerDialog(playerid, DIALOG_MATERIALINDEX, DIALOG_STYLE_INPUT, "Materialindex","Enter the index (part) you want to change of the object:\n{F58282}You need to enter a value.","Set","Back");
  1771. }
  1772. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1773. }
  1774. case DIALOG_MODELID:
  1775. {
  1776. if(response)
  1777. {
  1778. if(strlen(inputtext))
  1779. {
  1780. if(IsNumeric(inputtext))
  1781. {
  1782. oInfo[playerid][pInfo[playerid][editobject]][modelused] = 1;
  1783. oInfo[playerid][pInfo[playerid][editobject]][matmodel] = strval(inputtext);
  1784. ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1785. }
  1786. else
  1787. {
  1788. new dg1[135], dg2[35], dial[200];
  1789. format(dg1, sizeof(dg1), "Enter the model ID of the object on which the replacement texture is located\n\n{F5F582}Note: {A9C4E4}Use \"0\" for alpha (transparent)");
  1790. format(dg2, sizeof(dg2), "{F58282}You may only enter numbers.");
  1791. format(dial, sizeof(dial), "%s\n\n%s", dg1, dg2);
  1792. ShowPlayerDialog(playerid, DIALOG_MODELID, DIALOG_STYLE_INPUT,"Model ID",dial,"Set","Back");
  1793. }
  1794. }
  1795. else
  1796. {
  1797. new dg1[135], dg2[35], dial[200];
  1798. format(dg1, sizeof(dg1), "Enter the model ID of the object on which the replacement texture is located\n\n{F5F582}Note: {A9C4E4}Use \"0\" for alpha (transparent)");
  1799. format(dg2, sizeof(dg2), "{F58282}You need to enter a value.");
  1800. format(dial, sizeof(dial), "%s\n\n%s", dg1, dg2);
  1801. ShowPlayerDialog(playerid, DIALOG_MODELID, DIALOG_STYLE_INPUT,"Model ID",dial,"Set","Back");
  1802. }
  1803. }
  1804. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1805. }
  1806. case DIALOG_TXDNAME:
  1807. {
  1808. if(response)
  1809. {
  1810. if(strlen(inputtext))
  1811. {
  1812. new str[20];
  1813. format(str, sizeof(str), "%i_txdname", pInfo[playerid][editobject]);
  1814. SetPVarString(playerid, str, inputtext);
  1815. oInfo[playerid][pInfo[playerid][editobject]][txdused] = 1;
  1816. ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1817. }
  1818. else
  1819. {
  1820. new dg1[131], dg2[35], dial[200];
  1821. format(dg1, sizeof(dg1), "Enter the name of the .txd file the replacement texture is located at\n\n{F5F582}Note: {A9C4E4}Use \"none\" for alpha (transparent)");
  1822. format(dg2, sizeof(dg2), "{F58282}You need to enter a name.");
  1823. format(dial, sizeof(dial), "%s\n\n%s", dg1, dg2);
  1824. ShowPlayerDialog(playerid, DIALOG_TXDNAME, DIALOG_STYLE_INPUT,"TXD file name",dial,"Set","Back");
  1825. }
  1826. }
  1827. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1828. }
  1829. case DIALOG_TEXTURENAME:
  1830. {
  1831. if(response)
  1832. {
  1833. if(strlen(inputtext))
  1834. {
  1835. new str[20];
  1836. format(str, sizeof(str), "%i_texturename", pInfo[playerid][editobject]);
  1837. SetPVarString(playerid, str, inputtext);
  1838. oInfo[playerid][pInfo[playerid][editobject]][textureused] = 1;
  1839. ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1840. }
  1841. else
  1842. {
  1843. new dg1[121], dg2[35], dial[200];
  1844. format(dg1, sizeof(dg1), "Enter the name of the texture you want to put on the object\n\n{F5F582}Note: {A9C4E4}Use \"none\" for alpha (transparent)");
  1845. format(dg2, sizeof(dg2), "{F58282}You need to enter a text.");
  1846. format(dial, sizeof(dial), "%s\n\n%s", dg1, dg2);
  1847. ShowPlayerDialog(playerid, DIALOG_TEXTURENAME, DIALOG_STYLE_INPUT,"Texture name",dial,"Set","Back");
  1848. }
  1849. }
  1850. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1851. }
  1852. case DIALOG_COLOR:
  1853. {
  1854. if(response)
  1855. {
  1856. if(strlen(inputtext))
  1857. {
  1858. new str[20];
  1859. format(str, sizeof(str), "%i_color", pInfo[playerid][editobject]);
  1860. SetPVarString(playerid, str, inputtext);
  1861. oInfo[playerid][pInfo[playerid][editobject]][colorused] = 1;
  1862. ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1863. }
  1864. else
  1865. {
  1866. new dg1[50], dg2[150], dg3[50], dg4[50], dial[512];
  1867. format(dg1, sizeof(dg1), "Enter a color you want to paint the texture with.");
  1868. format(dg2, sizeof(dg2), "{F58282}Important: {A9C4E4}The color has to be in {FFFFFF}AA{0069FF}BB{00FF00}GG{FF0000}RR {A9C4E4}format.\n\tExample: FF00FF00 (green).");
  1869. format(dg3, sizeof(dg3), "\n{F5F582}Note: {A9C4E4}Use \"0\" for alpha (transparent).");
  1870. format(dg4, sizeof(dg4), "{F58282}You need to enter a color.");
  1871. format(dial, sizeof(dial), "%s\n%s\n\n%s\n\n%s", dg1, dg2, dg3, dg4);
  1872. ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_INPUT,"Color",dial,"Set","Back");
  1873. }
  1874. }
  1875. else ShowPlayerMaterialDialog(playerid, pInfo[playerid][editobject]);
  1876. }
  1877. case DIALOG_EDITORCOMMANDS:
  1878. {
  1879. if(!response)
  1880. {
  1881. ShowPlayerCommandHelp2(playerid);
  1882. }
  1883. }
  1884. case DIALOG_EDITORCOMMANDS2:
  1885. {
  1886. if(response)
  1887. {
  1888. ShowPlayerCommandHelp(playerid);
  1889. }
  1890. }
  1891. }
  1892. return 1;
  1893. }
  1894.  
  1895. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  1896. {
  1897. if(objectid == oInfo[playerid][pInfo[playerid][editobject]][objectID])
  1898. {
  1899. if(response == EDIT_RESPONSE_FINAL)
  1900. {
  1901. new object = pInfo[playerid][editobject];
  1902. oInfo[playerid][object][XLoc] = fX;
  1903. oInfo[playerid][object][YLoc] = fY;
  1904. oInfo[playerid][object][ZLoc] = fZ;
  1905. oInfo[playerid][object][XRot] = fRotX;
  1906. oInfo[playerid][object][YRot] = fRotY;
  1907. oInfo[playerid][object][ZRot] = fRotZ;
  1908. SetObjectPos(oInfo[playerid][object][objectID], fX, fY, fZ);
  1909. SetObjectRot(oInfo[playerid][object][objectID], fRotX, fRotY, fRotZ);
  1910. new string[128];
  1911. format(string, sizeof(string),"You have finished editing object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}).", object, oInfo[playerid][object][modelID]);
  1912. SendClientInfoMessage(playerid, string);
  1913. }
  1914. }
  1915. return 1;
  1916. }
  1917.  
  1918. public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
  1919. {
  1920. CancelEdit(playerid);
  1921. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  1922. {
  1923. if(oInfo[playerid][i][objectID] == objectid)
  1924. {
  1925. if(pInfo[playerid][flyeditor] != 1)
  1926. {
  1927. ShowPlayerDialog(playerid, DIALOG_SELECTMENU, DIALOG_STYLE_LIST,"Select Action","Edit\nChange Model\nDelete","Select","Cancel");
  1928. pInfo[playerid][editobject] = i;
  1929. }
  1930. else
  1931. {
  1932. pInfo[playerid][editobject] = 1;
  1933. EditObject(playerid, oInfo[playerid][i][objectID]);
  1934. }
  1935. break;
  1936. }
  1937. else if(i == (MAX_CREATED_OBJECTS-1))
  1938. {
  1939. SendClientErrorMessage(playerid, 4);
  1940. }
  1941. }
  1942. return 1;
  1943. }
  1944.  
  1945. stock SendClientErrorMessage(playerid, type)
  1946. {
  1947. switch(type)
  1948. {
  1949. case 0: SendClientMessage(playerid, COLOR_WARNING, "This is not a valid object number.");
  1950. case 1: SendClientMessage(playerid, COLOR_WARNING, "You haven't created any objects.");
  1951. case 2:
  1952. {
  1953. new string[128];
  1954. format(string, sizeof(string), "You can not create more objects, you have reached the maximum amount of {F58282}%i{F5F582} objects.", MAX_CREATED_OBJECTS);
  1955. SendClientMessage(playerid, COLOR_WARNING, string);
  1956. }
  1957. case 3: SendClientMessage(playerid, COLOR_WARNING, "Sorry, you can not export object files as this function is restricted to RCON admins.");
  1958. case 4: SendClientMessage(playerid, COLOR_WARNING, "The object you selected is not one of those you have created.");
  1959. case 5:
  1960. {
  1961. new string[110];
  1962. format(string, sizeof(string), "The value you entered is too big. Please choose a value smaller than or equal to {F58282}%.2f{F5F582}m.", MAX_CREATE_DISTANCE);
  1963. SendClientMessage(playerid, COLOR_WARNING, string);
  1964. }
  1965. case 6:
  1966. {
  1967. new string[110];
  1968. format(string, sizeof(string), "The value you entered is too big. Please choose a value smaller than or equal to {F58282}%.2f{F5F582}m.", MAX_MOVE_DISTANCE);
  1969. SendClientMessage(playerid, COLOR_WARNING, string);
  1970. }
  1971. case 7: SendClientMessage(playerid, COLOR_WARNING, "Sorry, you can not use this command as you are not in the object editor.");
  1972. case 8: SendClientMessage(playerid, COLOR_WARNING, "Sorry, the usage of command shortcuts for the object editor is disabled.");
  1973. case 9: SendClientMessage(playerid, COLOR_WARNING, "Sorry, you can not use this command when you're in the flyeditor.");
  1974. case 10: SendClientMessage(playerid, COLOR_WARNING, "This user is not connected.");
  1975. }
  1976. return 1;
  1977. }
  1978.  
  1979. stock SendClientInfoMessage(playerid, string[])
  1980. {
  1981. SendClientMessage(playerid, COLOR_INFO, string);
  1982. return 1;
  1983. }
  1984.  
  1985. forward ExportMap(playerid, inputtext[]);
  1986. public ExportMap(playerid, inputtext[])
  1987. {
  1988. new string[60];
  1989. format(string, sizeof(string), "ObjectEditor/Exports/%s.txt",inputtext);
  1990. if(!dini_Exists(string))
  1991. {
  1992. new File:File = fopen(string, io_write);
  1993. new def[50];
  1994. new counter = 0;
  1995. format(def, sizeof(def), "new %s[%i];\r\n\r\n", inputtext, pInfo[playerid][totalobjects]);
  1996. fwrite(File, def);
  1997. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  1998. {
  1999. if(oInfo[playerid][i][created] == 1)
  2000. {
  2001. new code[200];
  2002. format(code, sizeof(code), "%s[%i] = CreateObject(%i, %f, %f, %f, %f, %f, %f);\r\n",inputtext, counter, oInfo[playerid][i][modelID], oInfo[playerid][i][XLoc], oInfo[playerid][i][YLoc], oInfo[playerid][i][ZLoc], oInfo[playerid][i][XRot], oInfo[playerid][i][YRot], oInfo[playerid][i][ZRot]);
  2003. fwrite(File, code);
  2004. if(oInfo[playerid][i][usesmaterial] == 1)
  2005. {
  2006. new materialindex, matmodelid, txdname[50], texturename[50], color[15];
  2007. new str1[50], str2[50], str3[15];
  2008. new matcolor;
  2009. format(str1, sizeof(str1), "%i_txdname", i);
  2010. GetPVarString(playerid, str1, txdname, sizeof(txdname));
  2011. format(str2, sizeof(str2), "%i_texturename", i);
  2012. GetPVarString(playerid, str2, texturename, sizeof(texturename));
  2013. format(str3, sizeof(str3), "%i_color", i);
  2014. GetPVarString(playerid, str3, color, sizeof(color));
  2015. matcolor = HexToInt(color);
  2016. materialindex = oInfo[playerid][i][matindex];
  2017. matmodelid = oInfo[playerid][i][matmodel];
  2018. new code2[200];
  2019. format(code2, sizeof(code2), "SetObjectMaterial(%s[%i], %i, %i, \"%s\", \"%s\", %i);\r\n", inputtext, counter, materialindex, matmodelid, txdname, texturename, matcolor);
  2020. fwrite(File, code2);
  2021. }
  2022. counter++;
  2023. }
  2024. }
  2025. fclose(File);
  2026. new msg[100];
  2027. format(msg, sizeof(msg), "You have successfully exported all objects to the file {F58282}%s{F5F582}.txt.", inputtext);
  2028. SendClientInfoMessage(playerid, msg);
  2029. }
  2030. else
  2031. {
  2032. new dg1[141];
  2033. format(dg1, sizeof(dg1), "Enter the name of the file you want to export the objects to:\n\n{F58282}Sorry, this file already exists. {A9C4E4}Please choose another name.");
  2034. ShowPlayerDialog(playerid, DIALOG_MAP_EXPORTNAME, DIALOG_STYLE_INPUT,"Save name",dg1,"Export","Cancel");
  2035. }
  2036. return 1;
  2037. }
  2038.  
  2039. forward SaveMap(playerid, inputtext[]);
  2040. public SaveMap(playerid, inputtext[])
  2041. {
  2042. new oFile[100];
  2043. format(oFile, sizeof(oFile), "/ObjectEditor/Saves/%s.txt", inputtext);
  2044. if(!dini_Exists(oFile))
  2045. {
  2046. new oCounter = 0;
  2047. new pName[MAX_PLAYER_NAME];
  2048. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  2049. dini_Create(oFile);
  2050. dini_Set(oFile, "creator", pName);
  2051. dini_IntSet(oFile, "totalobjects", pInfo[playerid][totalobjects]);
  2052. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  2053. {
  2054. if(oInfo[playerid][i][created] == 1)
  2055. {
  2056. new towrite[60];
  2057. format(towrite, sizeof(towrite), "o%i_modelID", oCounter);
  2058. dini_IntSet(oFile, towrite, oInfo[playerid][i][modelID]);
  2059. format(towrite, sizeof(towrite), "o%i_XLoc", oCounter);
  2060. dini_FloatSet(oFile, towrite, oInfo[playerid][i][XLoc]);
  2061. format(towrite, sizeof(towrite), "o%i_YLoc", oCounter);
  2062. dini_FloatSet(oFile, towrite, oInfo[playerid][i][YLoc]);
  2063. format(towrite, sizeof(towrite), "o%i_ZLoc", oCounter);
  2064. dini_FloatSet(oFile, towrite, oInfo[playerid][i][ZLoc]);
  2065. format(towrite, sizeof(towrite), "o%i_XRot", oCounter);
  2066. dini_FloatSet(oFile, towrite, oInfo[playerid][i][XRot]);
  2067. format(towrite, sizeof(towrite), "o%i_YRot", oCounter);
  2068. dini_FloatSet(oFile, towrite, oInfo[playerid][i][YRot]);
  2069. format(towrite, sizeof(towrite), "o%i_ZRot", oCounter);
  2070. dini_FloatSet(oFile, towrite, oInfo[playerid][i][ZRot]);
  2071. if(oInfo[playerid][i][usesmaterial] == 1)
  2072. {
  2073. new txdname[50], texturename[50], color[15];
  2074. new str1[50], str2[50], str3[15];
  2075. format(towrite, sizeof(towrite), "o%i_usesmaterial", oCounter);
  2076. dini_IntSet(oFile, towrite, 1);
  2077. format(str1, sizeof(str1), "%i_txdname", i);
  2078. GetPVarString(playerid, str1, txdname, sizeof(txdname));
  2079. format(str2, sizeof(str2), "%i_texturename", i);
  2080. GetPVarString(playerid, str2, texturename, sizeof(texturename));
  2081. format(str3, sizeof(str3), "%i_color", i);
  2082. GetPVarString(playerid, str3, color, sizeof(color));
  2083. format(towrite, sizeof(towrite), "o%i_matindex", oCounter);
  2084. dini_IntSet(oFile, towrite, oInfo[playerid][i][matindex]);
  2085. format(towrite, sizeof(towrite), "o%i_matmodelid", oCounter);
  2086. dini_IntSet(oFile, towrite, oInfo[playerid][i][matmodel]);
  2087. format(towrite, sizeof(towrite), "o%i_txdname", oCounter);
  2088. dini_Set(oFile, towrite, txdname);
  2089. format(towrite, sizeof(towrite), "o%i_texturename", oCounter);
  2090. dini_Set(oFile, towrite, texturename);
  2091. format(towrite, sizeof(towrite), "o%i_matcolor", oCounter);
  2092. dini_Set(oFile, towrite, color);
  2093. }
  2094. else
  2095. {
  2096. format(towrite, sizeof(towrite), "o%i_usesmaterial", oCounter);
  2097. dini_IntSet(oFile, towrite, 0);
  2098. }
  2099. oCounter++;
  2100. }
  2101. }
  2102. new msg[100];
  2103. format(msg, sizeof(msg), "You have successfully saved all objects to the file {F58282}%s{F5F582}.txt.", inputtext);
  2104. SendClientInfoMessage(playerid, msg);
  2105. }
  2106. else
  2107. {
  2108. new dg1[139];
  2109. format(dg1, sizeof(dg1), "Enter the name of the file you want to save the objects in:\n\n{F58282}Sorry, this file already exists. {A9C4E4}Please choose another name.");
  2110. ShowPlayerDialog(playerid, DIALOG_MAP_SAVENAME, DIALOG_STYLE_INPUT,"Save name",dg1,"Save","Cancel");
  2111. }
  2112. return 1;
  2113. }
  2114.  
  2115. forward LoadMap(playerid, inputtext[]);
  2116. public LoadMap(playerid, inputtext[])
  2117. {
  2118. new oFile[100];
  2119. format(oFile, sizeof(oFile), "/ObjectEditor/Saves/%s.txt", inputtext);
  2120. if(dini_Exists(oFile))
  2121. {
  2122. new amount = dini_Int(oFile, "totalobjects");
  2123. if((pInfo[playerid][totalobjects] + amount) <= MAX_CREATED_OBJECTS)
  2124. {
  2125. new oCount = 0;
  2126. new i = 0;
  2127. do
  2128. {
  2129. if(oInfo[playerid][oCount][created] == 0)
  2130. {
  2131. new dir0[50], dir1[50], dir2[50], dir3[50], dir4[50], dir5[50], dir6[50], dir7[50];
  2132. format(dir0, sizeof(dir0), "o%i_modelID", i);
  2133. format(dir1, sizeof(dir1), "o%i_XLoc", i);
  2134. format(dir2, sizeof(dir2), "o%i_YLoc", i);
  2135. format(dir3, sizeof(dir3), "o%i_ZLoc", i);
  2136. format(dir4, sizeof(dir4), "o%i_XRot", i);
  2137. format(dir5, sizeof(dir5), "o%i_YRot", i);
  2138. format(dir6, sizeof(dir6), "o%i_ZRot", i);
  2139. oInfo[playerid][oCount][created] = 1;
  2140. oInfo[playerid][oCount][modelID] = dini_Int(oFile, dir0);
  2141. oInfo[playerid][oCount][XLoc] = dini_Float(oFile, dir1);
  2142. oInfo[playerid][oCount][YLoc] = dini_Float(oFile, dir2);
  2143. oInfo[playerid][oCount][ZLoc] = dini_Float(oFile, dir3);
  2144. oInfo[playerid][oCount][XRot] = dini_Float(oFile, dir4);
  2145. oInfo[playerid][oCount][YRot] = dini_Float(oFile, dir5);
  2146. oInfo[playerid][oCount][ZRot] = dini_Float(oFile, dir6);
  2147. oInfo[playerid][oCount][objectID] = CreateObject(oInfo[playerid][oCount][modelID], oInfo[playerid][oCount][XLoc], oInfo[playerid][oCount][YLoc], oInfo[playerid][oCount][ZLoc], oInfo[playerid][oCount][XRot], oInfo[playerid][oCount][YRot], oInfo[playerid][oCount][ZRot]);
  2148. format(dir7, sizeof(dir7), "o%i_usesmaterial", i);
  2149. if(dini_Int(oFile, dir7) == 1)
  2150. {
  2151. new dir8[50], dir9[50], dir10[50], dir11[50], dir12[50];
  2152. new str[20], str2[20], str3[20];
  2153. new txdname[50], texturename[50], color[50];
  2154. format(dir8, sizeof(dir8), "o%i_matindex", i);
  2155. format(dir9, sizeof(dir9), "o%i_matmodelid", i);
  2156. format(dir10, sizeof(dir10), "o%i_txdname", i);
  2157. format(dir11, sizeof(dir11), "o%i_texturename", i);
  2158. format(dir12, sizeof(dir12), "o%i_matcolor", i);
  2159. format(txdname, sizeof(txdname), "%s", dini_Get(oFile, dir10));
  2160. format(texturename, sizeof(texturename), "%s", dini_Get(oFile, dir11));
  2161. format(color, sizeof(color), "%s", dini_Get(oFile, dir12));
  2162. oInfo[playerid][oCount][indexused] = 1;
  2163. oInfo[playerid][oCount][modelused] = 1;
  2164. oInfo[playerid][oCount][txdused] = 1;
  2165. oInfo[playerid][oCount][textureused] = 1;
  2166. oInfo[playerid][oCount][colorused] = 1;
  2167. oInfo[playerid][oCount][matindex] = dini_Int(oFile, dir8);
  2168. oInfo[playerid][oCount][matmodel] = dini_Int(oFile, dir9);
  2169. format(str, sizeof(str), "%i_txdname", oCount);
  2170. format(str2, sizeof(str2), "%i_texturename", oCount);
  2171. format(str3, sizeof(str3), "%i_color", oCount);
  2172. SetPVarString(playerid, str, txdname);
  2173. SetPVarString(playerid, str2, texturename);
  2174. SetPVarString(playerid, str3, color);
  2175. oInfo[playerid][oCount][usesmaterial] = 1;
  2176. SetObjectMaterial(oInfo[playerid][oCount][objectID], oInfo[playerid][oCount][matindex], oInfo[playerid][oCount][matmodel], txdname, texturename, HexToInt(color));
  2177. }
  2178. else
  2179. {
  2180. oInfo[playerid][oCount][usesmaterial] = 0;
  2181. }
  2182. i++;
  2183. }
  2184. oCount++;
  2185. }
  2186. while(i < amount);
  2187. pInfo[playerid][totalobjects]+=amount;
  2188. new string[256];
  2189. format(string, sizeof(string), "You loaded {F58282}%i{F5F582} objects from file {F58282}%s{F5F582}.txt. | Total current objects: {F58282}%i{F5F582}.", amount, inputtext, pInfo[playerid][totalobjects]);
  2190. SendClientInfoMessage(playerid, string);
  2191. }
  2192. else
  2193. {
  2194. new string[128];
  2195. format(string, sizeof(string), "You can not load this file as you would exceed the maximum amount of {F58282}%i{F5F582} objects.", MAX_CREATED_OBJECTS);
  2196. SendClientMessage(playerid, COLOR_WARNING, string);
  2197. }
  2198. }
  2199. else
  2200. {
  2201. new dg1[256];
  2202. format(dg1, sizeof(dg1), "Enter the name of the file you want to load:\n\n{F58282}Sorry, this file does not exist.");
  2203. ShowPlayerDialog(playerid, DIALOG_MAP_LOAD, DIALOG_STYLE_INPUT, "Load map",dg1,"Load","Cancel");
  2204. }
  2205. return 1;
  2206. }
  2207.  
  2208. stock DeleteAllObjects(playerid)
  2209. {
  2210. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  2211. {
  2212. DestroyObject(oInfo[playerid][i][objectID]);
  2213. oInfo[playerid][i][objectID] = INVALID_OBJECT_ID;
  2214. oInfo[playerid][i][modelID] = 0;
  2215. oInfo[playerid][i][XLoc] = 0.0;
  2216. oInfo[playerid][i][YLoc] = 0.0;
  2217. oInfo[playerid][i][ZLoc] = 0.0;
  2218. oInfo[playerid][i][XRot] = 0.0;
  2219. oInfo[playerid][i][YRot] = 0.0;
  2220. oInfo[playerid][i][ZRot] = 0.0;
  2221. pInfo[playerid][totalobjects] = 0;
  2222. oInfo[playerid][i][created] = 0;
  2223. oInfo[playerid][i][indexused] = 0;
  2224. oInfo[playerid][i][modelused] = 0;
  2225. oInfo[playerid][i][txdused] = 0;
  2226. oInfo[playerid][i][textureused] = 0;
  2227. oInfo[playerid][i][colorused] = 0;
  2228. oInfo[playerid][i][matindex] = -1;
  2229. oInfo[playerid][i][matmodel] = -1;
  2230. new str1[20], str2[20], str3[20];
  2231. format(str1, sizeof(str1), "%i_txdname", i);
  2232. format(str2, sizeof(str2), "%i_texturename", i);
  2233. format(str3, sizeof(str3), "%i_color", i);
  2234. DeletePVar(playerid, str1);
  2235. DeletePVar(playerid, str2);
  2236. DeletePVar(playerid, str3);
  2237. oInfo[playerid][i][usesmaterial] = 0;
  2238. }
  2239. return 1;
  2240. }
  2241.  
  2242. forward ShowPlayerSettingsMenu(playerid);
  2243. public ShowPlayerSettingsMenu(playerid)
  2244. {
  2245. new setting1[128], setting2[128], setting3[128], setting4[128], setting5[128], setting6[128], setting7[128], dialog[512];
  2246. #if ALLOW_EDIT_OBJECT_ON_CREATE == true
  2247. if(pInfo[playerid][EditObjectOnCreate] == true)
  2248. format(setting1, sizeof(setting1), "Auto edit object after creation\t\t\t\t{91FF91}Enabled");
  2249. else
  2250. format(setting1, sizeof(setting1), "Auto edit object after creation\t\t\t\t{F58282}Disabled");
  2251. #else
  2252. format(setting1, sizeof(setting1), "{323232}Auto edit object after creation\t\t\t\tNot available");
  2253. #endif
  2254. #if ALLOW_EDIT_OBJECT_ON_DUPLICATE == true
  2255. if(pInfo[playerid][EditObjectOnDuplicate] == true)
  2256. format(setting2, sizeof(setting2), "Auto edit object after duplication\t\t\t{91FF91}Enabled");
  2257. else
  2258. format(setting2, sizeof(setting2), "Auto edit object after duplication\t\t\t{F58282}Disabled");
  2259. #else
  2260. format(setting2, sizeof(setting2), "{323232}Auto edit object after duplication\t\t\tNot available");
  2261. #endif
  2262. #if ALLOW_USE_MATERIAL_CHANGE_DIALOG == true
  2263. if(pInfo[playerid][UseMaterialDialog] == true)
  2264. format(setting3, sizeof(setting3), "Use material change dialog\t\t\t\t{91FF91}Enabled");
  2265. else
  2266. format(setting3, sizeof(setting3), "Use material change dialog\t\t\t\t{F58282}Disabled");
  2267. #else
  2268. format(setting3, sizeof(setting3), "{323232}Use material change dialog\t\t\t\tNot available");
  2269. #endif
  2270. #if ALLOW_TRANSFER_MATERIAL == true
  2271. if(pInfo[playerid][TransferMaterial] == true)
  2272. format(setting4, sizeof(setting4), "Copy texture to duplicated object\t\t\t{91FF91}Enabled");
  2273. else
  2274. format(setting4, sizeof(setting4), "Copy texture to duplicated object\t\t\t{F58282}Disabled");
  2275. #else
  2276. format(setting4, sizeof(setting4), "{323232}Copy texture to duplicated object\t\t\tNot available");
  2277. #endif
  2278. #if ALLOW_KEEP_MATERIAL == true
  2279. if(pInfo[playerid][KeepMaterial] == true)
  2280. format(setting5, sizeof(setting5), "Keep custom texture after changing object model\t{91FF91}Enabled");
  2281. else
  2282. format(setting5, sizeof(setting5), "Keep custom texture after changing object model\t{F58282}Disabled");
  2283. #else
  2284. format(setting5, sizeof(setting5), "{323232}Keep custom texture after changing object model\tNot available");
  2285. #endif
  2286. #if ALLOW_USE_CROSS == true
  2287. if(pInfo[playerid][UseCross] == true)
  2288. format(setting6, sizeof(setting6), "Use fade cross when in flyeditor editor mode\t\t{91FF91}Enabled");
  2289. else
  2290. format(setting6, sizeof(setting6), "Use fade cross when in flyeditor editor mode\t\t{F58282}Disabled");
  2291. #else
  2292. format(setting6, sizeof(setting6), "{323232}Use fade cross when in flyeditor editor mode\t\tNot available");
  2293. #endif
  2294.  
  2295. #if ALLOW_USE_3D_LABELS == true
  2296. if(pInfo[playerid][UseLabels] == true)
  2297. format(setting6, sizeof(setting7), "Use 3D text labels for help\t\t{91FF91}Enabled");
  2298. else
  2299. format(setting6, sizeof(setting7), "Use 3D text labels for help\t\t{F58282}Disabled");
  2300. #else
  2301. format(setting6, sizeof(setting7), "{323232}Use 3D text labels for help\t\tNot available");
  2302. #endif
  2303. format(dialog, sizeof(dialog),"%s\n%s\n%s\n%s\n%s\n%s\n%s", setting1, setting2, setting3, setting4, setting5, setting6, setting7);
  2304. ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, "Editor settings",dialog,"Change","Close");
  2305. return 1;
  2306. }
  2307.  
  2308. forward ShowPlayerMaterialDialog(playerid, object);
  2309. public ShowPlayerMaterialDialog(playerid, object)
  2310. {
  2311. new l1[128], l2[128], l3[128], l4[128], l5[128], dialog[512];
  2312. if(oInfo[playerid][pInfo[playerid][editobject]][indexused] == 0)
  2313. format(l1, sizeof(l1), "Materialindex\t{F58282}-");
  2314. else
  2315. format(l1, sizeof(l1), "Materialindex\t{91FF91}%i", oInfo[playerid][pInfo[playerid][editobject]][matindex]);
  2316. if(oInfo[playerid][pInfo[playerid][editobject]][modelused] == 0)
  2317. format(l2, sizeof(l2), "Model ID\t{F58282}-");
  2318. else
  2319. format(l2, sizeof(l2), "Model ID\t{91FF91}%i", oInfo[playerid][pInfo[playerid][editobject]][matmodel]);
  2320. if(oInfo[playerid][pInfo[playerid][editobject]][txdused] == 0)
  2321. format(l3, sizeof(l3), "TXD Name\t{F58282}-");
  2322. else
  2323. {
  2324. new str[20], input[50];
  2325. format(str, sizeof(str), "%i_txdname", pInfo[playerid][editobject]);
  2326. GetPVarString(playerid, str, input, sizeof(input));
  2327. format(l3, sizeof(l3), "TXD Name\t{91FF91}%s", input);
  2328. }
  2329. if(oInfo[playerid][pInfo[playerid][editobject]][textureused] == 0)
  2330. format(l4, sizeof(l4), "Texture name\t{F58282}-");
  2331. else
  2332. {
  2333. new str[20], input[50];
  2334. format(str, sizeof(str), "%i_texturename", pInfo[playerid][editobject]);
  2335. GetPVarString(playerid, str, input, sizeof(input));
  2336. format(l4, sizeof(l4), "Texture Name\t{91FF91}%s", input);
  2337. }
  2338. if(oInfo[playerid][pInfo[playerid][editobject]][colorused] == 0)
  2339. format(l5, sizeof(l5), "Color\t\t{F58282}-");
  2340. else
  2341. {
  2342. new str[20], input[50];
  2343. format(str, sizeof(str), "%i_color", pInfo[playerid][editobject]);
  2344. GetPVarString(playerid, str, input, sizeof(input));
  2345. if(strcmp(input, "0", true) == 0)
  2346. format(l5, sizeof(l5), "Color\t\t{91FF91}no color (texture default)");
  2347. else
  2348. format(l5, sizeof(l5), "Color\t\t{91FF91}%s", input);
  2349. }
  2350. if(oInfo[playerid][pInfo[playerid][editobject]][usesmaterial] == 0)
  2351. {
  2352. if(IsAllFilledOut(playerid, pInfo[playerid][editobject]))
  2353. {
  2354. format(dialog, sizeof(dialog),"%s\n%s\n%s\n%s\n%s\n{91FF91}Continue\n{323232}Remove texture", l1, l2, l3, l4, l5);
  2355. ShowPlayerDialog(playerid, DIALOG_MATERIALS, DIALOG_STYLE_LIST, "Change material",dialog,"Change","Cancel");
  2356. }
  2357. else
  2358. {
  2359. format(dialog, sizeof(dialog),"%s\n%s\n%s\n%s\n%s\n{323232}Continue\n{323232}Remove texture", l1, l2, l3, l4, l5);
  2360. ShowPlayerDialog(playerid, DIALOG_MATERIALS, DIALOG_STYLE_LIST, "Change material",dialog,"Change","Cancel");
  2361. }
  2362. }
  2363. else
  2364. {
  2365. if(IsAllFilledOut(playerid, pInfo[playerid][editobject]))
  2366. {
  2367. format(dialog, sizeof(dialog),"%s\n%s\n%s\n%s\n%s\n{91FF91}Continue\n{F58282}Remove texture", l1, l2, l3, l4, l5);
  2368. ShowPlayerDialog(playerid, DIALOG_MATERIALS, DIALOG_STYLE_LIST, "Change material",dialog,"Change","Cancel");
  2369. }
  2370. else
  2371. {
  2372. format(dialog, sizeof(dialog),"%s\n%s\n%s\n%s\n%s\n{323232}Continue\n{F58282}Remove texture", l1, l2, l3, l4, l5);
  2373. ShowPlayerDialog(playerid, DIALOG_MATERIALS, DIALOG_STYLE_LIST, "Change material",dialog,"Change","Cancel");
  2374. }
  2375. }
  2376. return 1;
  2377. }
  2378.  
  2379. forward IsAllFilledOut(playerid, object);
  2380. public IsAllFilledOut(playerid, object)
  2381. {
  2382. if(oInfo[playerid][object][indexused] == 1)
  2383. {
  2384. if(oInfo[playerid][object][modelused] == 1)
  2385. {
  2386. if(oInfo[playerid][object][txdused] == 1)
  2387. {
  2388. if(oInfo[playerid][object][textureused] == 1)
  2389. {
  2390. if(oInfo[playerid][object][colorused] == 1)
  2391. {
  2392. return 1;
  2393. }
  2394. else return 0;
  2395. }
  2396. else return 0;
  2397. }
  2398. else return 0;
  2399. }
  2400. else return 0;
  2401. }
  2402. else return 0;
  2403. }
  2404.  
  2405. forward ChangeObjectMaterial(playerid, object);
  2406. public ChangeObjectMaterial(playerid, object)
  2407. {
  2408. oInfo[playerid][object][usesmaterial] = 1;
  2409. new txdname[50], texturename[50], color[15];
  2410. new str1[50], str2[50], str3[15];
  2411. format(str1, sizeof(str1), "%i_txdname", object);
  2412. GetPVarString(playerid, str1, txdname, sizeof(txdname));
  2413. format(str2, sizeof(str2), "%i_texturename", object);
  2414. GetPVarString(playerid, str2, texturename, sizeof(texturename));
  2415. format(str3, sizeof(str3), "%i_color", object);
  2416. GetPVarString(playerid, str3, color, sizeof(color));
  2417. new rescolor = HexToInt(color);
  2418. SetObjectMaterial(oInfo[playerid][object][objectID], oInfo[playerid][object][matindex], oInfo[playerid][object][matmodel], txdname, texturename, rescolor);
  2419. return 1;
  2420. }
  2421.  
  2422. forward ResetObjectMaterial(playerid, object);
  2423. public ResetObjectMaterial(playerid, object)
  2424. {
  2425. oInfo[playerid][object][indexused] = 0;
  2426. oInfo[playerid][object][modelused] = 0;
  2427. oInfo[playerid][object][txdused] = 0;
  2428. oInfo[playerid][object][textureused] = 0;
  2429. oInfo[playerid][object][colorused] = 0;
  2430. oInfo[playerid][object][matindex] = -1;
  2431. oInfo[playerid][object][matmodel] = -1;
  2432. new str1[20], str2[20], str3[20];
  2433. format(str1, sizeof(str1), "%i_txdname", object);
  2434. format(str2, sizeof(str2), "%i_texturename", object);
  2435. format(str3, sizeof(str3), "%i_color", object);
  2436. DeletePVar(playerid, str1);
  2437. DeletePVar(playerid, str2);
  2438. DeletePVar(playerid, str3);
  2439. oInfo[playerid][object][usesmaterial] = 0;
  2440. DestroyObject(oInfo[playerid][object][objectID]);
  2441. oInfo[playerid][object][objectID] = CreateObject(oInfo[playerid][object][modelID], oInfo[playerid][object][XLoc], oInfo[playerid][object][YLoc], oInfo[playerid][object][ZLoc], oInfo[playerid][object][XRot], oInfo[playerid][object][YRot], oInfo[playerid][object][ZRot]);
  2442. new msg[128];
  2443. format(msg, sizeof(msg), "You have reset the texture of object number {F58282}%i{F5F582} (Model {F58282}%i{F5F582}) to default.", object, oInfo[playerid][object][modelID]);
  2444. SendClientInfoMessage(playerid, msg);
  2445. return 1;
  2446. }
  2447.  
  2448. forward ResetAllValues(playerid);
  2449. public ResetAllValues(playerid)
  2450. {
  2451. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  2452. {
  2453. oInfo[playerid][i][created] = 0;
  2454. oInfo[playerid][i][objectID] = 0;
  2455. oInfo[playerid][i][modelID] = 0;
  2456. oInfo[playerid][i][XLoc] = 0.0;
  2457. oInfo[playerid][i][YLoc] = 0.0;
  2458. oInfo[playerid][i][ZLoc] = 0.0;
  2459. oInfo[playerid][i][XRot] = 0.0;
  2460. oInfo[playerid][i][YRot] = 0.0;
  2461. oInfo[playerid][i][ZRot] = 0.0;
  2462. oInfo[playerid][i][usesmaterial] = 0;
  2463. oInfo[playerid][i][indexused] = 0;
  2464. oInfo[playerid][i][modelused] = 0;
  2465. oInfo[playerid][i][txdused] = 0;
  2466. oInfo[playerid][i][textureused] = 0;
  2467. oInfo[playerid][i][colorused] = 0;
  2468. oInfo[playerid][i][matindex] = 0;
  2469. oInfo[playerid][i][matmodel] = 0;
  2470. new str1[20], str2[20], str3[20];
  2471. format(str1, sizeof(str1), "%i_txdname", i);
  2472. format(str2, sizeof(str2), "%i_texturename", i);
  2473. format(str3, sizeof(str3), "%i_color", i);
  2474. DeletePVar(playerid, str1);
  2475. DeletePVar(playerid, str2);
  2476. DeletePVar(playerid, str3);
  2477. }
  2478. pInfo[playerid][EditObjectOnCreate] = false;
  2479. pInfo[playerid][EditObjectOnDuplicate] = false;
  2480. pInfo[playerid][UseMaterialDialog] = false;
  2481. pInfo[playerid][TransferMaterial] = false;
  2482. pInfo[playerid][totalobjects] = 0;
  2483. pInfo[playerid][editobject] = INVALID_OBJECT_NUMBER;
  2484. pInfo[playerid][editing] = false;
  2485. return 1;
  2486. }
  2487.  
  2488. forward ShowPlayerCommandHelp(playerid);
  2489. public ShowPlayerCommandHelp(playerid)
  2490. {
  2491. new l1[65], l2[27], l3[210], l4[247], l5[262], l6[262], l7[195];
  2492. new dialog[1200];
  2493. l1 = "Below is a list of all available commands for the object editor:";
  2494. l2 = "Command\t\tShortcut\tEffect";
  2495. l3 = "{87FF87}/createnewobject\t{F5F582}/cno\t\t{A9C4E4}Creates a new object\n"\
  2496. "{87FF87}/deleteobject\t\t{F5F582}/deo\t\t{A9C4E4}Deletes an object\n"\
  2497. "{87FF87}/deleteallobjects\t{F5F582}/deao\t\t{A9C4E4}Deletes all object";
  2498. l4 = "{87FF87}/setobjectxoffset\t{F5F582}/soxo\t\t{A9C4E4}Moves an object on the X axis\n"\
  2499. "{87FF87}/setobjectyoffset\t{F5F582}/soyo\t\t{A9C4E4}Moves an object on the Y axis\n"\
  2500. "{87FF87}/setobjectzoffset\t{F5F582}/sozo\t\t{A9C4E4}Moves an object on the Z axis";
  2501. l5 = "{87FF87}/setallobjectsxoffset\t{F5F582}/saoxo\t\t{A9C4E4}Move all object on the X axis\n"\
  2502. "{87FF87}/setallobjectsyoffset\t{F5F582}/saoyo\t\t{A9C4E4}Move all object on the Y axis\n"\
  2503. "{87FF87}/setallobjectszoffset\t{F5F582}/saozo\t\t{A9C4E4}Move all object on the Z axis";
  2504. l6 = "{87FF87}/setobjectxrotation\t{F5F582}/soxr\t\t{A9C4E4}Sets the X rotation of an object\n"\
  2505. "{87FF87}/setobjectyrotation\t{F5F582}/soyr\t\t{A9C4E4}Sets the Y rotation of an object\n"\
  2506. "{87FF87}/setobjectzrotation\t{F5F582}/sozr\t\t{A9C4E4}Sets the Z rotation of an object";
  2507. l7 = "{F5F582}Note: {A9C4E4}You can also type the command to get extra information about each command and the parameters.";
  2508. format(dialog, sizeof(dialog), "%s\n\n%s\n%s\n\n%s\n%s\n\n%s\n\n%s",l1, l2, l3, l4, l5, l6, l7);
  2509. ShowPlayerDialog(playerid, DIALOG_EDITORCOMMANDS, DIALOG_STYLE_MSGBOX, "Object Editor Commands #1", dialog, "Close","Page 2 >");
  2510. return 1;
  2511. }
  2512.  
  2513. forward ShowPlayerCommandHelp2(playerid);
  2514. public ShowPlayerCommandHelp2(playerid)
  2515. {
  2516. new l1[65], l2[27], l3[250], l4[247], l5[262], l6[262], l7[470];
  2517. new dialog[1630];
  2518. l1 = "Below is a list of all available commands for the object editor:";
  2519. l2 = "Command\t\tShortcut\tEffect";
  2520. l3 = "{87FF87}/nearestobject\t{F5F582}/neo\t\t{A9C4E4}Gets the closes object to your position\n"\
  2521. "{87FF87}/gotoobject\t\t{F5F582}/goo\t\t{A9C4E4}Teleports you to an object\n"\
  2522. "{87FF87}/replaceobjectmodel\t{F5F582}/rpom\t\t{A9C4E4}Replaces an object with a new object";
  2523. l4 = "{87FF87}/duplicateobject\t{F5F582}/duo\t\t{A9C4E4}Duplicates an object\n"\
  2524. "{87FF87}/setobjectmaterial\t{F5F582}/som\t\t{A9C4E4}Changes the texture of an object\n"\
  2525. "{87FF87}/setobjectpos\t\t{F5F582}/sop\t\t{A9C4E4}Sets an object to an exact position";
  2526. l5 = "{87FF87}/editobject\t\t{F5F582}/edo\t\t{A9C4E4}Modifies an object using the object editing tool\n"\
  2527. "{87FF87}/selectobject\t\t{F5F582}/seo\t\t{A9C4E4}Selects an object by clicking on it\n"\
  2528. "{87FF87}/flyeditor\t\t{F5F582}-\t\t{A9C4E4}Enters the flyeditor editor mode";
  2529. #if ALLOW_EXPORT_MAP_FILE == true
  2530. l6 = "{87FF87}/saveobjects\t\t{F5F582}-\t\t{A9C4E4}Saves an object file\n"\
  2531. "{87FF87}/loadobjects\t\t{F5F582}-\t\t{A9C4E4}Loads an object file\n"\
  2532. "{87FF87}/exportobjects\t{F5F582}-\t\t{A9C4E4}Exports an object file in the CreateObject() format";
  2533. #else
  2534. l6 = "{87FF87}/saveobjects\t\t{F5F582}-\t\t{A9C4E4}Saves an object file\n"\
  2535. "{87FF87}/loadobjects\t\t{F5F582}-\t\t{A9C4E4}Loads an object file\n"\
  2536. "{87FF87}/exportobjects\t{F5F582}-\t\t{A9C4E4}Exports an object file in the CreateObject() format\t{F58282}(RCON Admins only)";
  2537. #endif
  2538. l7 = "{87FF87}/editorcommands\t{F5F582}-\t\t{A9C4E4}Shows the editor commands help\n"\
  2539. "{87FF87}/esettingshelp\t{F5F582}-\t\t{A9C4E4}Shows editor settings help\n"\
  2540. "{87FF87}/editorsettings\t{F5F582}-\t\t{A9C4E4}Shows the editor settings dialog to a player\n"\
  2541. "{87FF87}/toggleeditor\t\t{F5F582}-\t\t{A9C4E4}Can be used by an RCON admin to allow a player to use the editor\n\n"\
  2542. "{F5F582}Note: {A9C4E4}You can also type the command to get extra information about each command and the parameters.";
  2543. format(dialog, sizeof(dialog), "%s\n\n%s\n%s\n%s\n%s\n%s\n\n%s",l1, l2, l3, l4, l5, l6, l7);
  2544. // 1 2 3 4 5 6 7 8 9 10 11
  2545. ShowPlayerDialog(playerid, DIALOG_EDITORCOMMANDS2, DIALOG_STYLE_MSGBOX, "Object Editor Commands #2", dialog, "< Page 1","Close");
  2546. return 1;
  2547. }
  2548.  
  2549. forward ShowPlayerSettingsHelp(playerid);
  2550. public ShowPlayerSettingsHelp(playerid)
  2551. {
  2552. new s1[220], s2[225], s3[233], s4[238], s5[216], s6[236], s7[74], dialog[1450];
  2553. s1 = "{91FF91}Auto edit object after creation:\n"\
  2554. "{A9C4E4}If this option is enabled you will be automatically be put into the editor mode after creating an object.\nBy this you can immediately modify it's position and rotation.";
  2555. s2 = "{91FF91}Auto edit object after duplication:\n"\
  2556. "{A9C4E4}If this option is enabled you will be automatically be put into the editor mode after duplicating an object.\nBy this you can immediately modify it's position and rotation.";
  2557. s3 = "{91FF91}Use material change dialog:\n"\
  2558. "{A9C4E4}This option allows you to use the dialog menu to change an object's texture.\nIf it is disabled, you must use /setobjectmaterial and enter all it's parameters together with the command.";
  2559. s4 = "{91FF91}Copy texture to duplicated object:\n"\
  2560. "{A9C4E4}If this is enabled, a duplicated object with automatically have the custom texture of it's \"mother object\".\nIf disabled, the duplicated object will have the object default texture.";
  2561. s5 = "{91FF91}Keep custom texture after changing object model:\n"\
  2562. "{A9C4E4}This option allows you to keep the custom texture after you changed the model of an object.\nIf it's disabled, the custom texture will be deleted.";
  2563. s6 = "{91FF91}Use fade cross when in flyeditor editor mode:\n"\
  2564. "{A9C4E4}If enabled, you will have a fade cross in the middle of your screen when you're in the flyeditor editor mode.\nYou can remove the fade cross by disabling this option.";
  2565. s7 = "If an object is grayed out, this feature has been disabled by the server.";
  2566. format(dialog, sizeof(dialog), "Below is a list of all options found in {F5F582}/editorsettings{A9C4E4}.\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s", s1, s2, s3, s4, s5, s6, s7);
  2567. ShowPlayerDialog(playerid, DIALOG_SETTINGSHELP, DIALOG_STYLE_MSGBOX, "Editor settings help",dialog,"Close","");
  2568. return 1;
  2569. }
  2570.  
  2571. forward Startflyeditor(playerid);
  2572. public Startflyeditor(playerid)
  2573. {
  2574. pInfo[playerid][flyeditor] = 1;
  2575. new Float:X, Float:Y, Float:Z;
  2576. GetPlayerPos(playerid, X, Y, Z);
  2577. pInfo[playerid][flyobject] = CreatePlayerObject(playerid, 19300, X, Y, Z, 0.0, 0.0, 0.0);
  2578. TogglePlayerSpectating(playerid, true);
  2579. AttachCameraToPlayerObject(playerid, pInfo[playerid][flyobject]);
  2580. SendClientInfoMessage(playerid, "You have entered the fly mode.");
  2581. SendClientInfoMessage(playerid, "Use {F58282}~k~~GO_FORWARD~ ~k~~GO_BACK~ ~k~~GO_LEFT~ ~k~~GO_RIGHT~{F5F582} to move the camera.");
  2582. SendClientInfoMessage(playerid, "Press {F58282}~k~~VEHICLE_ENTER_EXIT~{F5F582} to select an object you want to edit.");
  2583. SendClientInfoMessage(playerid, "While you are editing an object, you can move the camera around while holding down {F58282}~k~~PED_SPRINT~{F5F582}.");
  2584. SendClientInfoMessage(playerid, "To exit the fly mode, type /flyeditor again.");
  2585. if(pInfo[playerid][UseCross] == true)
  2586. {
  2587. PlayerTextDrawShow(playerid, Cross[0]);
  2588. PlayerTextDrawShow(playerid, Cross[1]);
  2589. }
  2590. return 1;
  2591. }
  2592.  
  2593. forward Endflyeditor(playerid);
  2594. public Endflyeditor(playerid)
  2595. {
  2596. pInfo[playerid][flyeditor] = 0;
  2597. GetPlayerCameraPos(playerid, pInfo[playerid][poX], pInfo[playerid][poY], pInfo[playerid][poZ]);
  2598. CancelEdit(playerid);
  2599. TogglePlayerSpectating(playerid, false);
  2600. DestroyPlayerObject(playerid, pInfo[playerid][flyobject]);
  2601. PlayerTextDrawHide(playerid, Cross[0]);
  2602. PlayerTextDrawHide(playerid, Cross[1]);
  2603. SetTimer("SpawnDelay", 100, 0);
  2604. return 1;
  2605. }
  2606.  
  2607. forward SpawnDelay(playerid);
  2608. public SpawnDelay(playerid)
  2609. {
  2610. SetPlayerPos(playerid, pInfo[playerid][poX], pInfo[playerid][poY], pInfo[playerid][poZ]);
  2611. }
  2612.  
  2613. forward ShowAllLabels(playerid);
  2614. public ShowAllLabels(playerid)
  2615. {
  2616. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  2617. {
  2618. if(oInfo[playerid][i][created])
  2619. {
  2620. //new labeltext[200];
  2621. //format(labeltext, 200, "Object Number: %i\nModel ID: %i\nRotation: %.2f, %.2f, %.2f", i, oInfo[playerid][i][modelID], oInfo[playerid][i][XRot], oInfo[playerid][i][YRot], oInfo[playerid][i][ZRot]);
  2622. oInfo[playerid][i][labelID] = CreatePlayer3DTextLabel(playerid, "*labeltext*""lol", -1, oInfo[playerid][i][XLoc], oInfo[playerid][i][YLoc], oInfo[playerid][i][ZLoc], 10.0, 0, 0, 0);
  2623. }
  2624. }
  2625. return 1;
  2626. }
  2627.  
  2628. forward HideAllLabels(playerid);
  2629. public HideAllLabels(playerid)
  2630. {
  2631. for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
  2632. {
  2633. DeletePlayer3DTextLabel(playerid, oInfo[playerid][i][labelID]);
  2634. }
  2635. return 1;
  2636. }
  2637.  
  2638. IsNumeric(szInput[])
  2639. {
  2640. new iChar, i = 0;
  2641. while ((iChar = szInput[i++])) if (!('0' <= iChar <= '9')) return 0;
  2642. return 1;
  2643. }
  2644.  
  2645. HexToInt(string[]){
  2646. if (string[0]==0) return 0;
  2647. new i;
  2648. new cur=1;
  2649. new res=0;
  2650. for (i=strlen(string);i>0;i--) {
  2651. if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
  2652. cur=cur*16;
  2653. }
  2654. return res;
  2655. }
  2656.  
  2657. stock GetMoveDirectionFromKeys(ud, lr)
  2658. {
  2659. new direction = 0;
  2660.  
  2661. if(lr < 0)
  2662. {
  2663. if(ud < 0) direction = MOVE_FORWARD_LEFT;
  2664. else if(ud > 0) direction = MOVE_BACK_LEFT;
  2665. else direction = MOVE_LEFT;
  2666. }
  2667. else if(lr > 0)
  2668. {
  2669. if(ud < 0) direction = MOVE_FORWARD_RIGHT;
  2670. else if(ud > 0) direction = MOVE_BACK_RIGHT;
  2671. else direction = MOVE_RIGHT;
  2672. }
  2673. else if(ud < 0) direction = MOVE_FORWARD;
  2674. else if(ud > 0) direction = MOVE_BACK;
  2675. return direction;
  2676. }
  2677.  
  2678. stock MoveCamera(playerid)
  2679. {
  2680. new Float:FV[3], Float:CP[3];
  2681. GetPlayerCameraPos(playerid, CP[0], CP[1], CP[2]);
  2682. GetPlayerCameraFrontVector(playerid, FV[0], FV[1], FV[2]);
  2683. if(pInfo[playerid][accelmul] <= 1) pInfo[playerid][accelmul] += ACCEL_RATE;
  2684. new Float:speed = MOVE_SPEED * pInfo[playerid][accelmul];
  2685. new Float:X, Float:Y, Float:Z;
  2686. GetNextCameraPosition(pInfo[playerid][mode], CP, FV, X, Y, Z);
  2687. MovePlayerObject(playerid, pInfo[playerid][flyobject], X, Y, Z, speed);
  2688. pInfo[playerid][lastmove] = GetTickCount();
  2689. return 1;
  2690. }
  2691.  
  2692. stock GetNextCameraPosition(move_mode, Float:CP[3], Float:FV[3], &Float:X, &Float:Y, &Float:Z)
  2693. {
  2694. #define OFFSET_X (FV[0]*6000.0)
  2695. #define OFFSET_Y (FV[1]*6000.0)
  2696. #define OFFSET_Z (FV[2]*6000.0)
  2697. switch(move_mode)
  2698. {
  2699. case MOVE_FORWARD:
  2700. {
  2701. X = CP[0]+OFFSET_X;
  2702. Y = CP[1]+OFFSET_Y;
  2703. Z = CP[2]+OFFSET_Z;
  2704. }
  2705. case MOVE_BACK:
  2706. {
  2707. X = CP[0]-OFFSET_X;
  2708. Y = CP[1]-OFFSET_Y;
  2709. Z = CP[2]-OFFSET_Z;
  2710. }
  2711. case MOVE_LEFT:
  2712. {
  2713. X = CP[0]-OFFSET_Y;
  2714. Y = CP[1]+OFFSET_X;
  2715. Z = CP[2];
  2716. }
  2717. case MOVE_RIGHT:
  2718. {
  2719. X = CP[0]+OFFSET_Y;
  2720. Y = CP[1]-OFFSET_X;
  2721. Z = CP[2];
  2722. }
  2723. case MOVE_BACK_LEFT:
  2724. {
  2725. X = CP[0]+(-OFFSET_X - OFFSET_Y);
  2726. Y = CP[1]+(-OFFSET_Y + OFFSET_X);
  2727. Z = CP[2]-OFFSET_Z;
  2728. }
  2729. case MOVE_BACK_RIGHT:
  2730. {
  2731. X = CP[0]+(-OFFSET_X + OFFSET_Y);
  2732. Y = CP[1]+(-OFFSET_Y - OFFSET_X);
  2733. Z = CP[2]-OFFSET_Z;
  2734. }
  2735. case MOVE_FORWARD_LEFT:
  2736. {
  2737. X = CP[0]+(OFFSET_X - OFFSET_Y);
  2738. Y = CP[1]+(OFFSET_Y + OFFSET_X);
  2739. Z = CP[2]+OFFSET_Z;
  2740. }
  2741. case MOVE_FORWARD_RIGHT:
  2742. {
  2743. X = CP[0]+(OFFSET_X + OFFSET_Y);
  2744. Y = CP[1]+(OFFSET_Y - OFFSET_X);
  2745. Z = CP[2]+OFFSET_Z;
  2746. }
  2747. }
  2748. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement