Advertisement
IdoGame

Admin Chat Colored + Select color

Sep 21st, 2014
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4. //You Can Find Colors At The Hudmessage Generator or here http://web.njit.edu/~kevin/rgb.txt.html//
  5.  
  6. #define LOG
  7. #pragma tabsize 0
  8. enum _:Cchat
  9. {
  10. WriteString[20],
  11. Color1,
  12. Color2,
  13. Color3
  14.  
  15.  
  16. }
  17. new const Chatsz[][Cchat] =
  18. {
  19. {"@b",0, 0, 255},
  20. {"@r",255,0,0},
  21. {"@g",0, 255, 0}
  22. //Add More Colors Here
  23. }
  24. enum _:AGroups
  25. {
  26. Name[12],
  27. R,
  28. G,
  29. B,
  30. Effect,
  31. Flag
  32. }
  33.  
  34. new const szGroups[ ][ AGroups ] = {
  35. { "Owner", 0, 0, 0, 1, ADMIN_IMMUNITY },
  36. { "Manager", 0, 127, 255, 1, ADMIN_RESERVATION },
  37. { "Admin", 0, 255, 127, 0, ADMIN_LEVEL_C },
  38. { "VIP", 255, 255, 255, 0, ADMIN_CHAT }
  39. }
  40.  
  41. new Float: g_flPositions[ 2 ][ 4 ][ 2 ] = {
  42. {
  43. { 0.07, 0.57 },
  44. { 0.07, 0.60 },
  45. { 0.07, 0.63 },
  46. { 0.07, 0.66 }
  47. },
  48. {
  49. { -1.0, 0.10 },
  50. { -1.0, 0.13 },
  51. { -1.0, 0.16 },
  52. { -1.0, 0.19 }
  53. }
  54. }
  55.  
  56. new g_iHudPosition, Float: g_flLastTsay[ 33 ]
  57.  
  58. #if defined LOG
  59. new szLogFile[ 24 ];
  60. #endif
  61.  
  62. public plugin_init() {
  63. register_plugin( "Admin Chat Colored + Select color", "v2.0", "+ColdWar,select colors added by xflane" );
  64.  
  65. register_clcmd( "say", "ClCmd_SayHook" );
  66.  
  67. #if defined LOG
  68. get_time( "AdminChat-%y%m%d.log", szLogFile, sizeof szLogFile - 1 );
  69. #endif
  70. }
  71.  
  72. public ClCmd_SayHook( client )
  73. {
  74. new szMessage[ 192 ];
  75. read_argv( 1, szMessage, sizeof szMessage - 1 );
  76.  
  77. remove_quotes( szMessage );
  78. trim( szMessage );
  79.  
  80. if( !( get_user_flags( client ) & ADMIN_CHAT ) )
  81. return 0;
  82. else if( !StartWith( szMessage, "@" ) )
  83. return 0;
  84. else if( get_gametime( ) - g_flLastTsay[ client ] < 1.0 )
  85. {
  86. ColorChat( client, "^4[AMXX]^1 You need to wait more ^4%.1f^1 to use ^3admin chat^1.", 0.5 - ( get_gametime( ) - g_flLastTsay[ client ] ) )
  87. return 1;
  88. }
  89. else
  90. {
  91. new Color1s = 0
  92. new Color2s = 0
  93. new Color3s = 0
  94. for( new i; i < sizeof Chatsz; i++)
  95. {
  96. if(StartWith(szMessage,Chatsz[ i ][ WriteString ]))
  97. {
  98.  
  99. Color1s = Chatsz[i][Color1]
  100. Color2s = Chatsz[i][Color2]
  101. Color3s = Chatsz[i][Color3]
  102. replace( szMessage, sizeof szMessage - 1, Chatsz[ i ][ WriteString ] , "" );
  103.  
  104. }
  105.  
  106. }
  107. if(Color1s == 0 && Color2s == 0 && Color3s == 0){
  108. Color1s = random(255)
  109. Color2s = random(255)
  110. Color3s = random(255)
  111. }
  112. new g_iPos = StartWith( szMessage, "@@" );
  113.  
  114. replace( szMessage, sizeof szMessage - 1, g_iPos ? "@@" : "@", "" );
  115.  
  116.  
  117.  
  118. if( !strlen( szMessage ) )
  119. return 1;
  120.  
  121. new szName[ 32 ], groupid;
  122.  
  123. get_user_name( client, szName, sizeof szName- 1 );
  124. groupid = GetGroupID( get_user_flags( client ) );
  125.  
  126. set_hudmessage( Color1s, Color2s, Color3s, g_flPositions[ g_iPos ][ g_iHudPosition ][ 0 ], g_flPositions[ g_iPos ][ g_iHudPosition ][ 1 ], szGroups[ groupid ][ Effect ], 0.0, 12.0, 0.0, 0.0, g_iHudPosition );
  127.  
  128. replace_all( szMessage, sizeof szMessage - 1, "%n", "^n" );
  129. show_hudmessage( 0, "[ %s ] %s : %s", szGroups[ groupid ][ Name ], szName, szMessage );
  130.  
  131. replace_all( szMessage, sizeof szMessage - 1, "^n", " " );
  132.  
  133. ColorChat( 0, "^4[ ^1%s ^4] ^3%s^1 : ^4%s", szGroups[ groupid ][ Name ], szName, szMessage );
  134.  
  135. #if defined LOG
  136. new auth[ 35 ], ip[ 26 ];
  137.  
  138. get_user_authid( client, auth, sizeof auth - 1 );
  139. get_user_ip( client, ip, sizeof ip - 1, 1 );
  140.  
  141. log_to_file( szLogFile, "[%s] %s < %s >< %s > says: %s.", szGroups[ groupid ][ Name ], szName, auth, ip, szMessage );
  142. #endif
  143.  
  144.  
  145. g_iHudPosition ++;
  146.  
  147. g_flLastTsay[ client ] = get_gametime( );
  148.  
  149. if( g_iHudPosition > 3 )
  150. g_iHudPosition = 0;
  151.  
  152. return 1;
  153. }
  154. return 0;
  155. }
  156.  
  157. stock StartWith( Msg[ ], Msg2[ ] )
  158. {
  159. return( equal( Msg, Msg2, strlen( Msg2 ) ) );
  160. }
  161.  
  162. stock GetGroupID( flags )
  163. {
  164. for( new i = 0 ; i < sizeof szGroups ; i ++ )
  165. {
  166. if( flags & szGroups[ i ][ Flag ] )
  167. return i;
  168. }
  169. return -1;
  170. }
  171.  
  172. stock ColorChat( index, message[], any:... )
  173. {
  174. if( index && !is_user_connected( index ) || !index && !get_playersnum( ) )
  175. return 0;
  176.  
  177. static szMessage[ 242 ];
  178.  
  179. vformat( szMessage, charsmax( szMessage ), message, 3 );
  180.  
  181. static st_msgid;
  182. if( !st_msgid )
  183. st_msgid = get_user_msgid( "SayText" );
  184.  
  185. if( index )
  186. {
  187. message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
  188. write_byte( index );
  189. write_string( szMessage );
  190. message_end( );
  191. }
  192. else
  193. {
  194.  
  195. static cc_glb_maxclients;
  196. if( !cc_glb_maxclients )
  197. cc_glb_maxclients = get_maxplayers( );
  198.  
  199. for( index = 1 ; index <= cc_glb_maxclients ; index ++ )
  200. {
  201. if( !is_user_connected( index ) )
  202. continue;
  203.  
  204. message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
  205. write_byte( index );
  206. write_string( szMessage );
  207. message_end( );
  208. }
  209. }
  210. return 1;
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement