HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2.  
  3. #define PLUGIN_NAME "Spy Admin"
  4. #define PLUGIN_VERSION "1.0"
  5. #define PLUGIN_AUTHOR "OciXCrom"
  6.  
  7. new const szPrefix[] = "^4[SPY]"
  8.  
  9. enum Color
  10. {
  11. NORMAL = 1, // clients scr_concolor cvar color
  12. GREEN, // Green Color
  13. TEAM_COLOR, // Red, grey, blue
  14. GREY, // grey
  15. RED, // Red
  16. BLUE, // Blue
  17. }
  18.  
  19. new TeamName[][] =
  20. {
  21. "",
  22. "TERRORIST",
  23. "CT",
  24. "SPECTATOR"
  25. }
  26.  
  27. new bool:spy[33]
  28. new bool:admin[33]
  29. new flags_original[33]
  30. new flag_z
  31.  
  32. new cvar_adminflag, cvar_autohide
  33.  
  34. public plugin_init()
  35. {
  36. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  37.  
  38. cvar_adminflag = register_cvar("spyadmin_adminflag", "d")
  39. cvar_autohide = register_cvar("spyadmin_autohide", "0")
  40.  
  41. register_clcmd("say /spy", "cmd_spy")
  42. register_clcmd("say_team /spy", "cmd_spy")
  43. register_clcmd("say /spyadmin", "cmd_spy")
  44. register_clcmd("say_team /spyadmin", "cmd_spy")
  45. register_clcmd("amx_spyadmin", "cmd_spy")
  46.  
  47. flag_z = read_flags("z")
  48. }
  49.  
  50. public client_putinserver(id)
  51. spyadmin_checkadmin(id)
  52.  
  53. public spyadmin_checkadmin(id)
  54. {
  55. spy[id] = false
  56. flags_original[id] = get_user_flags(id)
  57. admin[id] = user_has_flag(id, cvar_adminflag) ? true : false
  58.  
  59. if(get_pcvar_num(cvar_autohide) == 1)
  60. {
  61. if(admin[id])
  62. spyadmin_removeflags(id)
  63. }
  64. }
  65.  
  66. public client_infochanged(id)
  67. {
  68. new newname[32], oldname[32]
  69.  
  70. get_user_info(id, "name", newname, charsmax(newname))
  71. get_user_name(id, oldname, charsmax(oldname))
  72.  
  73. if(!equali(newname, oldname))
  74. spyadmin_checkadmin(id)
  75. }
  76.  
  77. public cmd_spy(id)
  78. {
  79. if(!admin[id]) ColorChat(id, TEAM_COLOR, "%s ^1Nincs hozzáférésed ehhez a parancshoz.", szPrefix)
  80. else spy[id] ? spyadmin_setflags(id) : spyadmin_removeflags(id)
  81. return PLUGIN_HANDLED
  82. }
  83.  
  84. public spyadmin_removeflags(id)
  85. {
  86. remove_user_flags(id, flags_original[id], 0)
  87. set_user_flags(id, flag_z, 0)
  88. spy[id] = true
  89. ColorChat(id, BLUE, "%s ^1Kém Mód ^3bekapcsolva^1.", szPrefix)
  90. }
  91.  
  92. public spyadmin_setflags(id)
  93. {
  94. remove_user_flags(id, flag_z, 0)
  95. set_user_flags(id, flags_original[id], 0)
  96. spy[id] = false
  97. ColorChat(id, RED, "%s ^1Kém Mód ^3kikapcsolva^1.", szPrefix)
  98. }
  99.  
  100. stock user_has_flag(id, cvar)
  101. {
  102. new flags[32]
  103. get_flags(get_user_flags(id), flags, charsmax(flags))
  104.  
  105. new vip_flag[2]
  106. get_pcvar_string(cvar, vip_flag, charsmax(vip_flag))
  107.  
  108. return (contain(flags, vip_flag) != -1) ? true : false
  109. }
  110.  
  111. /* ColorChat */
  112.  
  113. ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
  114. {
  115. static message[256];
  116.  
  117. switch(type)
  118. {
  119. case NORMAL: // clients scr_concolor cvar color
  120. {
  121. message[0] = 0x01;
  122. }
  123. case GREEN: // Green
  124. {
  125. message[0] = 0x04;
  126. }
  127. default: // White, Red, Blue
  128. {
  129. message[0] = 0x03;
  130. }
  131. }
  132.  
  133. vformat(message[1], 251, msg, 4);
  134.  
  135. // Make sure message is not longer than 192 character. Will crash the server.
  136. message[192] = '^0';
  137.  
  138. static team, ColorChange, index, MSG_Type;
  139.  
  140. if(id)
  141. {
  142. MSG_Type = MSG_ONE;
  143. index = id;
  144. } else {
  145. index = FindPlayer();
  146. MSG_Type = MSG_ALL;
  147. }
  148.  
  149. team = get_user_team(index);
  150. ColorChange = ColorSelection(index, MSG_Type, type);
  151.  
  152. ShowColorMessage(index, MSG_Type, message);
  153.  
  154. if(ColorChange)
  155. {
  156. Team_Info(index, MSG_Type, TeamName[team]);
  157. }
  158. }
  159.  
  160. ShowColorMessage(id, type, message[])
  161. {
  162. message_begin(type, get_user_msgid("SayText"), _, id);
  163. write_byte(id)
  164. write_string(message);
  165. message_end();
  166. }
  167.  
  168. Team_Info(id, type, team[])
  169. {
  170. message_begin(type, get_user_msgid("TeamInfo"), _, id);
  171. write_byte(id);
  172. write_string(team);
  173. message_end();
  174.  
  175. return 1;
  176. }
  177.  
  178. ColorSelection(index, type, Color:Type)
  179. {
  180. switch(Type)
  181. {
  182. case RED:
  183. {
  184. return Team_Info(index, type, TeamName[1]);
  185. }
  186. case BLUE:
  187. {
  188. return Team_Info(index, type, TeamName[2]);
  189. }
  190. case GREY:
  191. {
  192. return Team_Info(index, type, TeamName[0]);
  193. }
  194. }
  195.  
  196. return 0;
  197. }
  198.  
  199. FindPlayer()
  200. {
  201. static i;
  202. i = -1;
  203.  
  204. while(i <= get_maxplayers())
  205. {
  206. if(is_user_connected(++i))
  207. {
  208. return i;
  209. }
  210. }
  211.  
  212. return -1;
  213. }
  214. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  215. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  216. */
  217.