Проблема с SuperAdmin 4.1.

Сообщения
4
Реакции
0
Я использую этот плагин, но каждый раз, когда я пытаюсь выбрать время бана или сумму пощечины, ключ не работает, и в консоли отображается «Client with that name or userid not found».
Кто-нибудь знает, как решить эту проблему с меню?
Извините за язык, я из Чили.






Код:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Super Admin"
#define VERSION "4.1"
#define AUTHOR "[R]ak"

#define ShowSuperAdmin (get_pcvar_num(Pointer) == 2)

const MENU_OPTION = -4
const TASKMENU = 2708

enum _:Menu_Name_Data {
    AMXSUPERMENU,
    SADMIN,
    KICK,
    BAN,
    BANIP,
    SLAY,
    SLAP
}

enum _:Menu_Data {
    COMMANDMENU,
    COMMAND,
    MENU_NAME,
    MENU_OPTION_PREFIX,
    DATA1,
    DATA2,
    DATA3,
    DATA4
}

new const Menu_Name[Menu_Name_Data][Menu_Data][] = {
    { "amxsupermenu", "", "Amx Super Menu", "", "", "", "", "" },
    { "amx_addsuperadmin_menu", "amx_addsuperadmin", "Amx Add Super Admin Menu", "", "", "", "", "" },
    { "amx_super_kickmenu", "amx_super_kick", "Amx Super Kick Menu", "", "", "", "", "" },
    { "amx_super_banmenu", "amx_super_ban", "Amx Super Ban Menu", "Ban", "Permanente", "5", "15", "60" },
    { "amx_super_banipmenu", "amx_super_banip", "Amx Super Banip Menu", "Banip", "Permanente", "5", "15", "60" },
    { "amx_super_slaymenu", "amx_super_slay", "Amx Super Slay Menu", "", "", "", "", "" },
    { "amx_super_slapmenu", "amx_super_slap", "Amx Super Slap Menu", "Slap", "0", "1", "5", "99" }
}

new Pointer, Trie:SuperAdmins, g_RegisterID[Menu_Name_Data], g_MenuMain, g_MenuCallBack

public plugin_init() {
    
    register_dictionary("common.txt")
    
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_concmd(Menu_Name[KICK][COMMAND], "Super_Kick", _, "<target|#userid> <reason>")
    register_concmd(Menu_Name[BAN][COMMAND], "Super_Ban", _, "<target|#userid> <time> <reason>")
    register_concmd(Menu_Name[BANIP][COMMAND], "Super_Banip", _, "<target|#userid> <time> <reason>")
    register_concmd(Menu_Name[SLAY][COMMAND], "Super_Slay", _, "<target|#userid>")
    register_concmd(Menu_Name[SLAP][COMMAND], "Super_Slap", _, "<target|#userid> <damage>")
    register_concmd(Menu_Name[SADMIN][COMMAND], "Super_AddAdmin", _, "<target|#userid|steamid>")
    
    for(new i; i < sizeof Menu_Name; i++)
        g_RegisterID[i] = register_clcmd(Menu_Name[i][COMMANDMENU], "cmdSuperMenu")
    
    Pointer = get_cvar_pointer("amx_show_activity")
    
    g_MenuCallBack = menu_makecallback("CheckAlive")
}

public plugin_cfg() {
    SuperAdmins = TrieCreate()
    new ConfigDir[64]
    get_configsdir(ConfigDir, charsmax(ConfigDir))
    
    format(ConfigDir, charsmax(ConfigDir), "%s/SuperAdmin.ini", ConfigDir)
    
    if(!file_exists(ConfigDir))
        create_file(ConfigDir)
    
    new Data[37], File = fopen(ConfigDir, "rt")
        
    while (!feof(File)) {
        fgets(File, Data, charsmax(Data))
            
        trim(Data)
            
        if (Data[0] == ';' || !Data[0])
            continue;
            
        remove_quotes(Data)
        TrieSetCell(SuperAdmins, Data, true) 
    }
        
    fclose(File)
    
    create_menu_main()
}

public cmdSuperMenu(id, level, cid) {
    
    if(cid == g_RegisterID[AMXSUPERMENU])
        show_menu_main(id)
    else if(cid == g_RegisterID[KICK])
        show_menu_custom(id, KICK)
    else if(cid == g_RegisterID[BAN])
        show_menu_custom(id, BAN)
    else if(cid == g_RegisterID[BANIP])
        show_menu_custom(id, BANIP)
    else if(cid == g_RegisterID[SLAY])
        show_menu_custom(id, SLAY)
    else if(cid == g_RegisterID[SLAP])
        show_menu_custom(id, SLAP)
    else
        show_menu_custom(id, SADMIN)
    
    return PLUGIN_HANDLED
    
}

show_menu_main(id)
    menu_display(id, g_MenuMain)
    
show_menu_custom(id, Type, MenuKey = 0, page = 0) {
    
    new Item[4], Name[32], Player, Player_Num, Players[32], Menu_Item_Option[32], AddOption, Menu = menu_create(Menu_Name[Type][MENU_NAME], "menu_custom_handler")
    
    AddOption = (Type != KICK && Type != SLAY && Type != SADMIN)
    
    Item[1] = Type
    Item[2] = MenuKey
    Item[3] = 0
    
    if(AddOption)
        formatex(Menu_Item_Option, charsmax(Menu_Item_Option), "%s: %s", Menu_Name[Type][MENU_OPTION_PREFIX], Menu_Name[Type][MenuKey+DATA1])
    
    get_players(Players, Player_Num)
    
    for(new i; i < Player_Num; i++) {
        
        if(i && !(i % 6) && AddOption) {
            Item[0] = MENU_OPTION
            menu_additem(Menu, Menu_Item_Option, Item)
        }
        
        Player = Item[0] = Players[i]
        
        get_user_name(Player, Name, charsmax(Name))
                
        menu_additem(Menu, Name, Item, .callback = (Type >= SLAY) ? g_MenuCallBack : -1)
    }
    
    if(AddOption) {
        
        Item[0] = MENU_OPTION
    
        menu_additem(Menu, Menu_Item_Option, Item)
        
    }
    
    menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL)
    menu_display(id, Menu, page)
    
}

public menu_main_handler(id, menu, item) {
    
    if(item == MENU_EXIT)
        return
    
    show_menu_custom(id, item+1)
    
}

public menu_custom_handler(id, menu, item) {
    
    if(item == MENU_EXIT) {
        menu_destroy(menu)
        return
    }
    
    new Data[5], Access, Callback
    
    menu_item_getinfo(menu, item, Access, Data, charsmax(Data), _, _, Callback)
    
    if(Data[0] == MENU_OPTION) {   
        if((++Data[2] + DATA1) > DATA4)
            Data[2] = 0
    }
    else {
        
        new type = Data[1], victim = Data[0]
    
        client_cmd(id, "%s #%d %s", Menu_Name[type][COMMAND], get_user_userid(victim), Menu_Name[type][Data[2]+DATA1])
    
    }
    
    new page, newmenu, oldmenu
    player_menu_info(id, oldmenu, newmenu, page)
    
    Data[0] = id
    Data[3] = page
    
    set_task(0.1, "TaskShowMenu", TASKMENU, Data, sizeof Data)
    
    menu_destroy(menu)
    
}

public TaskShowMenu(Args[])
    show_menu_custom(Args[0], Args[1], Args[2], Args[3])

public CheckAlive(id, menu, item) {
    
    new Data[4], Access, Callback, Name[32]
    
    menu_item_getinfo(menu, item, Access, Data, charsmax(Data), Name, charsmax(Name), Callback)
    
    return (is_user_alive(Data[0])) ? ITEM_ENABLED : ITEM_DISABLED
    
}

public Super_Kick(id, level, cid) {
    if(!Is_SuperAdmin(id, cid, 2))
        return PLUGIN_HANDLED;
    
    new Name[32], Reason[32]
    
    read_argv(1, Name, charsmax(Name))
    read_argv(2, Reason, charsmax(Reason))
    remove_quotes(Reason)
    
    new player = get_target(id, Name)
    
    if(!player)
        return PLUGIN_HANDLED
    
    if(Reason[0])
        server_cmd("kick #%d ^"%s^"", get_user_userid(player), Reason)
    else
        server_cmd("kick #%d", get_user_userid(player))
        
    new Super_Admin[32], Victim[32]
    
    get_user_name(id, Super_Admin, charsmax(Super_Admin))
    get_user_name(player, Victim, charsmax(Victim))
    
    if(get_pcvar_num(Pointer))
        client_print(0, print_chat, "[AMXX] Admin %s kick %s", ShowSuperAdmin ? Super_Admin : "", Victim)
    
    return PLUGIN_HANDLED
}

public Super_Ban(id, level, cid) {
    if(!Is_SuperAdmin(id, cid, 3))
        return PLUGIN_HANDLED;
        
    new Name[32], Time[7] ,Reason[32]
    
    read_argv(1, Name, charsmax(Name))
    read_argv(2, Time, charsmax(Time))
    read_argv(3, Reason, charsmax(Reason))
    remove_quotes(Reason)
    
    new player = get_target(id, Name)
    
    if (!player)
        return PLUGIN_HANDLED
    
    new Authid[35], Time_Ban, Show_Time[20]
    
    get_user_authid(player, Authid, charsmax(Authid))
    Time_Ban = str_to_num(Time)
    
    if(!Time_Ban)
        formatex(Show_Time, charsmax(Show_Time), "Permanently")
    else
        formatex(Show_Time, charsmax(Show_Time), "%d Min", Time_Ban)
    
    if (Reason[0])
        server_cmd("kick #%d ^"%s | Banned | Time:%s)^";wait;banid ^"%s^" %s;wait;writeid", get_user_userid(player), Reason, Show_Time, Time_Ban, Authid)
    else
        server_cmd("kick #%d ^"Banned | Time:%s)^";wait;banid ^"%s^" %s;;wait;writeid", get_user_userid(player), Show_Time, Time_Ban, Authid)

    new Super_Admin[32], Victim[32]
    
    get_user_name(id, Super_Admin, charsmax(Super_Admin))
    get_user_name(player, Victim, charsmax(Victim))
    
    if(get_pcvar_num(Pointer))
        client_print(0, print_chat, "[AMXX] Admin %s Ban %s for %s", ShowSuperAdmin ? Super_Admin : "", Victim, Show_Time)
    
    return PLUGIN_HANDLED
}

public Super_Banip(id, level, cid) {
    if(!Is_SuperAdmin(id, cid, 3))
        return PLUGIN_HANDLED;
        
    new Name[32], Time[7] ,Reason[32]
    
    read_argv(1, Name, charsmax(Name))
    read_argv(2, Time, charsmax(Time))
    read_argv(3, Reason, charsmax(Reason))
    remove_quotes(Reason)
    
    new player = get_target(id, Name)
    
    if (!player)
        return PLUGIN_HANDLED
    
    new Ip[20], Time_Ban, Show_Time[20]
    
    get_user_ip(player, Ip, charsmax(Ip), 1)
    Time_Ban = str_to_num(Time)
    
    if(!Time_Ban)
        formatex(Show_Time, charsmax(Show_Time), "Permanently")
    else
        formatex(Show_Time, charsmax(Show_Time), "%d Min", Time_Ban)
    
    if (Reason[0])
        server_cmd("kick #%d ^"%s | Banned | Time:%s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", get_user_userid(player), Reason, Show_Time, Time_Ban, Ip)
    else
        server_cmd("kick #%d ^"Banned | Time:%s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", get_user_userid(player), Show_Time, Time_Ban, Ip)

    new Super_Admin[32], Victim[32]
    
    get_user_name(id, Super_Admin, charsmax(Super_Admin))
    get_user_name(player, Victim, charsmax(Victim))
    
    if(get_pcvar_num(Pointer))
        client_print(0, print_chat, "[AMXX] Admin %s Ban %s for %s", ShowSuperAdmin ? Super_Admin : "", Victim, Show_Time)
    
    return PLUGIN_HANDLED
}

public Super_Slay(id, level, cid) {
    if(!Is_SuperAdmin(id, cid, 2))
        return PLUGIN_HANDLED;
    
    new Name[32]
    
    read_argv(1, Name, charsmax(Name))
    
    new player = get_target(id, Name, true)
    
    if (!player)
        return PLUGIN_HANDLED
    
    user_kill(player)
    
    new Super_Admin[32], Victim[32]
    
    get_user_name(id, Super_Admin, charsmax(Super_Admin))
    get_user_name(player, Victim, charsmax(Victim))
    
    if(get_pcvar_num(Pointer))
        client_print(0, print_chat, "[AMXX] Admin %s Slay %s", ShowSuperAdmin ? Super_Admin : "", Victim)
        
    return PLUGIN_HANDLED
}

public Super_Slap(id, level, cid) {
    if(!Is_SuperAdmin(id, cid, 2))
        return PLUGIN_HANDLED;
        
    new Name[32], Power[32]
    
    read_argv(1, Name, charsmax(Name))
    read_argv(2, Power, charsmax(Power))
    
    new player = get_target(id, Name, true)
    
    if (!player)
        return PLUGIN_HANDLED

    user_slap(player, str_to_num(Power))
    
    new Super_Admin[32], Victim[32]
    
    get_user_name(id, Super_Admin, charsmax(Super_Admin))
    get_user_name(player, Victim, charsmax(Victim))
    
    if(get_pcvar_num(Pointer))
        client_print(0, print_chat, "[AMXX] Admin %s Slap %s with %d damage", ShowSuperAdmin ? Super_Admin : "", Victim, str_to_num(Power))
        
    return PLUGIN_HANDLED
}

public Super_AddAdmin(id, level, cid) {
    
    if(!Is_SuperAdmin(id, cid, 2))
        return PLUGIN_HANDLED;
    
    new Steam[37]
    
    read_argv(1, Steam, charsmax(Steam))
    remove_quotes(Steam)
    
    if(Steam[0] != 'S' || Steam[4] != 'M' || Steam[7] != ':' || Steam[9] != ':') {
        
        new player = get_target(id, Steam)
    
        if(!player)
            return PLUGIN_HANDLED
        
        get_user_authid(player, Steam, charsmax(Steam))
    }
    
    if(TrieKeyExists(SuperAdmins, Steam)) {
        console_print(id, "The steamid %s is already in SuperAdmin File", Steam)
        return PLUGIN_HANDLED
    }
    
    new ConfigDir[64]
    
    get_configsdir(ConfigDir, charsmax(ConfigDir))
    
    format(ConfigDir, charsmax(ConfigDir), "%s/SuperAdmin.ini", ConfigDir)
    
    new File = fopen(ConfigDir, "at")
        
    if (!File)
        return PLUGIN_HANDLED
        
    fprintf(File, "^n^"%s^"", Steam)
        
    fclose(File)
    
    TrieSetCell(SuperAdmins, Steam, true)
    
    console_print(id, "Steam: %s is now a SuperAdmin", Steam)
    
    return PLUGIN_HANDLED
}

create_menu_main() {
    
    new buffer[64]
    
    formatex(buffer, charsmax(buffer), "[R]ak Acme Inc.- %s", Menu_Name[AMXSUPERMENU][MENU_NAME])
    
    g_MenuMain = menu_create(buffer, "menu_main_handler")
    
    for(new i = 1; i < sizeof Menu_Name; i++)
        menu_additem(g_MenuMain, Menu_Name[i][MENU_NAME])
        
}

Is_SuperAdmin(id, cid, Args) {
    new Authid[35]
    
    get_user_authid(id, Authid, charsmax(Authid));
    
    if(TrieKeyExists(SuperAdmins, Authid) || id == 0) {
        
        if (read_argc() < Args) {
        
            new cmd[32], info[128], flag
        
            get_concmd(cid, cmd, charsmax(cmd), flag, info, charsmax(info), -1)

            console_print(id,"%L: %s %s", id, "USAGE", cmd, info)
        
            return false
        }
        
        return true
    }
        
    return false
}

get_target(id, Arg[], CheckAlive = false) {
    
    new player = find_player("bl", Arg)
    
    if(player) {
        
        if(player != find_player("blj", Arg)) {
        
            console_print(id, "%L", id, "MORE_CL_MATCHT")
            
            return false
        }
    }
    else if((player = find_player("c", Arg)) == 0 && Arg[0] == '#' && Arg[1])
        player = find_player("k", str_to_num(Arg[1]))
    
    if(!player)
        console_print(id, "%L", id, "CL_NOT_FOUND")
    else if(CheckAlive && !is_user_alive(player)) {
        
        new sName[32]
        
        get_user_name(player, sName, charsmax(sName))
        
        console_print(id, "%L", id, "CANT_PERF_DEAD", sName)
        
        return false
        
    }
    
    return player
    
}

create_file(ConfigDir[]) {
    
    new File = fopen(ConfigDir, "wt")
    
    fprintf(File, "; SuparAdmin By [R]ak Acme Inc.-^n; File location: $moddir/addons/amxmodx/configs/SuperAdmin.ini^n^n; Line starting with ; is a comment^n^n; Example of SuparAdmin account:^n; ^"STEAM_0:0:123456^"^n^n^n;Enjoy")
    
    fclose(File)
}

public plugin_end()
    TrieDestroy(SuperAdmins)
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу