Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #define LOG_FILE "addons/amxmodx/logs/cmd_show_logs.log"
- #define szFlag ADMIN_KICK
- #define is_user_admin(%0) (get_user_flags(%0) & szFlag)
- new i_logs, i_bad, i_banreason, i_banmess,i_bantime,i_con,i_info,i_Immunity,Trie:szNotShow,Trie:szBadCommands,Trie:szBadCont;
- new PLUGIN[][]={
- "CMD SHOW",
- "5.5",
- "Seroff"
- };
- static sLen,s_file[][]={"cmd_show.cfg","Not_show.ini","Bad_show.ini","Containi.ini"}
- public plugin_init(){
- register_plugin(PLUGIN[0],PLUGIN[1],PLUGIN[2]);
- i_logs=register_cvar("cmd_logs_enabled","1");
- i_bad=register_cvar("cmd_badshow_use","1");
- i_banreason=register_cvar("cmd_reason","");
- i_banmess=register_cvar("cmd_banmess","amx_bam [time] [userid] [reason]");
- i_bantime=register_cvar("cmd_bantime","10080");
- i_info=register_cvar("cmd_infotype","1");
- i_Immunity=register_cvar("cmd_adm_immunity","0");
- i_con=register_cvar("cmd_containi","1");
- szNotShow=TrieCreate();
- szBadCommands=TrieCreate();
- szBadCont=TrieCreate();
- }
- public plugin_cfg(){
- new sDirs[36],szCFGFile[64],szBadFile[64],szNotShowFile[64],szBadContFile[64];
- get_configsdir(sDirs, charsmax(sDirs));
- formatex(sDirs, charsmax(sDirs), "%s/Guard",sDirs);
- if(!dir_exists(sDirs))mkdir(sDirs);
- formatex(szCFGFile,charsmax(szCFGFile),"%s/%s",sDirs,s_file[0])
- formatex(szNotShowFile,charsmax(szNotShowFile),"%s/%s",sDirs,s_file[1])
- formatex(szBadFile,charsmax(szBadFile),"%s/%s",sDirs,s_file[2])
- formatex(szBadContFile,charsmax(szBadContFile),"%s/%s",sDirs,s_file[3])
- if(!file_exists(szCFGFile)){
- new szFileLines[1024];
- 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]);
- new fileid = fopen(szCFGFile,"at");
- if(fileid){
- fputs(fileid,szFileLines);
- }
- fclose(fileid);
- }
- new sFSTATE[128];
- formatex(sFSTATE,charsmax(sFSTATE),"File ^"%s^" not found",s_file[1]);
- if(!file_exists(szNotShowFile)) set_fail_state(sFSTATE);
- if(file_exists(szBadFile)){
- new iFilePointer = fopen( szBadFile, "r");
- if(iFilePointer != 0){
- new szData[128];
- while(fgets(iFilePointer, szData, 127)){
- replace(szData, 127, "^n", "");
- replace(szData, 127, "^t", "");
- remove_quotes(szData);
- trim(szData);
- strtolower(szData);
- TrieSetCell(szBadCommands, szData, 1);
- }
- fclose(iFilePointer);
- }
- }
- if(file_exists(szNotShowFile)){
- new iFilePointer = fopen( szNotShowFile, "r");
- if(iFilePointer != 0){
- new szData[128];
- while(fgets(iFilePointer, szData, 127)){
- replace(szData, 127, "^n", "");
- replace(szData, 127, "^t", "");
- remove_quotes(szData);
- trim(szData);
- TrieSetCell(szNotShow, szData, 1);
- }
- fclose(iFilePointer);
- }
- }
- if(file_exists(szBadContFile)){
- new sLine[10],iFilePointer = fopen( szBadContFile, "r");
- if(iFilePointer != 0){
- new szData[128];
- while(fgets(iFilePointer, szData, 127)){
- replace(szData, 127, "^n", "");
- replace(szData, 127, "^t", "");
- remove_quotes(szData);
- trim(szData);
- strtolower(szData);
- if(strlen(szData)>2){
- sLen++
- num_to_str ( sLen-1, sLine, charsmax(sLine) );
- TrieSetString(szBadCont,sLine,szData);
- }
- }
- fclose(iFilePointer);
- }
- }
- server_cmd("exec %s",szCFGFile); server_exec();
- return 0;
- }
- public client_command(id){
- if(!is_user_connected(id) || get_pcvar_num(i_Immunity)==1&&is_user_admin(id)) return 0;
- new name[32],cmd[128], temp[128],s_Buffer[64],sTemp[128],sLine[10];
- get_user_name(id, name, sizeof(name)-1);
- new szFile_cmd[]="addons/amxmodx/configs/Guard/checking_logcmd.txt"
- read_argv(0, temp, 127);
- if(!temp[0] || strlen(temp) == 0)return 0;
- if(TrieKeyExists(szNotShow, temp)){
- replace_all(temp, charsmax(temp), temp, "");
- return 0;
- }
- remove_quotes(temp); trim(temp);
- replace_all(temp, charsmax(temp), "#", "");
- replace_all(temp, charsmax(temp), "%", "");
- format(sTemp,charsmax(sTemp),"%s",temp);
- strtolower(sTemp);
- if(get_pcvar_num(i_bad)==1){
- if(TrieKeyExists(szBadCommands, sTemp)){
- PunishPlayer(id,temp);
- return 0;
- }
- }
- if(get_pcvar_num(i_con)==1){
- for(new d=0;d<sLen;d++){
- num_to_str ( d, sLine, charsmax(sLine) );
- TrieGetString(szBadCont,sLine,s_Buffer,charsmax(s_Buffer));
- if(containi(sTemp, s_Buffer) != -1){
- PunishPlayer(id,temp);
- return 0;
- }
- }
- }
- for(new i=0; i < read_argc (); i++){
- read_argv(i, temp, 127);
- format(cmd, 127, "%s %s", cmd, temp);
- }
- if(get_pcvar_num(i_logs)){
- log_to_file(LOG_FILE,"%s >> %s: [%s ]", is_user_admin(id) ? "Admin" : "Player", name, cmd)
- write_file(szFile_cmd, cmd);
- }
- for(new client=1; client < 33; client++){
- if(is_user_admin(client)){
- new content_msg[192];
- 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);
- switch(get_pcvar_num(i_info)){
- case 0:{
- user_console(client,content_msg);
- ChatColor(client,content_msg);
- }
- case 1:{
- user_console(client,content_msg);
- }
- case 2:{
- ChatColor(client,content_msg);
- }
- }
- }
- }
- return 0;
- }
- stock PunishPlayer(id, const szReason[],any:...){
- user_kill(id,1);
- new szUserId[10], szSteam[33], szIp[17], szTime[10], szBanString[128],izReason[128],sName[32];
- formatex(szUserId, charsmax(szUserId), "#%d", get_user_userid(id));
- get_pcvar_string(i_banmess,szBanString,charsmax(szBanString));
- get_pcvar_string(i_banreason,izReason,charsmax(izReason));
- get_user_authid(id, szSteam, charsmax(szSteam));
- get_user_ip(id, szIp, charsmax(szIp), 1);
- get_user_name(id,sName,31);
- num_to_str(get_pcvar_num(i_bantime), szTime, charsmax(szTime));
- replace_string(szBanString, charsmax(szBanString), "[userid]", szUserId);
- replace_string(szBanString, charsmax(szBanString), "[steam]", szSteam);
- replace_string(szBanString, charsmax(szBanString), "[ip]", szIp);
- server_print("%s %d",izReason,strlen(izReason));
- if(strlen(izReason)){
- replace_string(szBanString, charsmax(szBanString), "[reason]", izReason);
- }else{
- replace_string(szBanString, charsmax(szBanString), "[reason]", szReason);
- }
- replace_string(szBanString, charsmax(szBanString), "[time]", szTime);
- ChatColor(0, "^4Внимание:^1 Игрок ^3%s^1 наказан по причине ^3[^4%s^3]^1!", sName, strlen(izReason) ? izReason : szReason);
- server_cmd("%s", szBanString);
- }
- stock user_console(id,const msg_content[],any:...){
- new msg[192];
- vformat(msg, sizeof(msg)-1, msg_content, 3);
- format(msg,sizeof(msg)-1,"%s^n",msg);
- message_begin(MSG_ONE, 8, {0,0,0}, id);
- write_string(msg);
- message_end();
- }
- stock get_configsdir(name[],len){
- return get_localinfo("amxx_configsdir",name,len);
- }
- public plugin_end() {
- TrieDestroy(szBadCommands);
- TrieDestroy(szNotShow);
- TrieDestroy(szBadCont);
- }
- /* Сток цветного чата */
- stock ChatColor(const id, const input[], any:...)
- {
- new count = 1, players[32]
- static msg[191]
- vformat(msg, 190, input, 3)
- replace_all(msg, 190, "!g", "^4") // Зелёный
- replace_all(msg, 190, "!y", "^1") // Стандартный
- replace_all(msg, 190, "!t", "^3") // Цвет команды
- if (id) players[0] = id; else get_players(players, count, "ch")
- {
- for (new i = 0; i < count; i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment