1
0

seifader.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. Seifader - Screen Fader by Seif
  3. */
  4. /*x---------------------------------Important-------------------------------------x*/
  5. //**INCLUDES**//
  6. #include <a_samp>
  7. //**PRAGMAS**//
  8. //**MISC**//
  9. /*x---------------------------------Defining-------------------------------------x*/
  10. //**COLORS*//
  11. //Some colors I made
  12. /*#define GREEN 0x21DD00FF
  13. #define RED 0xE60000FF
  14. #define ADMIN_RED 0xFB0000FF
  15. #define YELLOW 0xFFFF00FF
  16. #define ORANGE 0xF97804FF
  17. #define LIGHTRED 0xFF8080FF
  18. #define LIGHTBLUE 0x00C2ECFF
  19. #define PURPLE 0xB360FDFF
  20. #define BLUE 0x1229FAFF
  21. #define LIGHTGREEN 0x38FF06FF
  22. #define DARKPINK 0xE100E1FF
  23. #define DARKGREEN 0x008040FF
  24. #define ANNOUNCEMENT 0x6AF7E1FF
  25. #define GREY 0xCECECEFF
  26. #define PINK 0xD52DFFFF
  27. #define DARKGREY 0x626262FF
  28. #define AQUAGREEN 0x03D687FF
  29. #define WHITE 0xFFFFFFFF*/
  30. //**MISC**//
  31. #define MAX_FADES 100
  32. //**VARIABLES**//
  33. new colorfade[MAX_FADES];
  34. new Text:screenfade[MAX_FADES];
  35. new FadeAvailability[MAX_FADES];
  36. new Text:PlayerColorFade[MAX_PLAYERS][MAX_FADES];
  37. // **FORWARDS** //
  38. forward ScreenFade(playerid, color, speed, maxalpha, fadeid);
  39. forward ScreenFadeColor(playerid, color, speed, maxalpha, fadeid);
  40. forward OnPlayerScreenFade(playerid, color, speed);
  41. forward OnPlayerScreenColorFade(playerid, color, speed);
  42. // **NATIVES** //
  43. /*
  44. native Seifader_OnInit();
  45. native RemovePlayerColorFade(playerid);
  46. native FadePlayerScreen(playerid, color, speed);
  47. native FadePlayerScreenToColor(playerid, color, speed);
  48. native GetAlpha(color); // extra function
  49. */
  50. /*x---------------------------------CallBacks-------------------------------------x*/
  51. Seifader_OnExit()
  52. {
  53. for(new all = 0; all < MAX_PLAYERS; all++) TextDrawDestroy(screenfade[all]);
  54. }
  55. stock FadePlayerScreen(playerid, color, speed)
  56. {
  57. new fadeid = FindFadeID();
  58. new maxalpha = GetAlpha(color);
  59. screenfade[fadeid] = TextDrawCreate(0.0, 0.0, "_");
  60. TextDrawFont(screenfade[fadeid], 1);
  61. TextDrawLetterSize(screenfade[fadeid], 0.0, 50.0);
  62. TextDrawUseBox(screenfade[fadeid], true);
  63. TextDrawColor(screenfade[fadeid], 0);
  64. colorfade[fadeid] = color;
  65. TextDrawBoxColor(screenfade[fadeid], color);
  66. TextDrawShowForPlayer(playerid, screenfade[fadeid]);
  67. FadeAvailability[fadeid] = 1;
  68. SetTimerEx("ScreenFade", 100, 0, "ddddd", playerid, color, speed, maxalpha, fadeid);
  69. }
  70. stock FadePlayerScreenToColor(playerid, color, speed)
  71. {
  72. new fadeid = FindFadeID();
  73. new maxalpha = GetAlpha(color);
  74. PlayerColorFade[playerid][fadeid] = TextDrawCreate(0.0, 0.0, "_");
  75. TextDrawFont(PlayerColorFade[playerid][fadeid], 1);
  76. TextDrawLetterSize(PlayerColorFade[playerid][fadeid], 0.0, 50.0);
  77. TextDrawUseBox(PlayerColorFade[playerid][fadeid], true);
  78. TextDrawColor(PlayerColorFade[playerid][fadeid], 0);
  79. color -= maxalpha;
  80. colorfade[fadeid] = color;
  81. TextDrawBoxColor(PlayerColorFade[playerid][fadeid], color);
  82. TextDrawShowForPlayer(playerid, PlayerColorFade[playerid][fadeid]);
  83. FadeAvailability[fadeid] = 1;
  84. SetTimerEx("ScreenFadeColor", 100, 0, "ddddd", playerid, color, speed, maxalpha, fadeid);
  85. }
  86. public ScreenFade(playerid, color, speed, maxalpha, fadeid)
  87. {
  88. if (color <= (colorfade[fadeid] - maxalpha))
  89. {
  90. TextDrawDestroy(screenfade[fadeid]);
  91. OnPlayerScreenFade(playerid, color, speed);
  92. FadeAvailability[fadeid] = 0;
  93. }
  94. else
  95. {
  96. color -= speed;
  97. if (color <= (colorfade[fadeid] - maxalpha)) color = (colorfade[fadeid] - maxalpha);
  98. TextDrawBoxColor(screenfade[fadeid], color);
  99. TextDrawShowForPlayer(playerid, screenfade[fadeid]);
  100. SetTimerEx("ScreenFade", 100, 0, "ddddd", playerid, color, speed, maxalpha, fadeid);
  101. }
  102. }
  103. public ScreenFadeColor(playerid, color, speed, maxalpha, fadeid)
  104. {
  105. if (color >= (colorfade[fadeid] + maxalpha))
  106. {
  107. FADE_FINISH:
  108. OnPlayerScreenColorFade(playerid, color, speed);
  109. FadeAvailability[fadeid] = 0;
  110. }
  111. else
  112. {
  113. color += speed;
  114. if (color >= (colorfade[fadeid] + maxalpha)) goto FADE_FINISH;
  115. TextDrawBoxColor(PlayerColorFade[playerid][fadeid], color);
  116. TextDrawShowForPlayer(playerid, PlayerColorFade[playerid][fadeid]);
  117. SetTimerEx("ScreenFadeColor", 100, 0, "ddddd", playerid, color, speed, maxalpha, fadeid);
  118. }
  119. }
  120. forward RemovePlayerColorFade(playerid);
  121. public RemovePlayerColorFade(playerid)
  122. {
  123. for(new i; i < MAX_FADES; i++)
  124. {
  125. TextDrawDestroy(PlayerColorFade[playerid][i]);
  126. }
  127. }
  128. stock FindFadeID()
  129. {
  130. for(new f = 0; f < MAX_FADES; f++)
  131. {
  132. if (FadeAvailability[f] == 0)
  133. {
  134. printf("found fade id: %d", f);
  135. return f;
  136. }
  137. }
  138. return -1;
  139. }
  140. stock GetAlpha(color)
  141. {
  142. return color&0xFF;
  143. }
  144. /*public OnPlayerScreenFade(playerid, color, speed)
  145. {
  146. return 1;
  147. }
  148. public OnPlayerScreenColorFade(playerid, color, speed)
  149. {
  150. return 1;
  151. }*/