Advertisement
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_isBanned[33]=0,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",
- "6.0.1F",
- "Seroff"
- };
- #if defined client_disconnected
- #define player_disconnect client_disconnected
- #else
- #define player_disconnect client_disconnect
- #endif
- #define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
- #define set_bit(%1,%2) (%1 |= (1 << (%2 & 31)))
- #define reset_bit(%1,%2) (%1 &= ~(1 << (%2 & 31)))
- new gbIsAdmin,gbIsConnected;
- 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 fileid = fopen(szCFGFile,"at");
- if(fileid){
- fprintf(fileid, "// %s v%s By %s^n",PLUGIN[0],PLUGIN[1],PLUGIN[2]);
- fprintf(fileid, "cmd_logs_enabled ^"1^" // Включить логи?^n");
- fprintf(fileid, "cmd_badshow_use ^"1^" // Проверять на плохие команды^n");
- fprintf(fileid, "cmd_reason ^"^" // Оставтье пустым если не хотите одну причину!^n");
- fprintf(fileid, "cmd_banmess ^"amx_ban [time] [userid] [reason]^" // Наказание игрока^n");
- fprintf(fileid, "cmd_bantime ^"10080^" // Время бана если тип наказания не равен 0^n");
- fprintf(fileid, "cmd_infotype ^"1^" // Куда сообщать админам: 0 - в чат и в консоль, 1 - в консоль, 2 - в чат^n");
- fprintf(fileid, "cmd_adm_immunity ^"0^" // Иммунитет для админов^n");
- fprintf(fileid, "cmd_containi ^"1^" // Наказывать за часть команды^n");
- fprintf(fileid, "^n^necho ^"^"^necho ^"CMD SHOW Config Executed^"^necho ^"^"^n");
- }
- 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)>1){
- 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_putinserver(id)
- {
- if(is_user_bot(id) || is_user_hltv(id))return;
- set_bit(gbIsConnected, id);
- if(is_user_admin(id))
- {
- set_bit(gbIsAdmin, id);
- }
- else
- reset_bit(gbIsAdmin, id);
- }
- public player_disconnect(id){
- reset_bit(gbIsAdmin, id);
- reset_bit(gbIsConnected, id);
- i_isBanned[id]=0;
- }
- public client_command(id){
- if(!get_bit(gbIsConnected, id) || get_pcvar_num(i_Immunity)==1&&get_bit(gbIsAdmin, id)) return 0;
- new name[32],cmd[128], temp[128],s_Buffer[64],sTemp[128],sLine[10],sLogs=get_pcvar_num(i_logs);
- 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)){
- if(sLogs) log_to_file(LOG_FILE,"UserPunish %s >>[%s]", name, temp)
- 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){
- if(sLogs) log_to_file(LOG_FILE,"UserPunish %s >>[%s]", name, temp)
- 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(sLogs){
- new fileid = fopen(szFile_cmd,"at");
- if(fileid){
- fprintf(fileid, "%s^n",cmd);
- }
- fclose(fileid);
- log_to_file(LOG_FILE,"%s >> %s: [%s ]", get_bit(gbIsAdmin, id) ? "Admin" : "Player", name, cmd)
- }
- for(new client=1; client < 33; client++){
- if(get_bit(gbIsAdmin, client)){
- new content_msg[192];
- formatex(content_msg,sizeof(content_msg)-1,"^3%s ^1>> ^4%s^1: [^3%s ^1]", get_bit(gbIsAdmin, id) ? "Admin" : "Player", name, cmd);
- switch(get_pcvar_num(i_info)){
- case 0:{
- console_print(client,content_msg);
- ChatColor(client,content_msg);
- }
- case 1:{
- console_print(client,content_msg);
- }
- case 2:{
- ChatColor(client,content_msg);
- }
- }
- }
- }
- return 0;
- }
- public PunishPlayer(id, const szReason[],any:...){
- if(is_user_alive(id)) user_kill(id,1);
- if(i_isBanned[id])return;
- i_isBanned[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_all(szBanString, charsmax(szBanString), "[userid]", szUserId);
- replace_all(szBanString, charsmax(szBanString), "[steam]", szSteam);
- replace_all(szBanString, charsmax(szBanString), "[ip]", szIp);
- server_print("%s %d",izReason,strlen(izReason));
- if(strlen(izReason)){
- replace_all(szBanString, charsmax(szBanString), "[reason]", izReason);
- }else{
- replace_all(szBanString, charsmax(szBanString), "[reason]", szReason);
- }
- replace_all(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);
- }
- public plugin_end() {
- TrieDestroy(szBadCommands);
- TrieDestroy(szNotShow);
- TrieDestroy(szBadCont);
- }
- stock get_configsdir(name[],len){
- return get_localinfo("amxx_configsdir",name,len);
- }
- /* Сток цветного чата */
- 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 (get_bit(gbIsConnected, players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement