Advertisement
Guest User

iText Object Editor v0.1

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