Advertisement
GuiButt

notify.inc

Oct 24th, 2023
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. /*
  2. notification.Show(playerid, "Tittle", "Text", "Logo");
  3. */
  4.  
  5. // * Settings * //
  6. #define MAX_NOTIFY (10) // max show notofication
  7. #define MAX_NT_STRING (320)
  8. #define MAX_NT_TITLE (64)
  9. #define SECONDS_NT (5)
  10.  
  11. enum ntInfo { ntIcon[32], ntTitle[MAX_NT_TITLE], ntMessage[MAX_NT_STRING], ntLines }
  12. static notifyInfo[MAX_PLAYERS][MAX_NOTIFY][ntInfo],
  13. PlayerText:notifyPTD[MAX_PLAYERS][MAX_NOTIFY * 6],
  14. notifyIndex[MAX_PLAYERS];
  15.  
  16. #define notify::%0(%1) forward %0(%1); public %0(%1)
  17. #define InternalNotification_show InternalNotification_Show
  18. #define notification. InternalNotification_
  19.  
  20. static const TDTextCaracterWidth[] = {
  21. 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,
  22. 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,
  23. 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,
  24. 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,
  25. 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,
  26. 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,
  27. 11,11,20,9,10,10,10,10,7,7,7,7,10,10,10,10,13,13,13,13,27,12,30
  28. };
  29.  
  30.  
  31. // Get width for char //
  32. stock getSizeMessage(const string:message[], maxWidth=500) {
  33. new size = 0, lines=1, i=-1, lastPoint = 0;
  34.  
  35. while(message[++i]) {
  36. size += TDTextCaracterWidth[message[i]];
  37.  
  38. switch(message[i]) {
  39. case ' ':
  40. lastPoint = i;
  41.  
  42. default:
  43. if(size >= maxWidth)
  44. ++lines,
  45. size -= maxWidth,
  46. size += i - lastPoint;
  47. }
  48. }
  49. return lines;
  50. }
  51.  
  52. //main function for show notification
  53. stock InternalNotification_Show(const playerid, const string:title[], const string:message[], const string:icon[] = "hud:radar_triads")
  54. {
  55. for(new x=-1;++x<notifyIndex[playerid];) {
  56. for(new i=-1;++i<6;) PlayerTextDrawDestroy(playerid, notifyPTD[playerid][(x*6) + i]);
  57. notifyInfo[playerid][notifyIndex[playerid]-x] = notifyInfo[playerid][(notifyIndex[playerid]-x)-1];
  58. }
  59.  
  60. strmid(notifyInfo[playerid][0][ntTitle], title, 0, MAX_NT_TITLE);
  61. strmid(notifyInfo[playerid][0][ntMessage], message, 0, MAX_NT_STRING);
  62. strmid(notifyInfo[playerid][0][ntIcon], icon, 0, 20);
  63. notifyInfo[playerid][0][ntLines] = getSizeMessage(message);
  64.  
  65. ++notifyIndex[playerid];
  66.  
  67. new Float:static_x=0.0;
  68. for(new x=-1;++x<notifyIndex[playerid];) {
  69. createNotifyTD(playerid, x, x * 6, static_x);
  70. static_x+=(notifyInfo[playerid][x][ntLines] * 7.5) + 40.0;
  71. }
  72.  
  73. SetTimerEx(#destroy_notify, SECONDS_NT * 1000, false, #i, playerid);
  74. return 1;
  75. }
  76.  
  77. // when the notification stops //
  78. notify::destroy_notify(playerid) {
  79. if(!notifyIndex[playerid]) return 1;
  80. --notifyIndex[playerid];
  81. for(new i=-1;++i<6;) PlayerTextDrawDestroy(playerid, notifyPTD[playerid][(notifyIndex[playerid]*6) + i]);
  82. return 1;
  83. }
  84.  
  85. // display notification //
  86. stock createNotifyTD(const playerid, index, i, const Float:static_x) {
  87. new lines = notifyInfo[playerid][index][ntLines],Float:x = (lines * 7.5) + static_x;
  88.  
  89. notifyPTD[playerid][i] = CreatePlayerTextDraw(playerid, 518.000000, 298.000000 - x, "ld_bum:blkdot");
  90. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  91. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.600000, 2.000000 + (lines *0.9));
  92. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 153.000000, 39.000000);
  93. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 1);
  94. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  95. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  96. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], 190);
  97. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  98. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  99. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 1);
  100. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  101. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  102. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  103.  
  104. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 27.84, 298.5 - x, "");
  105. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.0, 0.0);
  106. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 109.0, 15.0 + (lines * 7.2));
  107. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  108. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -16777184);
  109. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  110. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  111. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  112. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  113. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 0);
  114. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  115. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  116.  
  117. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 518.000000, 298.000000 - x, "ld_bum:blkdot");
  118. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  119. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.600000, 2.000000);
  120. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 3.500000, 39.000000);
  121. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 1);
  122. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  123. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  124. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], 512819199);
  125. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  126. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  127. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 1);
  128. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  129. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  130. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  131.  
  132. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 528.000000, 311.000000 - x, notifyInfo[playerid][index][ntIcon]);
  133. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 4);
  134. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.600000, 2.000000);
  135. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 11.500000, 13.000000);
  136. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 1);
  137. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  138. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  139. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -1);
  140. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  141. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  142. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 1);
  143. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  144. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  145. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  146.  
  147. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 544.000000, 301.000000 - x, notifyInfo[playerid][index][ntTitle]);
  148. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 1);
  149. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.262499, 1.349998);
  150. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 617.000000, 12.500000);
  151. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  152. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  153. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  154. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -1);
  155. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  156. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  157. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 0);
  158. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  159. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  160. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  161.  
  162. notifyPTD[playerid][++i] = CreatePlayerTextDraw(playerid, 544.000000, 317.000000 - x, notifyInfo[playerid][index][ntMessage]);
  163. PlayerTextDrawFont(playerid, notifyPTD[playerid][i], 1);
  164. PlayerTextDrawLetterSize(playerid, notifyPTD[playerid][i], 0.199999, 1.099997);
  165. PlayerTextDrawTextSize(playerid, notifyPTD[playerid][i], 676.500000, 12.500000);
  166. PlayerTextDrawSetOutline(playerid, notifyPTD[playerid][i], 0);
  167. PlayerTextDrawSetShadow(playerid, notifyPTD[playerid][i], 0);
  168. PlayerTextDrawAlignment(playerid, notifyPTD[playerid][i], 1);
  169. PlayerTextDrawColor(playerid, notifyPTD[playerid][i], -1);
  170. PlayerTextDrawBackgroundColor(playerid, notifyPTD[playerid][i], 255);
  171. PlayerTextDrawBoxColor(playerid, notifyPTD[playerid][i], 50);
  172. PlayerTextDrawUseBox(playerid, notifyPTD[playerid][i], 0);
  173. PlayerTextDrawSetProportional(playerid, notifyPTD[playerid][i], 1);
  174. PlayerTextDrawSetSelectable(playerid, notifyPTD[playerid][i], 0);
  175. PlayerTextDrawShow(playerid, notifyPTD[playerid][i]);
  176. return true;
  177. }
  178.  
  179. public OnPlayerConnect(playerid)
  180. {
  181.  
  182. notifyIndex[playerid] = 0;
  183.  
  184. #if defined NT_OnPlayerConnect
  185. return NT_OnPlayerConnect(playerid);
  186. #else
  187. return 1;
  188. #endif
  189. }
  190. #if defined _ALS_OnPlayerConnect
  191. #undef OnPlayerConnect
  192. #else
  193. #define _ALS_OnPlayerConnect
  194. #endif
  195.  
  196. #define OnPlayerConnect NT_OnPlayerConnect
  197. #if defined NT_OnPlayerConnect
  198. forward NT_OnPlayerConnect(playerid);
  199. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement