Advertisement
mrdrifter

Msg (new version)

Jun 14th, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1.  
  2. /* SA-MP Chat lights colors and flexible formatting
  3. *
  4. * (c) Copyright 2014 by mrdrifter
  5. *
  6. * (1.2)
  7. *
  8. */
  9.  
  10.  
  11. #if defined _msg_included
  12. #endinput
  13. #endif
  14. #define _msg_included
  15.  
  16. #define MSG_MAX_BUFFERSTR 1024 //splitf 2048?
  17.  
  18. stock msg_Messger[MSG_MAX_BUFFERSTR];
  19. stock msg_SendClientMessageEx(playerid, color, text[])
  20. {
  21. //printf("elo %s", text);
  22. if(strlen(text) > 144)
  23. {
  24. new msg_string3[145];
  25.  
  26. strmid(msg_string3, text, 0, 140);
  27. strins(msg_string3, "...", 0);
  28.  
  29. strdel(text, 0, 140);
  30. SendClientMessage(playerid, color, msg_string3);
  31.  
  32. return SendClientMessage(playerid, color, text);
  33. }
  34. else
  35. return SendClientMessage(playerid, color, text);
  36. }
  37. /*
  38. stock msg_SendClientMessage(playerid, colour, const fmat[], va_args<>)
  39. {
  40. return msg_SendClientMessageEx(playerid, colour, va_returnex(colour, fmat, va_start<3>));
  41. }
  42. */
  43.  
  44.  
  45.  
  46. #if defined _ALS_SendClientMessage
  47. #undef SendClientMessage
  48. #else
  49. #define _ALS_SendClientMessage
  50. #endif
  51. #define SendClientMessage(%0,%1,%2) (format(msg_Messger,sizeof(msg_Messger),%2),msg_return(%1,msg_Messger),msg_SendClientMessageEx(%0,%1,msg_Messger))
  52.  
  53.  
  54. stock msg_SendClientMessageToAllEx(color, text[])
  55. {
  56.  
  57. if(strlen(text) > 144)
  58. {
  59. new msg_string3[145];
  60.  
  61. strmid(msg_string3, text, 0, 140);
  62. strins(msg_string3, "...", 140);
  63.  
  64. strdel(text, 0, 140);
  65.  
  66. SendClientMessageToAll(color, msg_string3);
  67.  
  68. return SendClientMessageToAll(color, text);
  69. }
  70. else
  71. return SendClientMessageToAll(color, text);
  72. }
  73. /*
  74. stock msg_SendClientMessageToAll(colour, const fmat[], va_args<>)
  75. {
  76. return msg_SendClientMessageToAllEx(colour, va_returnex(colour, fmat, va_start<2>));
  77. }*/
  78.  
  79. #if defined _ALS_SendClientMessageToAll
  80. #undef SendClientMessageToAll
  81. #else
  82. #define _ALS_SendClientMessageToAll
  83. #endif
  84. #define SendClientMessageToAll(%1,%2) (format(msg_Messger,sizeof(msg_Messger),%2),msg_return(%1,msg_Messger),msg_SendClientMessageToAllEx(%1,msg_Messger))
  85.  
  86.  
  87. #define splitf(%0) (format(msg_Messger,sizeof(msg_Messger),%0),msg_return(0xA9C4E400,msg_Messger),msg_Messger)
  88. #define m_query(%0) (format(msg_Messger,sizeof(msg_Messger),%0),mysql_query(msg_Messger))
  89. #define va_returnex(%0,%1) (format(msg_Messger,sizeof(msg_Messger),%1),msg_return(%0,msg_Messger),msg_Messger)
  90.  
  91.  
  92. stock msg_return(color,fmat[], size = sizeof(fmat))
  93. {
  94. static
  95. out[MSG_MAX_BUFFERSTR],
  96. cdata[1],
  97. colors[2][9];
  98.  
  99.  
  100. format(out,sizeof(out),fmat);
  101. cdata[0] = color;
  102.  
  103. cdata{0} = floatround(float(cdata{0}) - (float(cdata{0}) * 0.3));
  104. cdata{1} = floatround(float(cdata{1}) - (float(cdata{1}) * 0.3));
  105. cdata{2} = floatround(float(cdata{2}) - (float(cdata{2}) * 0.3));
  106.  
  107. format(colors[0], 9, "{%06x}", color >>> 8);
  108. format(colors[1], 9, "{%06x}", (cdata[0]) >>> 8);
  109.  
  110. cdata[0] = strfind(out, "{b}", true);
  111. while (cdata[0] != -1)
  112. {
  113. strdel(out, cdata[0], cdata[0] + 3);
  114. strins(out, colors[1], cdata[0], size);
  115.  
  116. cdata[0] = strfind(out, "{b}", true);
  117. }
  118.  
  119. cdata[0] = strfind(out, "{/b}", true);
  120. while (cdata[0] != -1)
  121. {
  122. strdel(out, cdata[0], cdata[0] + 4);
  123. strins(out, colors[0], cdata[0], size);
  124.  
  125. cdata[0] = strfind(out, "{/b}", true);
  126. }
  127. format(fmat,size,out);
  128. return out;
  129. }
  130.  
  131.  
  132. stock msg_granient(color, fmat[], bitid = 1)
  133. {
  134. static
  135. out[MSG_MAX_BUFFERSTR],
  136. colors[9];
  137.  
  138. format(out,sizeof(out),"%s",fmat);
  139. new
  140. cdata[1],
  141. pos,
  142. bool:plusplus = true;
  143.  
  144. cdata[0] = color;
  145.  
  146. // cdata{bitid} = 0;
  147.  
  148.  
  149. pos = strfind(out, "|", true);
  150. while (pos != -1)
  151. {
  152. format(colors, 9, "{%06x}", (cdata[0]) >>> 8);
  153.  
  154. strdel(out, pos, pos + 1);
  155. strins(out, " ", pos);
  156.  
  157. strins(out, colors, pos);
  158.  
  159. if((cdata{bitid})+30 > 255 && plusplus)
  160. plusplus = false;
  161. else if((cdata{bitid})-30 < 30 && !plusplus)
  162. plusplus = true;
  163.  
  164. if(plusplus)
  165. cdata{bitid} += 30;
  166. else
  167. cdata{bitid} -= 30;
  168.  
  169. pos = strfind(out, "|", true, pos);
  170. }
  171.  
  172.  
  173. return out;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement