廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 1537 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
能天使
個人頭像
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x72 鮮花 x196
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[1.6][插件] Ban sma 修改.. 請進..大大
複製程式
/*

Ban Old Menu (yeah it could really use a better name)

Collects info from players who have left the server recently and gives the admin a menu from which the admin can auth/ip ban, name+auth+ip are collected and displayed, each ban requires a confirm which will help prevent annoying accidents.

50 most recent, reset on map change, when over 50 the old data gets over written slot by slot, while under 50 oldest first, just a little over 50 and the first few start to get over written.

used menu structure from:
http://www.amxmodx.org/forums/viewtopic.php?p=112762
*     Vote Kick/Ban Menu
*        by WaZZeR
*   Thanks to:
*     v3x       - helped me with the loose indentation error 
*     xeroblood - for the palyer menu template

todo: ban server cmd cvar, for diff ban systems; unban menu; reduce memory waste; see ip permissions; newest always go first

*/
#include <amxmodx>
#include <amxmisc>

#define MENU_SIZE    1024
#define MENU_PLAYERS 7
#define OLD_MAX 50

new g_iMenuPosition[33]; //position in menu list
new g_iMenuPlayers_auth[OLD_MAX+1][30]; //old player list
new g_iMenuPlayers_name[OLD_MAX+1][30]; 
new g_iMenuPlayers_ip[OLD_MAX+1][30]; 
new g_iMenuOption_auth[33][30]; //to confirm
new g_iMenuOption_name[33][30]; 
new g_iMenuOption_ip[33][30]; 
new g_iMenuSettings[33]; //auth/ip
new g_iMenuOldCounter; // up stop
new g_iMenuOldInsertPos; // up down up down

public plugin_init()
{
    register_plugin("Ban Old Menu","0.1","Seather");
    register_menucmd(register_menuid("Ban Old Menu"),1023,"actionBanOldMenu");
    register_clcmd("amx_banmenu","cmdBanOld",ADMIN_KICK,"- displays ban old menu");
    g_iMenuOldCounter = 0;
    g_iMenuOldInsertPos = 0;
}


public cmdBanOld( id, lvl, cid )
{
    if( cmd_access( id, lvl, cid, 0 ) )
    {
        g_iMenuOption_auth[id] = " ";
        g_iMenuSettings[id] = 0;
        g_iMenuPosition[id] = 0;

        showBanOldMenu(id);
    }
    return PLUGIN_HANDLED
}

public showBanOldMenu( id )
{
    if( g_iMenuPosition[id] < 0 ) return

    new i;
    new szMenuBody[MENU_SIZE];
    new iCurrKey = 0;
    new iStart = g_iMenuPosition[id] * MENU_PLAYERS;

    if( iStart >= g_iMenuOldCounter )
    {
        iStart = g_iMenuPosition[id] = 0;
    }
    new iLen = format( szMenuBody, MENU_SIZE-1, "\rBan Old Menu\R%d/%d^n\w^n", g_iMenuPosition[id]+1, (g_iMenuOldCounter / MENU_PLAYERS + ((g_iMenuOldCounter % MENU_PLAYERS) ? 1 : 0 )) );
    new iEnd = iStart + MENU_PLAYERS;
    new iKeys = (1<<9|1<<7);

    if( iEnd > g_iMenuOldCounter )
        iEnd = g_iMenuOldCounter;

    for( i = iStart; i < iEnd; i++ )
    {
            iKeys |= (1<<iCurrKey++);
            iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s, %s, %s^n", iCurrKey, g_iMenuPlayers_auth[i], g_iMenuPlayers_name[i], g_iMenuPlayers_ip[i] );
    }
    //Check if it is auth or ip
    if (!equal(g_iMenuOption_auth[id]," "))
        iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n8. CONFIRM,%s,%s,%s,%s^n" , g_iMenuSettings[id] ? "Ban IP" : "Ban Auth" , g_iMenuOption_auth[id] , g_iMenuOption_name[id] , g_iMenuOption_ip[id] );
    else if ( g_iMenuSettings[id] == 0)
        iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n8. AUTH^n" );
    else
        iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n8. IP^n" );
        
    //Cheack if there are more players left
    if( iEnd != g_iMenuOldCounter )
    {
        format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", g_iMenuPosition[id] ? "Back" : "Exit" );
        iKeys |= (1<<8);
    }
    else
        format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", g_iMenuPosition[id] ? "Back" : "Exit" );

    show_menu( id, iKeys, szMenuBody, -1 );

    return
}

public actionBanOldMenu( id, key )
{
    switch( key )
    {
        case 7: {
            if(!equal(g_iMenuOption_auth[id]," ")) //ban!
            {
                if(g_iMenuSettings[id] == 0)
                    server_cmd("banid 0 %s;writeid",g_iMenuOption_auth[id]);
                else
                    server_cmd("addip 0 %s;writeip",g_iMenuOption_ip[id]);
                
                /////
                new l_name[30];
                get_user_name( id, l_name, 29 );
                new l_authid[30];
                get_user_authid(id,l_authid,29);
                console_print(id, "[AMXX] %s,%s,%s,%s", g_iMenuSettings[id] ? "Ban IP" : "Ban Auth", g_iMenuOption_auth[id],g_iMenuOption_ip[id],g_iMenuOption_name[id]);                
                switch (get_cvar_num("amx_show_activity"))
                {
                    case 2: client_print(0, print_chat, "[香港伺服器] 管理員 %s :: %s,%s,%s", l_name, g_iMenuSettings[id] ? "Ban IP" : "Ban Auth", g_iMenuOption_auth[id],g_iMenuOption_name[id]); //admin name
                    case 1: client_print(0, print_chat, "[香港伺服器] 管理員 :: %s,%s,%s", g_iMenuSettings[id] ? "Ban IP" : "Ban Auth", g_iMenuOption_auth[id],g_iMenuOption_name[id]);
                }
            
                log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s,%s,%s,%s^"", l_name, get_user_userid(id), l_authid, g_iMenuSettings[id] ? "Ban IP" : "Ban Auth", g_iMenuOption_auth[id],g_iMenuOption_ip[id],g_iMenuOption_name[id]);

                /////
                g_iMenuOption_auth[id] = " ";
            }
            else if(g_iMenuSettings[id] == 0)
            {
                g_iMenuSettings[id] = 1;
            }
            else
            {
                g_iMenuSettings[id] = 0;
            }
                 
            showBanOldMenu( id );
        }
        case 8: {
            g_iMenuOption_auth[id] = " ";
            ++g_iMenuPosition[id];
            showBanOldMenu( id ); // More Option
        }
        case 9: {
            g_iMenuOption_auth[id] = " ";
            --g_iMenuPosition[id];
            showBanOldMenu( id ); // Back Option
        }

        default:
        {
            new player = g_iMenuPosition[id] * MENU_PLAYERS + key;

            g_iMenuOption_auth[id] = g_iMenuPlayers_auth[player];
            g_iMenuOption_name[id] = g_iMenuPlayers_name[player];
            g_iMenuOption_ip[id] = g_iMenuPlayers_ip[player];

            showBanOldMenu( id );
        }
    }
    return PLUGIN_HANDLED
}

public client_disconnect(id)
{
   new l_authid[30];
   get_user_authid(id,l_authid,29);
   
   new l_name[30];
   get_user_name( id, l_name, 29 );
   
   new l_ip[30];
   get_user_ip( id, l_ip, 29, 1 );
   
   if( !(get_user_flags(id) & ADMIN_IMMUNITY) && !is_user_bot(id) )
   {
   g_iMenuPlayers_auth[g_iMenuOldInsertPos] = l_authid;
   g_iMenuPlayers_name[g_iMenuOldInsertPos] = l_name;
   g_iMenuPlayers_ip[g_iMenuOldInsertPos] = l_ip;
   
   g_iMenuOldCounter++;
   g_iMenuOldInsertPos++;
   if(g_iMenuOldInsertPos >= OLD_MAX)
     g_iMenuOldInsertPos = 0;
   if(g_iMenuOldCounter > OLD_MAX)
     g_iMenuOldCounter = OLD_MAX;
   }  
}

如何修改至不封IP 只封CS名





獻花 x0 回到頂端 [樓 主] From:香港特別行政區 | Posted:2012-01-25 04:21 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.051227 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言