Advertisement
Guest User

Text Editor

a guest
Jul 29th, 2015
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.31 KB | None | 0 0
  1. #include <a_samp>
  2. //#include <../include/gl_common.inc>
  3.  
  4. stock isNumeric(const string[])
  5. {
  6. new length=strlen(string);
  7. if (length==0) return false;
  8. for (new i = 0; i < length; i++)
  9. {
  10. if (
  11. (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
  12. || (string[i]=='-' && i!=0) // A '-' but not at first.
  13. || (string[i]=='+' && i!=0) // A '+' but not at first.
  14. ) return false;
  15. }
  16. if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  17. return true;
  18. }
  19.  
  20. new Object[MAX_PLAYERS],
  21. Text[MAX_PLAYERS][128],
  22. Size[MAX_PLAYERS] = 50,
  23. Index[MAX_PLAYERS] = 0,
  24. UseBold[MAX_PLAYERS] = 0,
  25. TextAlign[MAX_PLAYERS] = 1,
  26. FontName[MAX_PLAYERS][128],
  27. FontSize[MAX_PLAYERS] = 24,
  28. TextColor[MAX_PLAYERS],
  29. BackgColor[MAX_PLAYERS],
  30. OName[MAX_PLAYERS][30],
  31. ObjectID[MAX_PLAYERS] = 19353,
  32. Float:Pos[4], Float:Rot[3];
  33.  
  34. new bool:ObjectType[MAX_PLAYERS] = false,
  35. bool:CreatingTextO[MAX_PLAYERS] = false;
  36.  
  37. #define R "{FF0000}" //Red
  38. #define G "{C4C4C4}" //Grey
  39. #define Y "{EEEA00}" //Yellow
  40. #define B "{00A7EE}" //Blue
  41.  
  42.  
  43. #define MainDialog 0
  44. #define OTypeDialog 1
  45. #define OModelDialog 2
  46. #define TextDialog 3
  47. #define IndexDialog 4
  48. #define SizesDialog 5
  49. #define FontNDialog 6
  50. #define FontSDialog 7
  51. #define BoldDialog 8
  52. #define ColorDialog 9
  53. #define BackgDialog 10
  54. #define BackgColorD 11
  55. #define AlignDialog 12
  56. #define SaveDialog 13
  57. #define ColorDialog2 14
  58. #define ColorDialog3 15
  59. #define ColorDialog4 16
  60. #define ColorDialog5 17
  61.  
  62. public OnFilterScriptInit()
  63. {
  64. print(" ____________________________");
  65. print(" |-Text Object Editor Loaded- |");
  66. print(" | Scripted by irinel1996 |");
  67. print(" | Copyright © 2012-2013 |");
  68. print(" | Keep the credits! |");
  69. print(" |____________________________|");
  70. return 1;
  71. }
  72.  
  73. public OnPlayerCommandText(playerid, cmdtext[])
  74. {
  75. if(!strcmp(cmdtext, "/createot", true) || !strcmp(cmdtext, "/cto", true) || !strcmp(cmdtext, "/create", true))
  76. {
  77. if(CreatingTextO[playerid] == false)
  78. {
  79. TextAlign[playerid] = 1,
  80. Text[playerid] = "Example",
  81. FontName[playerid] = "Arial",
  82. TextColor[playerid] = HexToInt("0xFFFF8200"),
  83. BackgColor[playerid] = HexToInt("0xFF000000");
  84.  
  85. CreatingTextO[playerid] = true, ShowMainMenu(playerid);
  86. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]), GetPlayerFacingAngle(playerid, Pos[3]);
  87. new Float:x = Pos[0] + (5.0 * floatsin(-Pos[3], degrees));
  88. new Float:y = Pos[1] + (5.0 * floatcos(-Pos[3], degrees));
  89.  
  90. Object[playerid] = CreatePlayerObject(playerid, ObjectID[playerid], x, y, Pos[2]+0.5, 0.0, 0.0, Pos[3] - 90.0);
  91.  
  92. SetPlayerObjectMaterialText(playerid, Object[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  93. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  94.  
  95. SendClientMessage(playerid,-1,""R"* "B"INFO: "Y"New Text Object created.");
  96. } else { ShowMainMenu(playerid); }
  97. return 1;
  98. }
  99. if(!strcmp(cmdtext, "/test", true))
  100. {
  101. new MiObjeto = CreateObject(19353, 1965.633911, 1343.049560, 15.874607, 0.000000, 0.000000, 179.142486);
  102. SetObjectMaterialText(MiObjeto, "Example", 0, 50, "Arial", 24, 0, -32256, -16777216, 1);
  103. return 1;
  104. }
  105. return 0;
  106. }
  107.  
  108. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  109. {
  110. if(dialogid == MainDialog){
  111. if(response){
  112. switch(listitem) {
  113. case 0:{
  114. new string[128], type[30];
  115. if(ObjectType[playerid] == false) type = "Normal Object";
  116. else if(ObjectType[playerid] == true) type = "Player Object";
  117. format(string, sizeof(string),""B"Curret Object Type: "Y"%s\
  118. \n"G"Please, select your Object Type below:",type);
  119. ShowPlayerDialog(playerid,OTypeDialog,DIALOG_STYLE_MSGBOX," "R"Object Type",string,"Normal O.","Player O.");
  120. }
  121. case 1:{
  122. new string[128];
  123. format(string, sizeof(string), ""B"Current Object Model ID: "Y"%d\
  124. \n"G"Please, type below a Model ID for the object (example = 19353):",ObjectID[playerid]);
  125. ShowPlayerDialog(playerid,OModelDialog,DIALOG_STYLE_INPUT," "R"Object Model ID",string,"Change","Back");
  126. }
  127. case 2:{
  128. new string[300];
  129. format(string, sizeof(string),""B"Current Object Text: "Y"%s\
  130. \n"G"Please, type below your text for the object:",Text[playerid]);
  131. ShowPlayerDialog(playerid,TextDialog,DIALOG_STYLE_INPUT," "R"Object Text",string,"Change","Back");
  132. }
  133. case 3: {
  134. new string[128];
  135. format(string, sizeof(string),""B"Current Material Index: "Y"%d\
  136. \n"G"Please, type below the Material Index which you want use (default = 0):",Index[playerid]);
  137. ShowPlayerDialog(playerid,IndexDialog,DIALOG_STYLE_INPUT," "R"Material Index",string,"Change","Back");
  138. }
  139. case 4: {
  140. new sizes[600];
  141. strcat(sizes,""Y"1. "B"32x32 "G"(10)\
  142. \n"Y"2. "B"64x32 "G"(20)\
  143. \n"Y"3. "B"64x64 "G"(30)\
  144. \n"Y"4. "B"128x32 "G"(40)\
  145. \n"Y"5. "B"128x64 "G"(50)\
  146. \n"Y"6. "B"128x128 "G"(60)\
  147. \n"Y"7. "B"256x32 "G"(70)");
  148. strcat(sizes,"\n"Y"8. "B"256x64 "G"(80)\
  149. \n"Y"9. "B"256x128 "G"(90)\
  150. \n"Y"10. "B"256x256 "G"(100)\
  151. \n"Y"11. "B"512x64 "G"(110)\
  152. \n"Y"12. "B"512x128 "G"(120)\
  153. \n"Y"13. "B"512x256 "G"(130)\
  154. \n"Y"14. "B"512x512 "G"(140)");
  155. new current[128];
  156. format(current, sizeof(current),""R"Material Size "G"| "B"Current size: "Y"%d",Size[playerid]);
  157. ShowPlayerDialog(playerid,SizesDialog,DIALOG_STYLE_LIST,current,sizes,"Change","Back");
  158. }
  159. case 5: {
  160. new string[128];
  161. format(string, sizeof(string), ""B"Current Text Font: "Y"%s\
  162. \n"G"Please, type below the Text Font name which you want use:",FontName[playerid]);
  163. ShowPlayerDialog(playerid,FontNDialog,DIALOG_STYLE_INPUT," "R"Text Font",string,"Change","Back");
  164. }
  165. case 6: {
  166. new string[128];
  167. format(string, sizeof(string), ""B"Current Text Size: "Y"%d\
  168. \n"G"Please, type below the Text Size which you want use:",FontSize[playerid]);
  169. ShowPlayerDialog(playerid,FontSDialog,DIALOG_STYLE_INPUT," "R"Text Size",string,"Change","Back");
  170. }
  171. case 7: {
  172. new title[100]; new yesorno[10];
  173. if(UseBold[playerid] == 0) yesorno = "No";
  174. else if(UseBold[playerid] == 1) yesorno = "Yes";
  175. format(title, sizeof(title), ""R"Bold Text "G"| "B"Using Bold Text: "Y"%s",yesorno);
  176. ShowPlayerDialog(playerid,BoldDialog,DIALOG_STYLE_LIST,title,""Y"1. "B"No\n"Y"2. "B"Yes","Change","Back");
  177. }
  178. case 8: {
  179. new titulo[100];
  180. format(titulo, sizeof(titulo),""R"Text Color "G"| "B"Current Text Color: "Y"%i",TextColor[playerid]);
  181. ShowPlayerDialog(playerid,ColorDialog,DIALOG_STYLE_LIST,titulo,""Y"1. "B"Type a ARGB color code\
  182. \n"Y"2. "B"Select a predefinded color","Next","Back");
  183. }
  184. case 9: {
  185. new titulo[100];
  186. format(titulo, sizeof(titulo),""R"Object Background "G"| "B"Current Text Color: "Y"%i",BackgColor[playerid]);
  187. ShowPlayerDialog(playerid,BackgColorD,DIALOG_STYLE_LIST,titulo,""Y"1. "B"Disable Background\n"Y"2. "B"Type a ARGB color code\
  188. \n"Y"3. "B"Select a predefinded color","Next","Back");
  189. }
  190. case 10: {
  191. new title[100]; new position[30];
  192. if(TextAlign[playerid] == 0) position = "Left";
  193. else if(TextAlign[playerid] == 1) position = "Center";
  194. else if(TextAlign[playerid] == 2) position = "Right";
  195. format(title, sizeof(title), ""R"Text Alignment "G"| "B"Current Alignment: "Y"%s",position);
  196. ShowPlayerDialog(playerid,AlignDialog,DIALOG_STYLE_LIST,title,""Y"1. "B"Left\n"Y"2. "B"Center\n"Y"3. "B"Right","Change","Back");
  197. }
  198. case 11: {
  199. EditPlayerObject(playerid, Object[playerid]);
  200. SendClientMessage(playerid,-1,""R"* "B"INFO: "Y"Use "G"ESC "Y"to cancel the object edition.");
  201. }
  202. case 12: {
  203. ShowPlayerDialog(playerid,SaveDialog,DIALOG_STYLE_INPUT," "R"Exporting Lines",
  204. "Please, type a name for the object below (example = MyObject):","Export","Back");
  205. }
  206. case 13: {
  207. CreatingTextO[playerid] = false, DestroyPlayerObject(playerid, Object[playerid]);
  208. TextAlign[playerid] = 1, Text[playerid] = "Example", FontName[playerid] = "Arial",
  209. TextColor[playerid] = HexToInt("0xFFFF8200"), BackgColor[playerid] = HexToInt("0xFF000000"),
  210. Size[playerid] = 50, Index[playerid] = 0, UseBold[playerid] = 0,
  211. FontSize[playerid] = 24, OName[playerid] = "0", ObjectID[playerid] = 19353;
  212. SendClientMessage(playerid,-1,""R"* "B"INFO: "Y"All settings have been reseted.");
  213. }
  214. }
  215. }
  216. return 1;
  217. }
  218. if(dialogid == OTypeDialog)
  219. {
  220. if(response)
  221. {
  222. ObjectType[playerid] = false;
  223. SendClientMessage(playerid,-1,""R"* "B"Object Type: "Y"Normal Object"); ShowMainMenu(playerid);
  224. } else {
  225. ObjectType[playerid] = true;
  226. SendClientMessage(playerid,-1,""R"* "B"Object Type: "Y"Player Object"); ShowMainMenu(playerid);
  227. }
  228. return 1;
  229. }
  230. if(dialogid == OModelDialog)
  231. {
  232. if(response)
  233. {
  234. if(!isNumeric(inputtext)) return SendClientMessage(playerid,-1,""Y"* "R"ERROR: "G"Please, use a numeric value"R"!"), ShowMainMenu(playerid);
  235. new string[128];
  236. ObjectID[playerid] = strval(inputtext);
  237. format(string, sizeof(string), ""R"* "B"Object Model ID: "Y"%d",ObjectID[playerid]);
  238. SendClientMessage(playerid,-1,string); UpdateObject(playerid), ShowMainMenu(playerid);
  239. } else { ShowMainMenu(playerid); }
  240. return 1;
  241. }
  242. if(dialogid == TextDialog){
  243. if(response){
  244. new string[128];
  245. format(string, sizeof(string),"%s",inputtext);
  246. Text[playerid] = string; format(string, sizeof(string), ""R"* "B"Object Text: "Y"%s",Text[playerid]);
  247. SendClientMessage(playerid,-1,string); UpdateObject(playerid), ShowMainMenu(playerid);
  248. } else { ShowMainMenu(playerid); }
  249. return 1;
  250. }
  251. if(dialogid == IndexDialog){
  252. if(response){
  253. if(!isNumeric(inputtext)) return SendClientMessage(playerid,-1,""Y"* "R"ERROR: "G"Please, use a numeric value"R"!"), ShowMainMenu(playerid);
  254. new string[100];
  255. Index[playerid] = strval(inputtext);
  256. format(string, sizeof(string),""R"* "B"Object Material Index: "Y"%d",Index[playerid]);
  257. SendClientMessage(playerid,-1,string); UpdateObject(playerid), ShowMainMenu(playerid);
  258. } else { ShowMainMenu(playerid); }
  259. return 1;
  260. }
  261. if(dialogid == SizesDialog){
  262. if(response)
  263. {
  264. switch(listitem) {
  265. case 0: Size[playerid] = 10;
  266. case 1: Size[playerid] = 20;
  267. case 2: Size[playerid] = 30;
  268. case 3: Size[playerid] = 40;
  269. case 4: Size[playerid] = 50;
  270. case 5: Size[playerid] = 60;
  271. case 6: Size[playerid] = 70;
  272. case 7: Size[playerid] = 80;
  273. case 8: Size[playerid] = 90;
  274. case 9: Size[playerid] = 100;
  275. case 10: Size[playerid] = 110;
  276. case 11: Size[playerid] = 120;
  277. case 12: Size[playerid] = 130;
  278. case 13: Size[playerid] = 140;
  279. default: Size[playerid] = 70;
  280. }
  281. new string[128];
  282. format(string, sizeof(string), ""R"* "B"Object Material Size: "Y"%d",Size[playerid]);
  283. SendClientMessage(playerid,-1,string); UpdateObject(playerid), ShowMainMenu(playerid);
  284. } else { ShowMainMenu(playerid); }
  285. return 1;
  286. }
  287. if(dialogid == FontNDialog)
  288. {
  289. if(response) {
  290. new string[128]; format(string, sizeof(string),"%s",inputtext); FontName[playerid] = string;
  291. format(string, sizeof(string), ""R"* "B"Text Font: "Y"%s",FontName[playerid]); SendClientMessage(playerid,-1,string);
  292. UpdateObject(playerid), ShowMainMenu(playerid);
  293. } else { ShowMainMenu(playerid); }
  294. return 1;
  295. }
  296. if(dialogid == FontSDialog)
  297. {
  298. if(response) {
  299. if(!isNumeric(inputtext)) return SendClientMessage(playerid,-1,""Y"* "R"ERROR: "G"Please, use a numeric value"R"!"), ShowMainMenu(playerid);
  300. new string[128]; FontSize[playerid] = strval(inputtext);
  301. format(string, sizeof(string), ""R"* "B"Text Size: "Y"%d",FontSize[playerid]); SendClientMessage(playerid,-1,string);
  302. UpdateObject(playerid), ShowMainMenu(playerid);
  303. } else { ShowMainMenu(playerid); }
  304. return 1;
  305. }
  306. if(dialogid == BoldDialog)
  307. {
  308. if(response)
  309. {
  310. switch(listitem)
  311. {
  312. case 0: {
  313. UseBold[playerid] = 0;
  314. SendClientMessage(playerid,-1,""R"* "B"Bold Text: "Y"No");
  315. UpdateObject(playerid), ShowMainMenu(playerid);
  316. }
  317. case 1: {
  318. UseBold[playerid] = 1;
  319. SendClientMessage(playerid,-1,""R"* "B"Bold Text: "Y"Yes");
  320. UpdateObject(playerid), ShowMainMenu(playerid);
  321. }
  322. }
  323. } else { ShowMainMenu(playerid); }
  324. return 1;
  325. }
  326. if(dialogid == ColorDialog)
  327. {
  328. if(response)
  329. {
  330. switch(listitem)
  331. {
  332. case 0: {
  333. ShowPlayerDialog(playerid,ColorDialog2,DIALOG_STYLE_INPUT," "R"Text Color",
  334. ""G"Please, type a ARGB color code below (example = 0xFFFF0000):","Change","Back");
  335. }
  336. case 1: {
  337. ShowPlayerDialog(playerid,ColorDialog3,DIALOG_STYLE_LIST,""R"Color List",
  338. "{FF0000}Red\n{04B404}Green\n{00B5CD}Sky-Blue\n{FFFF00}Yellow\
  339. \n{0000FF}Blue\n{848484}Grey\n{FF00FF}Pink\n{FFFFFF}White","Change","Back");
  340. }
  341. }
  342. } else { ShowMainMenu(playerid); }
  343. return 1;
  344. }
  345. if(dialogid == ColorDialog2)
  346. {
  347. if(response) {
  348. new string[80]; TextColor[playerid] = HexToInt(inputtext);
  349. format(string, sizeof(string),""R"* "B"Text Color: "Y"%i", TextColor[playerid]);
  350. SendClientMessage(playerid,-1,string); UpdateObject(playerid), ShowMainMenu(playerid);
  351. } else {
  352. new titulo[100];
  353. format(titulo, sizeof(titulo),""R"Text Color "G"| "B"Current Text Color: "Y"%i",TextColor[playerid]);
  354. ShowPlayerDialog(playerid,ColorDialog,DIALOG_STYLE_LIST,titulo,""Y"1. "B"Type a ARGB color code\
  355. \n"Y"2. "B"Select a predefinded color","Next","Back");
  356. }
  357. return 1;
  358. }
  359. if(dialogid == ColorDialog3)
  360. {
  361. if(response) {
  362. switch(listitem)
  363. {
  364. case 0: { TextColor[playerid] = HexToInt("0xFFFF0000"); } //Red
  365. case 1: { TextColor[playerid] = HexToInt("0xFF04B404"); }
  366. case 2: { TextColor[playerid] = HexToInt("0xFF00B5CD"); }
  367. case 3: { TextColor[playerid] = HexToInt("0xFFFFFF00"); } //Yellow
  368. case 4: { TextColor[playerid] = HexToInt("0xFF0000FF"); }
  369. case 5: { TextColor[playerid] = HexToInt("0xFF848484"); }
  370. case 6: { TextColor[playerid] = HexToInt("0xFFFF00FF"); }
  371. case 7: { TextColor[playerid] = HexToInt("0xFFFFFFFF"); } //White
  372. }
  373. new string[80]; UpdateObject(playerid);
  374. format(string, sizeof(string),""R"* "B"Text Color: "Y"%i", TextColor[playerid]);
  375. SendClientMessage(playerid,-1,string); ShowMainMenu(playerid);
  376. } else {
  377. new titulo[100];
  378. format(titulo, sizeof(titulo),""R"Text Color "G"| "B"Current Text Color: "Y"%i",TextColor[playerid]);
  379. ShowPlayerDialog(playerid,ColorDialog,DIALOG_STYLE_LIST,titulo,""Y"1. "B"Type a ARGB color code\
  380. \n"Y"2. "B"Select a predefinded color","Next","Back");
  381. }
  382. return 1;
  383. }
  384. if(dialogid == BackgColorD)
  385. {
  386. if(response)
  387. {
  388. switch(listitem)
  389. {
  390. case 0: { BackgColor[playerid] = 0; UpdateObject(playerid); ShowMainMenu(playerid); SendClientMessage(playerid,-1,""R"* "B"Background Color: "Y"Disabled"); }
  391. case 1: {
  392. ShowPlayerDialog(playerid,ColorDialog4,DIALOG_STYLE_INPUT," "R"Background Color",
  393. ""G"Please, type a ARGB color code below (example = 0xFFFF0000):","Change","Back");
  394. }
  395. case 2: {
  396. ShowPlayerDialog(playerid,ColorDialog5,DIALOG_STYLE_LIST,""R"Color List",
  397. "{FF0000}Red\n{04B404}Green\n{00B5CD}Sky-Blue\n{FFFF00}Yellow\
  398. \n{0000FF}Blue\n{848484}Grey\n{FF00FF}Pink\n{FFFFFF}White","Change","Back");
  399. }
  400. }
  401. } else { ShowMainMenu(playerid); }
  402. return 1;
  403. }
  404. if(dialogid == ColorDialog4)
  405. {
  406. if(response) {
  407. new string[80]; BackgColor[playerid] = HexToInt(inputtext);
  408. format(string, sizeof(string),""R"* "B"Background Color: "Y"%i", BackgColor[playerid]);
  409. SendClientMessage(playerid,-1,string); UpdateObject(playerid), ShowMainMenu(playerid);
  410. } else {
  411. new titulo[100];
  412. format(titulo, sizeof(titulo),""R"Object Background "G"| "B"Current Text Color: "Y"%i",BackgColor[playerid]);
  413. ShowPlayerDialog(playerid,BackgColorD,DIALOG_STYLE_LIST,titulo,""Y"1. "B"Disable Background\n"Y"2. "B"Type a ARGB color code\
  414. \n"Y"3. "B"Select a predefinded color","Next","Back");
  415. }
  416. return 1;
  417. }
  418. if(dialogid == ColorDialog5)
  419. {
  420. if(response) {
  421. switch(listitem)
  422. {
  423. case 0: { BackgColor[playerid] = HexToInt("0xFFFF0000"); } //Red
  424. case 1: { BackgColor[playerid] = HexToInt("0xFF04B404"); }
  425. case 2: { BackgColor[playerid] = HexToInt("0xFF00B5CD"); }
  426. case 3: { BackgColor[playerid] = HexToInt("0xFFFFFF00"); } //Yellow
  427. case 4: { BackgColor[playerid] = HexToInt("0xFF0000FF"); }
  428. case 5: { BackgColor[playerid] = HexToInt("0xFF848484"); }
  429. case 6: { BackgColor[playerid] = HexToInt("0xFFFF00FF"); }
  430. case 7: { BackgColor[playerid] = HexToInt("0xFFFFFFFF"); } //White
  431. }
  432. new string[80]; UpdateObject(playerid); ShowMainMenu(playerid);
  433. format(string, sizeof(string),""R"* "B"Background Color: "Y"%i", BackgColor[playerid]);
  434. SendClientMessage(playerid,-1,string);
  435. } else {
  436. new titulo[100];
  437. format(titulo, sizeof(titulo),""R"Object Background "G"| "B"Current Text Color: "Y"%i",BackgColor[playerid]);
  438. ShowPlayerDialog(playerid,BackgColorD,DIALOG_STYLE_LIST,titulo,""Y"1. "B"Disable Background\n"Y"2. "B"Type a ARGB color code\
  439. \n"Y"3. "B"Select a predefinded color","Next","Back");
  440. }
  441. return 1;
  442. }
  443. if(dialogid == AlignDialog)
  444. {
  445. if(response) {
  446. switch(listitem)
  447. {
  448. case 0: {
  449. TextAlign[playerid] = 0; UpdateObject(playerid);
  450. SendClientMessage(playerid,-1,""R"* "B"Text Alignment: "Y"Left"), ShowMainMenu(playerid);
  451. }
  452. case 1: {
  453. TextAlign[playerid] = 1; UpdateObject(playerid);
  454. SendClientMessage(playerid,-1,""R"* "B"Text Alignment: "Y"Center"), ShowMainMenu(playerid);
  455. }
  456. case 2: {
  457. TextAlign[playerid] = 2; UpdateObject(playerid);
  458. SendClientMessage(playerid,-1,""R"* "B"Text Alignment: "Y"Right"), ShowMainMenu(playerid);
  459. }
  460. }
  461. } else { ShowMainMenu(playerid); }
  462. }
  463. if(dialogid == SaveDialog)
  464. {
  465. if(response)
  466. {
  467. if(strlen(inputtext) <= 0) return SendClientMessage(playerid,-1,""Y"* "R"ERROR: "G"Please, type something for the object name"R"!"), ShowMainMenu(playerid);
  468. new string[600], soname[30];
  469. format(soname, sizeof(soname),"%s",inputtext); OName[playerid] = soname;
  470. new Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ;
  471. GetPlayerObjectPos(playerid, Object[playerid], fX, fY, fZ),
  472. GetPlayerObjectRot(playerid, Object[playerid], fRotX, fRotY, fRotZ);
  473. if(!fexist("textobjects.txt"))
  474. {
  475. new File:archivo = fopen("textobjects.txt", io_write);
  476. if(ObjectType[playerid] == false) {
  477. format(string, sizeof(string),"new %s = CreateObject(%d, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f);\
  478. \r\nSetObjectMaterialText(%s, \"%s\", %d, %d, \"%s\", %d, %d, %i, %i, %d);",OName[playerid],ObjectID[playerid],
  479. fX, fY, fZ, fRotX, fRotY, fRotZ, OName[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  480. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  481. fwrite(archivo,string);
  482. fclose(archivo);
  483. } else {
  484. format(string, sizeof(string),"new %s = CreatePlayerObject(playerid, %d, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f);\
  485. \r\nSetPlayerObjectMaterialText(playerid, %s, \"%s\", %d, %d, \"%s\", %d, %d, %i, %i, %d);",OName[playerid],ObjectID[playerid],
  486. fX, fY, fZ, fRotX, fRotY, fRotZ, OName[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  487. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  488. fwrite(archivo,string); fclose(archivo);
  489. }
  490. } else {
  491. new File:archivo = fopen("textobjects.txt", io_append);
  492. if(ObjectType[playerid] == false) {
  493. format(string, sizeof(string),"\r\n\r\nnew %s = CreateObject(%d, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f);\
  494. \r\nSetObjectMaterialText(%s, \"%s\", %d, %d, \"%s\", %d, %d, %i, %i, %d);",OName[playerid],ObjectID[playerid],
  495. fX, fY, fZ, fRotX, fRotY, fRotZ, OName[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  496. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  497. fwrite(archivo,string); fclose(archivo);
  498. } else {
  499. format(string, sizeof(string),"\r\n\r\nnew %s = CreatePlayerObject(playerid, %d, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f, %0.4f);\
  500. \r\nSetPlayerObjectMaterialText(playerid, %s, \"%s\", %d, %d, \"%s\", %d, %d, %i, %i, %d);",OName[playerid],ObjectID[playerid],
  501. fX, fY, fZ, fRotX, fRotY, fRotZ, OName[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  502. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  503. fwrite(archivo,string); fclose(archivo);
  504. }
  505. }
  506. //---
  507. CreatingTextO[playerid] = false, DestroyPlayerObject(playerid, Object[playerid]);
  508. TextAlign[playerid] = 1, Text[playerid] = "Example", FontName[playerid] = "Arial",
  509. TextColor[playerid] = HexToInt("0xFFFF8200"), BackgColor[playerid] = HexToInt("0xFF000000"),
  510. Size[playerid] = 50, Index[playerid] = 0, UseBold[playerid] = 0,
  511. FontSize[playerid] = 24, OName[playerid] = "0", ObjectID[playerid] = 19353;
  512. //---
  513. SendClientMessage(playerid,-1,""R"* "B"INFO: "Y"Script saved, check your "G"textobjects.txt "Y"in "G"scriptfiles"Y".");
  514. SendClientMessage(playerid,-1,""R"* "B"INFO: "Y"All settings have been reseted.");
  515. } else { ShowMainMenu(playerid); }
  516. return 1;
  517. }
  518. return 0;
  519. }
  520.  
  521. ShowMainMenu(playerid)
  522. {
  523. new string[600];
  524. strcat(string,""Y"1. "B"Set Object Type\n"Y"2. "B"Set Object Model ID\n"Y"3. "B"Set Object Text\
  525. \n"Y"4. "B"Set Material Index\n"Y"5. "B"Set Material Size\n");
  526. strcat(string, ""Y"6. "B"Set Text Font\n"Y"7. "B"Set Text Size\n"Y"8. "B"Set Bold Text\
  527. \n"Y"9. "B"Set Text Color\n"Y"10. "B"Set Background Color\n"Y"11. "B"Set Text Alignment\n"Y"12. "G"Edit Object\
  528. \n"Y"13. "G"Export Lines\n"Y"14. "G"Reset Object");
  529. ShowPlayerDialog(playerid,MainDialog,DIALOG_STYLE_LIST,""R"Text Object | Main Menu",string,"Continue","Exit");
  530. return 1;
  531. }
  532.  
  533. UpdateObject(playerid)
  534. {
  535. GetPlayerObjectPos(playerid, Object[playerid], Pos[0], Pos[1], Pos[2]);
  536. GetPlayerObjectRot(playerid, Object[playerid], Rot[0], Rot[1], Rot[2]); DestroyPlayerObject(playerid, Object[playerid]);
  537. Object[playerid] = CreatePlayerObject(playerid, ObjectID[playerid], Pos[0], Pos[1], Pos[2], Rot[0], Rot[1], Rot[2]);
  538.  
  539. SetPlayerObjectMaterialText(playerid, Object[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  540. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  541. }
  542.  
  543. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  544. {
  545. if(objectid == Object[playerid]) {
  546. if(response == EDIT_RESPONSE_FINAL)
  547. {
  548. SendClientMessage(playerid,-1,""R"* "B"Object Edition: "Y"Updated");
  549. DestroyPlayerObject(playerid, Object[playerid]);
  550. Object[playerid] = CreatePlayerObject(playerid, ObjectID[playerid], fX, fY, fZ, fRotX, fRotY, fRotZ);
  551. SetPlayerObjectMaterialText(playerid, Object[playerid], Text[playerid], Index[playerid], Size[playerid], FontName[playerid],
  552. FontSize[playerid], UseBold[playerid], TextColor[playerid], BackgColor[playerid], TextAlign[playerid]);
  553. ShowMainMenu(playerid);
  554. } else if(response == EDIT_RESPONSE_CANCEL) {
  555. SendClientMessage(playerid,-1,""R"* "B"Object Edition: "Y"No updated"); UpdateObject(playerid), ShowMainMenu(playerid);
  556. }
  557. }
  558. }
  559. stock HexToInt(string[]) //By Zamaroht, I think... =/
  560. {
  561. if (string[0]==0) return 0;
  562. new i;
  563. new cur=1;
  564. new res=0;
  565. for (i=strlen(string);i>0;i--) {
  566. if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
  567. cur=cur*16;
  568. }
  569. return res;
  570. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement