Advertisement
Paulo_AttacK

TextDrawMove v1.5

Jul 8th, 2012
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.53 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. //        #### ########   ######     ######## ########    ###    ##     ##
  5. //         ##  ##     ## ##    ##       ##    ##         ## ##   ###   ###
  6. //         ##  ##     ## ##             ##    ##        ##   ##  #### ####
  7. //         ##  ########   ######        ##    ######   ##     ## ## ### ##
  8. //         ##  ##              ##       ##    ##       ######### ##     ##
  9. //         ##  ##        ##    ##       ##    ##       ##     ## ##     ##
  10. //        #### ##         ######        ##    ######## ##     ## ##     ##
  11. //
  12. //
  13. //                              TextDrawMove v1.5
  14. //
  15. /*                   ______          ______           _      
  16. //                   | ___ \         | ___ \         | |      
  17. //                   | |_/ /_   _    | |_/ /_ _ _   _| | ___  
  18. //                   | ___ \ | | |   |  __/ _` | | | | |/ _ \
  19. //                   | |_/ / |_| |_  | | | (_| | |_| | | (_) |
  20. //                   \____/ \__, (_) \_|  \__,_|\__,_|_|\___/
  21. //                           __/ |                            
  22. //                          |___/                            
  23. */                            
  24. //              Agradecimento especial à Drakins(Otimizou ResetArray)
  25. //
  26. //            !!!   Mova facilmente e dinamicamente suas TextDraws   !!!
  27. //
  28. //          [iPs]TeaM soluções de programação em geral (agora com cursos)
  29. //
  30. //                  http://ips-team.forumeiros.com/ (contate-nos)
  31. //
  32. /////////////////////////////////////////////////////////////////////////////////
  33.  
  34. #define Function%0(%1) forward%0(%1); public%0(%1)
  35.  
  36. #define PT_MOVE_BOX 0
  37. #define PT_MOVE_TEXT 1
  38.  
  39. #define ResetArray(%0); new ArrayReset[MAX_TEXT_DRAWS]; %0 = ArrayReset;
  40.  
  41. new PT_Text[Text:MAX_TEXT_DRAWS][800 char],
  42.     Float:PT_X[Text:MAX_TEXT_DRAWS],
  43.     Float:PT_Y[Text:MAX_TEXT_DRAWS],
  44.     PT_Alig[Text:MAX_TEXT_DRAWS char],
  45.     PT_BackCor[Text:MAX_TEXT_DRAWS],
  46.     PT_BoxCor[Text:MAX_TEXT_DRAWS],
  47.     PT_Cor[Text:MAX_TEXT_DRAWS],
  48.     PT_Font[Text:MAX_TEXT_DRAWS char],
  49.     Float:PT_lX[Text:MAX_TEXT_DRAWS],
  50.     Float:PT_lY[Text:MAX_TEXT_DRAWS],
  51.     PT_Line[Text:MAX_TEXT_DRAWS char],
  52.     PT_Prop[Text:MAX_TEXT_DRAWS char],
  53.     PT_Sombra[Text:MAX_TEXT_DRAWS char],
  54.     PT_Box[Text:MAX_TEXT_DRAWS char],
  55.     Float:PT_tX[Text:MAX_TEXT_DRAWS],
  56.     Float:PT_tY[Text:MAX_TEXT_DRAWS],
  57.     PT_Timer[Text:MAX_TEXT_DRAWS char],
  58.     bool:PT_Movendo[Text:MAX_TEXT_DRAWS char],
  59.     bool:PT_Fadding[Text:MAX_TEXT_DRAWS char];
  60.  
  61. stock TextDrawMove(Text:Td, Float:fX, Float:fY, Float:fX2, Float:fY2, Speed, Move, playerid = INVALID_PLAYER_ID) {
  62.     if(!Speed || PT_Movendo{Td} || (PT_X[Td] == fX && PT_Y[Td] == fY && PT_tX[Td] == fX2 && PT_tY[Td] == fY2)) return 1;
  63.     static MaiorDist;
  64.     if(floatabs(PT_X[Td]-fX) > floatabs(PT_Y[Td]-fY)) MaiorDist = floatround(floatabs(PT_X[Td]-fX));
  65.     else MaiorDist = floatround(floatabs(PT_Y[Td]-fY));
  66.     if(floatabs(PT_tX[Td]-fX2) > floatabs(PT_tY[Td]-fY2) && floatabs(PT_tX[Td]-fX2) > MaiorDist) MaiorDist = floatround(floatabs(PT_tX[Td]-fX2));
  67.     else if(floatabs(PT_tY[Td]-fY2) > MaiorDist) MaiorDist = floatround(floatabs(PT_tY[Td]-fY2));
  68.     PT_Timer{Td} = SetTimerEx(#MoveTd, ((MaiorDist/Speed)/20), false, #iffffiiii, _:Td, (fX == 0.0 ? PT_X[Td] : fX), (fY == 0.0 ? PT_Y[Td] : fY), (fX2 == 0.0 ? PT_tX[Td] : fX2), (fY2 == 0.0 ? PT_tY[Td] : fY2), ((MaiorDist/Speed)/20), MaiorDist, Move, playerid);
  69.     return PT_Movendo{Td} = true;
  70. }
  71.  
  72. stock TextDrawFade(Text:Td, Color, Speed, playerid = INVALID_PLAYER_ID) {
  73.     if(PT_Fadding{Td}) return 1;
  74.     new Cor[2][11]; HexStr(Color, Cor[0]), HexStr((PT_Box{Td} ? PT_BoxCor[Td] : PT_Cor[Td]), Cor[1]);
  75.     PT_Timer{Td} = SetTimerEx(#FadeTd, Speed*30, false, #iiiii, _:Td, (HexInt(Cor[0]) > HexInt(Cor[1]) ? HexInt(Cor[0])-HexInt(Cor[1]) : HexInt(Cor[1])-HexInt(Cor[0])), (Color > (PT_Box{Td} ? PT_BoxCor[Td] : PT_Cor[Td]) ? true : false), Speed*30, playerid);
  76.     return PT_Fadding{Td} = true;
  77. }
  78.  
  79. stock Text:TextDrawCreateEx(Float:x, Float:y, text[]) {
  80.     static Text:Td; Td = TextDrawCreate(x, y, text);
  81.     PT_X[Td] = x; PT_Y[Td] = y; format(PT_Text[Td], 800, text);
  82.     return Td;
  83. }
  84.  
  85. stock TextDrawAlignmentEx(Text:text, alignment) {
  86.     TextDrawAlignment(text, alignment);
  87.     PT_Alig{text} = alignment;
  88. }
  89.  
  90. stock TextDrawBackgroundColorEx(Text:text, color) {
  91.     TextDrawBackgroundColor(text, color);
  92.     PT_BackCor[text] = color;
  93. }
  94.  
  95. stock TextDrawBoxColorEx(Text:text, color) {
  96.     TextDrawBoxColor(text, color); new Cor[11]; HexStr(color, Cor);
  97.     PT_BoxCor[text] = HexInt(Cor);
  98. }
  99.  
  100. stock TextDrawColorEx(Text:text, color) {
  101.     TextDrawColor(text, color); new Cor[11]; HexStr(color, Cor);
  102.     PT_Cor[text] = HexInt(Cor);
  103. }
  104.  
  105. stock TextDrawFontEx(Text:text, font) {
  106.     TextDrawFont(text, font);
  107.     PT_Font{text} = font;
  108. }
  109.  
  110. stock TextDrawLetterSizeEx(Text:text, Float:x, Float:y) {
  111.     TextDrawLetterSize(text, x, y);
  112.     PT_lX[text] = x; PT_lY[text] = y;
  113. }
  114.  
  115. stock TextDrawSetOutlineEx(Text:text, size) {
  116.     TextDrawSetOutline(text, size);
  117.     PT_Line{text} = size;
  118. }
  119.  
  120. stock TextDrawSetProportionalEx(Text:text, set) {
  121.     TextDrawSetProportional(text, set);
  122.     PT_Prop{text} = set;
  123. }
  124.  
  125. stock TextDrawSetShadowEx(Text:text, size) {
  126.     TextDrawSetShadow(text, size);
  127.     PT_Sombra{text} = size;
  128. }
  129.  
  130. stock TextDrawTextSizeEx(Text:text, Float:x, Float:y) {
  131.     TextDrawTextSize(text, x, y);
  132.     PT_tX[text] = x; PT_tY[text] = y;
  133. }
  134.  
  135. stock TextDrawUseBoxEx(Text:text, use) {
  136.     TextDrawUseBox(text, use);
  137.     PT_Box{text} = use;
  138. }
  139.  
  140. stock TextDrawGetXAndYPos(Text:text, Float:Var[2]) return (Var[0] = PT_X[text], Var[1] = PT_Y[text], 1);
  141.  
  142. stock TextDrawGetXAndYTextSize(Text:text, Float:Var[2]) return (Var[0] = PT_tX[text], Var[1] = PT_tY[text], 1);
  143.  
  144. stock TextDrawGetXAndYLetterSize(Text:text, Float:Var[2]) return (Var[0] = PT_lX[text], Var[1] = PT_lY[text], 1);
  145.  
  146. stock TextDrawDestroyEx(Text:text) {
  147.     TextDrawDestroy(text);
  148.     ResetArray(PT_Text[text]);
  149.     PT_X[text] = 0;
  150.     PT_Y[text] = 0;
  151.     PT_Alig{text} = 0;
  152.     PT_BackCor[text] = 0;
  153.     PT_BoxCor[text] = 0;
  154.     PT_Cor[text] = 0;
  155.     PT_Font{text} = 0;
  156.     PT_lX[text] = 0;
  157.     PT_lY[text] = 0;
  158.     PT_Line{text} = 0;
  159.     PT_Prop{text} = 0;
  160.     PT_Sombra{text} = 0;
  161.     PT_Box{text} = 0;
  162.     PT_tX[text] = 0;
  163.     PT_tY[text] = 0;
  164. }
  165.  
  166. stock HexStr(Int, Color[11]) { //Baseado DOF2
  167.     static Caracters[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; Color = "0x";
  168.     for(new i; i != 8; ++i) Color[i+2] = Caracters[(Int >>> ((7 - i) << 2)) & 0x0F];
  169.     return Color;
  170. }
  171.  
  172. stock StrHex(Str[]) { //Baseado DOF2
  173.     new i, Int;
  174.     if(Str[0] == '0' && (Str[1] == 'x' || Str[1] == 'X')) i = 2;
  175.     while(Str[i]) {
  176.         Int <<= 4;
  177.         switch(Str[i]) {
  178.             case '0'..'9': Int |= Str[i] - '0';
  179.             case 'A'..'F': Int |= Str[i] - 'A' + 10;
  180.             case 'a'..'f': Int |= Str[i] - 'a' + 10;
  181.             default: return 0;
  182.         }
  183.         ++i;
  184.     }
  185.     return Int;
  186. }
  187.  
  188. stock HexInt(Str[]) { //Baseado Wiki
  189.     if(!Str[0]) return 0;
  190.     new Calc = 1, Result;
  191.     for(new i = strlen(Str); i != 0; i--) {
  192.         if(Str[i-2] == '0' && (Str[i-1] == 'x' || Str[i-1] == 'X')) continue;
  193.         if(Str[i-1] < 58) Result += Calc*(Str[i-1]-48);
  194.         else Result += Calc*(Str[i-1]-65+10);
  195.         Calc = Calc*0x10;
  196.     }
  197.     return Result;
  198. }
  199.  
  200. Function MoveTd(Text:Td, Float:fX, Float:fY, Float:fX2, Float:fY2, Time, MaiorDist, Move, playerid) {
  201.     static i; i++; TextDrawDestroy(Td);
  202.     Td = TextDrawCreate((PT_X[Td] < fX ? (PT_X[Td]+i < fX ? PT_X[Td]+i : fX) : (PT_X[Td]-i > fX ? PT_X[Td]-i : fX)), (PT_Y[Td] < fY ? (PT_Y[Td]+i < fY ? PT_Y[Td]+i : fY) : (PT_Y[Td]-i > fY ? PT_Y[Td]-i : fY)), PT_Text[Td]);
  203.     TextDrawAlignment(Td, PT_Alig{Td});
  204.     TextDrawBackgroundColor(Td, PT_BackCor[Td]);
  205.     TextDrawBoxColor(Td, PT_BoxCor[Td]);
  206.     TextDrawColor(Td, PT_Cor[Td]);
  207.     TextDrawFont(Td, PT_Font{Td});
  208.     TextDrawLetterSize(Td, PT_lX[Td], PT_lY[Td]);
  209.     TextDrawSetOutline(Td, PT_Line{Td});
  210.     TextDrawSetProportional(Td, PT_Prop{Td});
  211.     TextDrawSetShadow(Td, PT_Sombra{Td});
  212.     TextDrawUseBox(Td, PT_Box{Td});
  213.     if(Move == PT_MOVE_BOX) TextDrawTextSize(Td, (PT_tX[Td] < fX2 ? (PT_tX[Td]+i < fX2 ? PT_tX[Td]+i : fX2) : (PT_tX[Td]-i > fX2 ? PT_tX[Td]-i : fX2)), (PT_tY[Td] < fY2 ? (PT_tY[Td]+i < fY2 ? PT_tY[Td]+i : fY2) : (PT_tY[Td]-i > fY2 ? PT_tY[Td]-i : fY2)));
  214.     else TextDrawTextSize(Td, PT_tX[Td], PT_tY[Td]);
  215.     if(playerid == INVALID_PLAYER_ID) TextDrawShowForAll(Td);
  216.     else TextDrawShowForPlayer(playerid, Td);
  217.     if(i >= MaiorDist) return PT_X[Td] = fX, PT_Y[Td] = fY, PT_tX[Td] = fX2, PT_tY[Td] = fY2, PT_Movendo{Td} = false, i = 0;
  218.     return PT_Timer{Td} = SetTimerEx(#MoveTd, Time, false, #iffffiiii, _:Td, fX, fY, fX2, fY2, Time, MaiorDist, Move, playerid);
  219. }
  220.  
  221. Function FadeTd(Text:Td, Cor, bool:Calc, Time, playerid) {
  222.     static i = 5; i--;
  223.     if(PT_Box{Td}) TextDrawBoxColor(Td, (Calc ? (PT_BoxCor[Td]+(Cor/i)) : (PT_BoxCor[Td]-(Cor/i))));
  224.     else TextDrawColor(Td, (Calc ? (PT_Cor[Td]+(Cor/i)) : (PT_Cor[Td]-(Cor/i))));
  225.     if(playerid == INVALID_PLAYER_ID) TextDrawShowForAll(Td);
  226.     else TextDrawShowForPlayer(playerid, Td);
  227.     if(i == 1) return (PT_Box{Td} ? (PT_BoxCor[Td] = (Calc ? (PT_BoxCor[Td]+Cor) : (PT_BoxCor[Td]-Cor))) : (PT_Cor[Td] = (Calc ? (PT_Cor[Td]+Cor) : (PT_Cor[Td]-Cor)))), i = 5, PT_Fadding{Td} = false;
  228.     return PT_Timer{Td} = SetTimerEx(#FadeTd, Time, false, #iiiii, _:Td, Cor, Calc, Time, playerid);
  229. }
  230.  
  231. #define TextDrawCreate TextDrawCreateEx
  232. #define TextDrawAlignment TextDrawAlignmentEx
  233. #define TextDrawBackgroundColor TextDrawBackgroundColorEx
  234. #define TextDrawBoxColor TextDrawBoxColorEx
  235. #define TextDrawColor TextDrawColorEx
  236. #define TextDrawFont TextDrawFontEx
  237. #define TextDrawLetterSize TextDrawLetterSizeEx
  238. #define TextDrawSetOutline TextDrawSetOutlineEx
  239. #define TextDrawSetProportional TextDrawSetProportionalEx
  240. #define TextDrawSetShadow TextDrawSetShadowEx
  241. #define TextDrawUseBox TextDrawUseBoxEx
  242. #define TextDrawTextSize TextDrawTextSizeEx
  243. #define TextDrawDestroy TextDrawDestroyEx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement