Advertisement
seroff

CMD SHOW V6.0 By Seroff

Feb 28th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define LOG_FILE "addons/amxmodx/logs/cmd_show_logs.log"
  4.  
  5. #define szFlag ADMIN_KICK
  6. #define is_user_admin(%0) (get_user_flags(%0) & szFlag)
  7. new i_logs, i_bad, i_banreason, i_banmess,i_bantime,i_con,i_info,i_Immunity,Trie:szNotShow,Trie:szBadCommands,Trie:szBadCont;
  8.  
  9. new PLUGIN[][]={
  10. "CMD SHOW",
  11. "6.0",
  12. "Seroff"
  13. };
  14.  
  15.  
  16. #if defined client_disconnected
  17. #define player_disconnect client_disconnected
  18. #else
  19. #define player_disconnect client_disconnect
  20. #endif
  21.  
  22. #define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
  23. #define set_bit(%1,%2) (%1 |= (1 << (%2 & 31)))
  24. #define reset_bit(%1,%2) (%1 &= ~(1 << (%2 & 31)))
  25.  
  26. new gbIsAdmin,gbIsConnected;
  27.  
  28. static sLen,s_file[][]={"cmd_show.cfg","Not_show.ini","Bad_show.ini","Containi.ini"}
  29.  
  30. public plugin_init(){
  31. register_plugin(PLUGIN[0],PLUGIN[1],PLUGIN[2]);
  32. i_logs=register_cvar("cmd_logs_enabled","1");
  33. i_bad=register_cvar("cmd_badshow_use","1");
  34. i_banreason=register_cvar("cmd_reason","");
  35. i_banmess=register_cvar("cmd_banmess","amx_bam [time] [userid] [reason]");
  36. i_bantime=register_cvar("cmd_bantime","10080");
  37. i_info=register_cvar("cmd_infotype","1");
  38. i_Immunity=register_cvar("cmd_adm_immunity","0");
  39. i_con=register_cvar("cmd_containi","1");
  40. szNotShow=TrieCreate();
  41. szBadCommands=TrieCreate();
  42. szBadCont=TrieCreate();
  43. }
  44.  
  45. public plugin_cfg(){
  46. new sDirs[36],szCFGFile[64],szBadFile[64],szNotShowFile[64],szBadContFile[64];
  47. get_configsdir(sDirs, charsmax(sDirs));
  48. formatex(sDirs, charsmax(sDirs), "%s/Guard",sDirs);
  49. if(!dir_exists(sDirs))mkdir(sDirs);
  50. formatex(szCFGFile,charsmax(szCFGFile),"%s/%s",sDirs,s_file[0])
  51. formatex(szNotShowFile,charsmax(szNotShowFile),"%s/%s",sDirs,s_file[1])
  52. formatex(szBadFile,charsmax(szBadFile),"%s/%s",sDirs,s_file[2])
  53. formatex(szBadContFile,charsmax(szBadContFile),"%s/%s",sDirs,s_file[3])
  54. if(!file_exists(szCFGFile)){
  55. new fileid = fopen(szCFGFile,"at");
  56. if(fileid){
  57. fprintf(fileid, "// %s v%s By %s^n",PLUGIN[0],PLUGIN[1],PLUGIN[2]);
  58. fprintf(fileid, "cmd_logs_enabled ^"1^" // Включить логи?^n");
  59. fprintf(fileid, "cmd_badshow_use ^"1^" // Проверять на плохие команды^n");
  60. fprintf(fileid, "cmd_reason ^"^" // Оставтье пустым если не хотите одну причину!^n");
  61. fprintf(fileid, "cmd_banmess ^"amx_ban [time] [userid] [reason]^" // Наказание игрока^n");
  62. fprintf(fileid, "cmd_bantime ^"10080^" // Время бана если тип наказания не равен 0^n");
  63. fprintf(fileid, "cmd_infotype ^"1^" // Куда сообщать админам: 0 - в чат и в консоль, 1 - в консоль, 2 - в чат^n");
  64. fprintf(fileid, "cmd_adm_immunity ^"0^" // Иммунитет для админов^n");
  65. fprintf(fileid, "cmd_containi ^"1^" // Наказывать за часть команды^n");
  66. fprintf(fileid, "^n^necho ^"^"^necho ^"CMD SHOW Config Executed^"^necho ^"^"^n");
  67. }
  68. fclose(fileid);
  69. }
  70. new sFSTATE[128];
  71. formatex(sFSTATE,charsmax(sFSTATE),"File ^"%s^" not found",s_file[1]);
  72. if(!file_exists(szNotShowFile)) set_fail_state(sFSTATE);
  73. if(file_exists(szBadFile)){
  74. new iFilePointer = fopen( szBadFile, "r");
  75. if(iFilePointer != 0){
  76. new szData[128];
  77. while(fgets(iFilePointer, szData, 127)){
  78. replace(szData, 127, "^n", "");
  79. replace(szData, 127, "^t", "");
  80. remove_quotes(szData);
  81. trim(szData);
  82. strtolower(szData);
  83. TrieSetCell(szBadCommands, szData, 1);
  84. }
  85. fclose(iFilePointer);
  86. }
  87. }
  88. if(file_exists(szNotShowFile)){
  89. new iFilePointer = fopen( szNotShowFile, "r");
  90. if(iFilePointer != 0){
  91. new szData[128];
  92. while(fgets(iFilePointer, szData, 127)){
  93. replace(szData, 127, "^n", "");
  94. replace(szData, 127, "^t", "");
  95. remove_quotes(szData);
  96. trim(szData);
  97. TrieSetCell(szNotShow, szData, 1);
  98. }
  99. fclose(iFilePointer);
  100. }
  101. }
  102. if(file_exists(szBadContFile)){
  103. new sLine[10],iFilePointer = fopen( szBadContFile, "r");
  104. if(iFilePointer != 0){
  105. new szData[128];
  106. while(fgets(iFilePointer, szData, 127)){
  107. replace(szData, 127, "^n", "");
  108. replace(szData, 127, "^t", "");
  109. remove_quotes(szData);
  110. trim(szData);
  111. strtolower(szData);
  112. if(strlen(szData)>0){
  113. sLen++
  114. num_to_str ( sLen-1, sLine, charsmax(sLine) );
  115. TrieSetString(szBadCont,sLine,szData);
  116. }
  117. }
  118. fclose(iFilePointer);
  119. }
  120. }
  121. server_cmd("exec %s",szCFGFile); server_exec();
  122. return 0;
  123. }
  124.  
  125.  
  126. public client_putinserver(id)
  127. {
  128. set_bit(gbIsConnected, id);
  129. if(is_user_admin(id))
  130. {
  131. set_bit(gbIsAdmin, id);
  132. }
  133. else
  134. reset_bit(gbIsAdmin, id);
  135. }
  136.  
  137. public player_disconnect(id){
  138. reset_bit(gbIsAdmin, id);
  139. reset_bit(gbIsConnected, id);
  140. }
  141.  
  142. public client_command(id){
  143. if(!get_bit(gbIsConnected, id) || get_pcvar_num(i_Immunity)==1&&get_bit(gbIsAdmin, id)) return 0;
  144. new name[32],cmd[128], temp[128],s_Buffer[64],sTemp[128],sLine[10];
  145. get_user_name(id, name, sizeof(name)-1);
  146. new szFile_cmd[]="addons/amxmodx/configs/Guard/checking_logcmd.txt" // неизвестные команды которых нету в бд!
  147. read_argv(0, temp, 127);
  148. if(!temp[0] || strlen(temp) == 0)return 0;
  149. if(TrieKeyExists(szNotShow, temp)){
  150. replace_all(temp, charsmax(temp), temp, "");
  151. return 0;
  152. }
  153. remove_quotes(temp); trim(temp);
  154. replace_all(temp, charsmax(temp), "#", "");
  155. replace_all(temp, charsmax(temp), "%", "");
  156. format(sTemp,charsmax(sTemp),"%s",temp);
  157. strtolower(sTemp);
  158. if(get_pcvar_num(i_bad)==1){
  159. if(TrieKeyExists(szBadCommands, sTemp)){
  160. PunishPlayer(id,temp);
  161. return 0;
  162. }
  163. }
  164. if(get_pcvar_num(i_con)==1){
  165. for(new d=0;d<sLen;d++){
  166. num_to_str ( d, sLine, charsmax(sLine) );
  167. TrieGetString(szBadCont,sLine,s_Buffer,charsmax(s_Buffer));
  168. if(containi(sTemp, s_Buffer) != -1){
  169. PunishPlayer(id,temp);
  170. return 0;
  171. }
  172. }
  173. }
  174. for(new i=0; i < read_argc (); i++){
  175. read_argv(i, temp, 127);
  176. format(cmd, 127, "%s %s", cmd, temp);
  177. }
  178. if(get_pcvar_num(i_logs)){
  179. new fileid = fopen(szFile_cmd,"at");
  180. if(fileid){
  181. fprintf(fileid, "%s^n",cmd);
  182. }
  183. fclose(fileid);
  184. log_to_file(LOG_FILE,"%s >> %s: [%s ]", get_bit(gbIsAdmin, id) ? "Admin" : "Player", name, cmd)
  185. }
  186. for(new client=1; client < 33; client++){
  187. if(get_bit(gbIsAdmin, client)){
  188. new content_msg[192];
  189. formatex(content_msg,sizeof(content_msg)-1,"^3%s ^1>> ^4%s^1: [^3%s ^1]", get_bit(gbIsAdmin, id) ? "Admin" : "Player", name, cmd);
  190. switch(get_pcvar_num(i_info)){
  191. case 0:{
  192. user_console(client,content_msg);
  193. ChatColor(client,content_msg);
  194. }
  195. case 1:{
  196. user_console(client,content_msg);
  197. }
  198. case 2:{
  199. ChatColor(client,content_msg);
  200. }
  201. }
  202. }
  203. }
  204. return 0;
  205. }
  206.  
  207. public PunishPlayer(id, const szReason[],any:...){
  208. user_kill(id,1);
  209. new szUserId[10], szSteam[33], szIp[17], szTime[10], szBanString[128],izReason[128],sName[32];
  210. formatex(szUserId, charsmax(szUserId), "#%d", get_user_userid(id));
  211. get_pcvar_string(i_banmess,szBanString,charsmax(szBanString));
  212. get_pcvar_string(i_banreason,izReason,charsmax(izReason));
  213. get_user_authid(id, szSteam, charsmax(szSteam));
  214. get_user_ip(id, szIp, charsmax(szIp), 1);
  215. get_user_name(id,sName,31);
  216. num_to_str(get_pcvar_num(i_bantime), szTime, charsmax(szTime));
  217. replace_all(szBanString, charsmax(szBanString), "[userid]", szUserId);
  218. replace_all(szBanString, charsmax(szBanString), "[steam]", szSteam);
  219. replace_all(szBanString, charsmax(szBanString), "[ip]", szIp);
  220. server_print("%s %d",izReason,strlen(izReason));
  221. if(strlen(izReason)){
  222. replace_all(szBanString, charsmax(szBanString), "[reason]", izReason);
  223. }else{
  224. replace_all(szBanString, charsmax(szBanString), "[reason]", szReason);
  225. }
  226. replace_all(szBanString, charsmax(szBanString), "[time]", szTime);
  227. ChatColor(0, "^4Внимание:^1 Игрок ^3%s^1 наказан по причине ^3[^4%s^3]^1!", sName, strlen(izReason) ? izReason : szReason);
  228. server_cmd("%s", szBanString);
  229. }
  230.  
  231.  
  232. public plugin_end() {
  233. TrieDestroy(szBadCommands);
  234. TrieDestroy(szNotShow);
  235. TrieDestroy(szBadCont);
  236. }
  237.  
  238. stock user_console(id,const msg_content[],any:...){
  239. new msg[192];
  240. vformat(msg, sizeof(msg)-1, msg_content, 3);
  241. format(msg,sizeof(msg)-1,"%s^n",msg);
  242. message_begin(MSG_ONE, 8, {0,0,0}, id);
  243. write_string(msg);
  244. message_end();
  245. }
  246. stock get_configsdir(name[],len){
  247. return get_localinfo("amxx_configsdir",name,len);
  248. }
  249.  
  250. /* Сток цветного чата */
  251. stock ChatColor(const id, const input[], any:...)
  252. {
  253. new count = 1, players[32]
  254. static msg[191]
  255. vformat(msg, 190, input, 3)
  256. replace_all(msg, 190, "!g", "^4") // Зелёный
  257. replace_all(msg, 190, "!y", "^1") // Стандартный
  258. replace_all(msg, 190, "!t", "^3") // Цвет команды
  259. if (id) players[0] = id; else get_players(players, count, "ch")
  260. {
  261. for (new i = 0; i < count; i++)
  262. {
  263. if (get_bit(gbIsConnected, players[i]))
  264. {
  265. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  266. write_byte(players[i]);
  267. write_string(msg);
  268. message_end();
  269. }
  270. }
  271. }
  272. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement