seroff

CMD SHOW V5.5 By Seroff

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