Advertisement
mrdrifter

Textdraw fixer [@update: 2014-02-13]

Feb 13th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. /*
  2. Textdraw fixer
  3.  
  4. @author: mrdrifter
  5. @update: 2014-02-13
  6.  
  7. @description: Biblioteka naprawia bugi SA:MP związane z TextDrawami
  8. */
  9. #if defined _draw_fix_included
  10. #endinput
  11. #endif
  12. #define _draw_fix_included
  13.  
  14. new bool:Textdraw@ALS_@Data[Text:MAX_TEXT_DRAWS];
  15. new bool:PlayerTextdraw@ALS_@Data[MAX_PLAYERS][PlayerText:MAX_PLAYER_TEXT_DRAWS];
  16.  
  17. stock Text:TextDrawCreateEx(Float:x, Float:y, text[])
  18. {
  19. PolishChars@ALS_@Replace(text);
  20. new Text:id = TextDrawCreate(x, y, text);
  21. Textdraw@ALS_@Data[id] = true;
  22. return id;
  23. }
  24.  
  25. #define TextDrawCreate TextDrawCreateEx
  26.  
  27. stock TextDrawDestroyEx(Text:text)
  28. {
  29. if(!Textdraw@ALS_@Data[text]) return INVALID_TEXT_DRAW;
  30. Textdraw@ALS_@Data[text] = false;
  31. return TextDrawDestroy(text);
  32. }
  33. #define TextDrawDestroy TextDrawDestroyEx
  34.  
  35. stock TextDrawSetString2(Text:text, string[])
  36. {
  37. if(!Textdraw@ALS_@Data[text]) return INVALID_TEXT_DRAW;
  38. return TextDrawSetString(text, string);
  39. }
  40.  
  41. stock TextDrawSetStringEx(Text:text, string[])
  42. {
  43. if(!Textdraw@ALS_@Data[text]) return INVALID_TEXT_DRAW;
  44.  
  45. Space@ALS_@Delete(string);
  46. PolishChars@ALS_@Replace(string);
  47. return TextDrawSetString(text, string);
  48. }
  49. #define TextDrawSetString TextDrawSetStringEx
  50.  
  51. stock PlayerText:CreatePlayerTextDrawEx(playerid, Float:x, Float:y, text[])
  52. {
  53. PolishChars@ALS_@Replace(text);
  54. new PlayerText:id = CreatePlayerTextDraw(playerid, x, y, text);
  55. PlayerTextdraw@ALS_@Data[playerid][id] = true;
  56. return id;
  57. }
  58. #define CreatePlayerTextDraw CreatePlayerTextDrawEx
  59.  
  60. stock PlayerTextDrawDestroyEx(playerid, PlayerText:text)
  61. {
  62. if(!PlayerTextdraw@ALS_@Data[playerid][text]) return INVALID_TEXT_DRAW;
  63. PlayerTextdraw@ALS_@Data[playerid][text] = false;
  64. return PlayerTextDrawDestroy(playerid, text);
  65. }
  66. #define PlayerTextDrawDestroy PlayerTextDrawDestroyEx
  67.  
  68. stock PlayerTextDrawSetString2(playerid, PlayerText:text, string[])
  69. {
  70. if(!PlayerTextdraw@ALS_@Data[playerid][text]) return INVALID_TEXT_DRAW;
  71. return PlayerTextDrawSetString(playerid, text, string);
  72. }
  73.  
  74. stock PlayerTextDrawSetStringEx(playerid, PlayerText:text, string[])
  75. {
  76. if(!PlayerTextdraw@ALS_@Data[playerid][text]) return INVALID_TEXT_DRAW;
  77.  
  78. Space@ALS_@Delete(string);
  79. PolishChars@ALS_@Replace(string);
  80. return PlayerTextDrawSetString(playerid, text, string);
  81. }
  82. #define PlayerTextDrawSetString PlayerTextDrawSetStringEx
  83.  
  84.  
  85. stock Space@ALS_@Delete(string[])
  86. {
  87. new len = strlen(string);
  88. if(string[len-1] == ' ')
  89. {
  90. strdel(string, len-1, len);
  91. Space@ALS_@Delete(string);
  92. }
  93. }
  94.  
  95. stock PolishChars@ALS_@Replace(string[])
  96. {
  97. for(new x, c = strlen(string);x<c; x++)
  98. {
  99. switch(string[x])
  100. {
  101. case 'ł':
  102. string[x] = 'l';
  103. case 'ż', 'ź':
  104. string[x] = 'z';
  105. case 'ć':
  106. string[x] = 'c';
  107. case 'ń':
  108. string[x] = 'n';
  109. case 'ę':
  110. string[x] = 'e';
  111. case 'ó':
  112. string[x] = 'o';
  113. case 'ą':
  114. string[x] = 'a';
  115. case 'ś':
  116. string[x] = 's';
  117.  
  118. case 'Ł':
  119. string[x] = 'L';
  120. case 'Ż', 'Ź':
  121. string[x] = 'Z';
  122. case 'Ć':
  123. string[x] = 'C';
  124. case 'Ń':
  125. string[x] = 'N';
  126. case 'Ę':
  127. string[x] = 'E';
  128. case 'Ó':
  129. string[x] = 'O';
  130. case 'Ą':
  131. string[x] = 'A';
  132. case 'Ś':
  133. string[x] = 'S';
  134. }
  135. }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement