Advertisement
GuiButt

notifyg

Oct 27th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1. /*
  2. notificationg.Show("Tittle", "Text", "Text2", "Logo");
  3. */
  4.  
  5. // * Settings * //
  6. #define MAX_NOTIFY (8) // max show notofication
  7. #define MAX_NT_STRING (320)
  8. #define MAX_NT_STRING2 (320)
  9. #define MAX_NT_TITLE (64)
  10. #define SECONDS_NT (5)
  11.  
  12. enum ntInfo {ntIcon[32], ntTitle[MAX_NT_TITLE], ntMessage[MAX_NT_STRING], ntMessage2[MAX_NT_STRING2], ntLines }
  13. static notifyInfo[MAX_NOTIFY][ntInfo],
  14. Text:notifyPTD[MAX_NOTIFY * 7],
  15. notifyIndex;
  16.  
  17. #define notify::%0(%1) forward %0(%1); public %0(%1)
  18. #define InternalNotification_show InternalNotification_Show
  19. #define notificationg. InternalNotification_
  20.  
  21. static const TDTextCaracterWidth[] = {
  22. 0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
  23. 12,12,12,12,12,12,12,13,13,28,28,28,28,8,17,17,30,28,28,12,9,21,28,14,28,28,
  24. 28,28,28,28,28,28,13,13,30,30,30,30,10,25,23,21,24,22,20,24,24,17,20,22,20,
  25. 30,27,27,26,26,24,23,24,31,23,31,24,23,21,28,33,33,14,28,10,11,12,9,11,10,
  26. 10,12,12,7,7,13,5,18,12,10,12,11,10,12,8,13,13,18,17,13,12,30,30,37,35,37,
  27. 25,25,25,25,33,21,24,24,24,24,17,17,17,17,27,27,27,27,31,31,31,31,11,11,11,
  28. 11,11,20,9,10,10,10,10,7,7,7,7,10,10,10,10,13,13,13,13,27,12,30
  29. };
  30.  
  31.  
  32. // Get width for char //
  33. stock getSizeMessage(const message[], maxWidth=500) {
  34. new size = 0, lines=1, i=-1, lastPoint = 0;
  35.  
  36. while(message[++i]) {
  37. size += TDTextCaracterWidth[message[i]];
  38.  
  39. switch(message[i]) {
  40. case ' ':
  41. lastPoint = i;
  42.  
  43. default:
  44. if(size >= maxWidth)
  45. ++lines,
  46. size -= maxWidth,
  47. size += i - lastPoint;
  48. }
  49. }
  50. return lines;
  51. }
  52. stock getSizeMessage2(const message2[], maxWidth=500) {
  53. new size = 0, lines=1, i=-1, lastPoint = 0;
  54.  
  55. while(message2[++i]) {
  56. size += TDTextCaracterWidth[message2[i]];
  57.  
  58. switch(message2[i]) {
  59. case ' ':
  60. lastPoint = i;
  61.  
  62. default:
  63. if(size >= maxWidth)
  64. ++lines,
  65. size -= maxWidth,
  66. size += i - lastPoint;
  67. }
  68. }
  69. return lines;
  70. }
  71.  
  72. //main function for show notification
  73. stock InternalNotification_Show(const title[], const message[], const message2[], const icon[] = "hud:radar_triads")
  74. {
  75. for(new x=-1;++x<notifyIndex;) {
  76. for(new i=-1;++i<7;) TextDrawDestroy(notifyPTD[(x*7) + i]);
  77. notifyInfo[notifyIndex-x] = notifyInfo[(notifyIndex-x)-1];
  78. }
  79.  
  80. strmid(notifyInfo[0][ntTitle], title, 0, MAX_NT_TITLE);
  81. strmid(notifyInfo[0][ntMessage], message, 0, MAX_NT_STRING);
  82. strmid(notifyInfo[0][ntMessage2], message2, 0, MAX_NT_STRING2);
  83. strmid(notifyInfo[0][ntIcon], icon, 0, 20);
  84. notifyInfo[0][ntLines] = getSizeMessage(message);
  85. notifyInfo[0][ntLines] += getSizeMessage(message2);
  86.  
  87. ++notifyIndex;
  88.  
  89. new Float:static_x=0.0;
  90. for(new x=-1;++x<notifyIndex;) {
  91. createNotifyTD(x, x * 7, static_x);
  92. static_x+=(notifyInfo[x][ntLines] * 7.5) + 34.1;
  93. }
  94.  
  95. SetTimer("destroy_notify", SECONDS_NT * 1000, false);
  96. return 1;
  97. }
  98.  
  99. // when the notification stops //
  100. notify::destroy_notify() {
  101. if(!notifyIndex) return 1;
  102. --notifyIndex;
  103. for(new i=-1;++i<7;) TextDrawDestroy(notifyPTD[(notifyIndex*7) + i]);
  104. return 1;
  105. }
  106.  
  107. // display notification //
  108. stock createNotifyTD(index, i, const Float:static_x) {
  109. new lines = notifyInfo[index][ntLines],Float:x = (lines * 7.5) + static_x;
  110.  
  111. notifyPTD[i] = TextDrawCreate(517.247802, 340.083221 - x, "ld_bum:blkdot");
  112. TextDrawFont(notifyPTD[i], 4);
  113. TextDrawLetterSize(notifyPTD[i], 0.000000, 0.000000 + (lines *0.9));
  114. TextDrawTextSize(notifyPTD[i], 135.402648, 37.916664);
  115. TextDrawSetOutline(notifyPTD[i], 1);
  116. TextDrawSetShadow(notifyPTD[i], 0);
  117. TextDrawAlignment(notifyPTD[i], 1);
  118. TextDrawColor(notifyPTD[i], 190);
  119. TextDrawBackgroundColor(notifyPTD[i], 255);
  120. TextDrawBoxColor(notifyPTD[i], 50);
  121. TextDrawUseBox(notifyPTD[i], 1);
  122. TextDrawSetProportional(notifyPTD[i], 1);
  123. TextDrawShowForAll(notifyPTD[i]);
  124.  
  125. notifyPTD[++i] = TextDrawCreate(27.84, 298.5 - x, "");
  126. TextDrawLetterSize(notifyPTD[i], 0.0, 0.0);
  127. TextDrawTextSize(notifyPTD[i], 109.0, 15.0 + (lines * 7.2));
  128. TextDrawAlignment(notifyPTD[i], 1);
  129. TextDrawColor(notifyPTD[i], -16777184);
  130. TextDrawSetShadow(notifyPTD[i], 0);
  131. TextDrawSetOutline(notifyPTD[i], 0);
  132. TextDrawBackgroundColor(notifyPTD[i], 255);
  133. TextDrawFont(notifyPTD[i], 4);
  134. TextDrawSetProportional(notifyPTD[i], 0);
  135. TextDrawSetShadow(notifyPTD[i], 0);
  136. TextDrawShowForAll(notifyPTD[i]);
  137.  
  138. notifyPTD[++i] = TextDrawCreate(517.247497, 337.749969 - x, "ld_bum:blkdot");
  139. TextDrawFont(notifyPTD[i], 4);
  140. TextDrawLetterSize(notifyPTD[i], 0.000000, 0.000000);
  141. TextDrawTextSize(notifyPTD[i], 142.430450, 2.916687);
  142. TextDrawSetOutline(notifyPTD[i], 1);
  143. TextDrawSetShadow(notifyPTD[i], 0);
  144. TextDrawAlignment(notifyPTD[i], 1);
  145. TextDrawColor(notifyPTD[i], 512819199);
  146. TextDrawBackgroundColor(notifyPTD[i], 255);
  147. TextDrawBoxColor(notifyPTD[i], 50);
  148. TextDrawUseBox(notifyPTD[i], 1);
  149. TextDrawSetProportional(notifyPTD[i], 1);
  150. TextDrawShowForAll(notifyPTD[i]);
  151.  
  152. notifyPTD[++i] = TextDrawCreate(519.590270, 343.583374 - x, notifyInfo[index][ntIcon]);
  153. TextDrawFont(notifyPTD[i], 4);
  154. TextDrawLetterSize(notifyPTD[i], 0.000000, 0.000000);
  155. TextDrawTextSize(notifyPTD[i], 8.286972, 9.916668);
  156. TextDrawSetOutline(notifyPTD[i], 1);
  157. TextDrawSetShadow(notifyPTD[i], 0);
  158. TextDrawAlignment(notifyPTD[i], 1);
  159. TextDrawColor(notifyPTD[i], 16711935);
  160. TextDrawBackgroundColor(notifyPTD[i], 255);
  161. TextDrawBoxColor(notifyPTD[i], 50);
  162. TextDrawUseBox(notifyPTD[i], 1);
  163. TextDrawSetProportional(notifyPTD[i], 1);
  164. TextDrawShowForAll(notifyPTD[i]);
  165.  
  166. notifyPTD[++i] = TextDrawCreate(529.429382, 341.833343 - x, notifyInfo[index][ntTitle]);
  167. TextDrawFont(notifyPTD[i], 1);
  168. TextDrawLetterSize(notifyPTD[i], 0.181259, 1.194166);
  169. TextDrawTextSize(notifyPTD[i], 617.000000, 12.500000);
  170. TextDrawSetOutline(notifyPTD[i], 0);
  171. TextDrawSetShadow(notifyPTD[i], 0);
  172. TextDrawAlignment(notifyPTD[i], 1);
  173. TextDrawColor(notifyPTD[i], -1);
  174. TextDrawBackgroundColor(notifyPTD[i], 255);
  175. TextDrawBoxColor(notifyPTD[i], 50);
  176. TextDrawUseBox(notifyPTD[i], 0);
  177. TextDrawSetProportional(notifyPTD[i], 1);
  178. TextDrawShowForAll(notifyPTD[i]);
  179.  
  180. notifyPTD[++i] = TextDrawCreate(520.058715, 353.500091 - x, notifyInfo[index][ntMessage]);
  181. TextDrawFont(notifyPTD[i], 1);
  182. TextDrawLetterSize(notifyPTD[i], 0.200000, 1.200000);
  183. TextDrawTextSize(notifyPTD[i], 676.500000, 12.500000);
  184. TextDrawSetOutline(notifyPTD[i], 0);
  185. TextDrawSetShadow(notifyPTD[i], 0);
  186. TextDrawAlignment(notifyPTD[i], 1);
  187. TextDrawColor(notifyPTD[i], -1);
  188. TextDrawBackgroundColor(notifyPTD[i], 255);
  189. TextDrawBoxColor(notifyPTD[i], 50);
  190. TextDrawUseBox(notifyPTD[i], 0);
  191. TextDrawSetProportional(notifyPTD[i], 1);
  192. TextDrawShowForAll(notifyPTD[i]);
  193.  
  194. notifyPTD[++i] = TextDrawCreate(520.058715, 363.500091 - x, notifyInfo[index][ntMessage2]);
  195. TextDrawFont(notifyPTD[i], 1);
  196. TextDrawLetterSize(notifyPTD[i], 0.200000, 1.200000);
  197. TextDrawTextSize(notifyPTD[i], 676.500000, 12.500000);
  198. TextDrawSetOutline(notifyPTD[i], 0);
  199. TextDrawSetShadow(notifyPTD[i], 0);
  200. TextDrawAlignment(notifyPTD[i], 1);
  201. TextDrawColor(notifyPTD[i], -1);
  202. TextDrawBackgroundColor(notifyPTD[i], 255);
  203. TextDrawBoxColor(notifyPTD[i], 50);
  204. TextDrawUseBox(notifyPTD[i], 0);
  205. TextDrawSetProportional(notifyPTD[i], 1);
  206. TextDrawShowForAll(notifyPTD[i]);
  207.  
  208. return true;
  209. }
  210.  
  211. public OnPlayerConnect(playerid)
  212. {
  213.  
  214. notifyIndex = 0;
  215.  
  216. #if defined NT_OnPlayerConnect
  217. return NT_OnPlayerConnect(playerid);
  218. #else
  219. return 1;
  220. #endif
  221. }
  222. #if defined _ALS_OnPlayerConnect
  223. #undef OnPlayerConnect
  224. #else
  225. #define _ALS_OnPlayerConnect
  226. #endif
  227.  
  228. #define OnPlayerConnect NT_OnPlayerConnect
  229. #if defined NT_OnPlayerConnect
  230. forward NT_OnPlayerConnect(playerid);
  231. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement