Advertisement
GuiButt

notify2.inc

Oct 24th, 2023
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.63 KB | None | 0 0
  1. /*
  2. notification.Show(playerid, "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_PLAYERS][MAX_NOTIFY][ntInfo],
  14. PlayerText:notifyPTD[MAX_PLAYERS][MAX_NOTIFY * 7],
  15. notifyIndex[MAX_PLAYERS];
  16.  
  17. #define notify::%0(%1) forward %0(%1); public %0(%1)
  18. #define InternalNotification_show InternalNotification_Show
  19. #define notification. 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 string: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 string: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 playerid, const string:title[], const string:message[], const string:message2[], const string:icon[] = "hud:radar_triads")
  74. {
  75. for(new x=-1;++x<notifyIndex[playerid];) {
  76. for(new i=-1;++i<7;) PlayerTextDrawDestroy(playerid, notifyPTD[playerid][(x*7) + i]);
  77. notifyInfo[playerid][notifyIndex[playerid]-x] = notifyInfo[playerid][(notifyIndex[playerid]-x)-1];
  78. }
  79.  
  80. strmid(notifyInfo[playerid][0][ntTitle], title, 0, MAX_NT_TITLE);
  81. strmid(notifyInfo[playerid][0][ntMessage], message, 0, MAX_NT_STRING);
  82. strmid(notifyInfo[playerid][0][ntMessage2], message2, 0, MAX_NT_STRING2);
  83. strmid(notifyInfo[playerid][0][ntIcon], icon, 0, 20);
  84. notifyInfo[playerid][0][ntLines] = getSizeMessage(message);
  85. notifyInfo[playerid][0][ntLines] = getSizeMessage2(message2);
  86.  
  87. ++notifyIndex[playerid];
  88.  
  89. new Float:static_x=0.0;
  90. for(new x=-1;++x<notifyIndex[playerid];) {
  91. createNotifyTD(playerid, x, x * 7, static_x);
  92. static_x+=(notifyInfo[playerid][x][ntLines] * 7.5) + 34.1;
  93. }
  94.  
  95. SetTimerEx(#destroy_notify, SECONDS_NT * 1000, false, #i, playerid);
  96. return 1;
  97. }
  98.  
  99. // when the notification stops //
  100. notify::destroy_notify(playerid) {
  101. if(!notifyIndex[playerid]) return 1;
  102. --notifyIndex[playerid];
  103. for(new i=-1;++i<7;) PlayerTextDrawDestroy(playerid, notifyPTD[playerid][(notifyIndex[playerid]*7) + i]);
  104. return 1;
  105. }
  106.  
  107. // display notification //
  108. stock createNotifyTD(const playerid, index, i, const Float:static_x) {
  109. new lines = notifyInfo[playerid][index][ntLines],Float:x = (lines * 7.5) + static_x;
  110.  
  111. notifyPTD[playerid][i] = CreatePlayerTextDraw(playerid, 517.247802, 340.083221 - x, "ld_bum:blkdot");
  112. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  113. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.000000, 0.000000 + (lines *0.9));
  114. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 135.402648, 37.916664);
  115. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 1);
  116. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  117. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  118. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], 190);
  119. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  120. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  121. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 1);
  122. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  123. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  124. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  125.  
  126. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 27.84, 298.5 - x, "");
  127. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.0, 0.0);
  128. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 109.0, 15.0 + (lines * 7.2));
  129. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  130. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -16777184);
  131. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  132. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  133. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  134. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  135. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 0);
  136. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  137. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  138.  
  139. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 517.247497, 337.749969 - x, "ld_bum:blkdot");
  140. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  141. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.000000, 0.000000);
  142. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 142.430450, 2.916687);
  143. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 1);
  144. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  145. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  146. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], 512819199);
  147. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  148. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  149. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 1);
  150. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  151. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  152. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  153.  
  154. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 519.590270, 343.583374 - x, notifyInfo[playerid][index][ntIcon]);
  155. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  156. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.000000, 0.000000);
  157. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 8.286972, 9.916668);
  158. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 1);
  159. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  160. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  161. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], 16711935);
  162. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  163. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  164. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 1);
  165. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  166. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  167. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  168.  
  169. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 529.429382, 341.833343 - x, notifyInfo[playerid][index][ntTitle]);
  170. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 1);
  171. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.181259, 1.194166);
  172. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 617.000000, 12.500000);
  173. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  174. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  175. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  176. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -1);
  177. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  178. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  179. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 0);
  180. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  181. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  182. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  183.  
  184. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 520.058715, 353.500091 - x, notifyInfo[playerid][index][ntMessage]);
  185. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 1);
  186. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.200000, 1.200000);
  187. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 676.500000, 12.500000);
  188. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  189. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  190. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  191. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -1);
  192. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  193. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  194. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 0);
  195. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  196. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  197. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  198.  
  199. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 520.058715, 363.500091 - x, notifyInfo[playerid][index][ntMessage2]);
  200. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 1);
  201. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.200000, 1.200000);
  202. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 676.500000, 12.500000);
  203. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  204. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  205. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  206. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -1);
  207. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  208. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  209. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 0);
  210. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  211. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  212. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  213. return true;
  214. }
  215.  
  216. public OnPlayerConnect(playerid)
  217. {
  218.  
  219. notifyIndex[playerid] = 0;
  220.  
  221. #if defined NT_OnPlayerConnect
  222. return NT_OnPlayerConnect(playerid);
  223. #else
  224. return 1;
  225. #endif
  226. }
  227. #if defined _ALS_OnPlayerConnect
  228. #undef OnPlayerConnect
  229. #else
  230. #define _ALS_OnPlayerConnect
  231. #endif
  232.  
  233. #define OnPlayerConnect NT_OnPlayerConnect
  234. #if defined NT_OnPlayerConnect
  235. forward NT_OnPlayerConnect(playerid);
  236. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement