View Single Post
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 05-01-2019 , 22:45   Re: Admin Menu By Natsheh
Reply With Quote #39

First of all sry for opening old thread but i need this.

@Natsheh i have problem with Ban/Kick Menu , i used to copy and paste the codes for Ban/Kick in new sma file and made a new plugin to add it in amxmodmenu and everything was good.

But it has only 1 problem, the ban option don't Ban the player, the information of steam id , length , nick of player goes in ban_list.cfg but the banned player can join the server with same steam id and nick!!

Codes of single Ban/Kick Menu Plugin :
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <colorchat>

#define PLUGIN "Admin~Menu"
#define VERSION "1.7"
#define AUTHOR "Natsheh"

#define IMMUNITY ADMIN_IMMUNITY

#define ACCESS ADMIN_LEVEL_A

#define MAX_LEN 64

new szBanList[] = "ban_list.cfg"

new const szAdminOption[][] = {
    
"Kick/Ban Menu"


new 
szKB[33]


new const 
szKBText[][] = {
    
"Kick",
    
"Ban"
}


new 
szReasons[33][32]

new 
szLengths[33][11]

new 
KBTiming[33]




public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_bankick""AdminMenu", -1"Open admin menu"ACCESS)
    
    
register_clcmd("Reason""KBReason", -1"Reason to kick/ban"ACCESS)
    
register_clcmd("Length""KBLength", -1"Length to ban"ACCESS)
}

public 
AdminMenu(id)
{
    if(!(
get_user_flags(id) & ACCESS))
    {
        
ColorChat(idNORMAL"^4You ^1Are ^3Not ^4Admin^3!")
        return 
PLUGIN_HANDLED
    
}
    
    new 
AMenu menu_create("Admin Menu^n\yChoose Option""AdminMenuHandle")
    
    new 
szAdminOptionNum[8]
    
    for( new 
0sizeof szAdminOption++ )
    {
        
num_to_str(iszAdminOptionNum7)
        
menu_additem(AMenuszAdminOption[i], szAdminOptionNum0)
    }
    
menu_display(idAMenu)
    return 
PLUGIN_CONTINUE
}
public 
AdminMenuHandle(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[9], name[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata8name63callback)
    
    new 
tempOption str_to_num(data)
    
    switch( 
tempOption )
    {
        case 
0KBMenu(id)
    }
    return 
PLUGIN_HANDLED
}

public 
KBMenu(id)
{
    new 
szText[64]
    
    
formatex(szTextcharsmax(szText), "Kick/Ban Menu")
    new 
KB menu_create(szText"KBMenuHandle")
    
    new 
players[32], numname[32], szTempid[32]
    
    if(
equal(szReasons[id], ""))
        
format(szReasons[id], 31"None")
    if(
equal(szLengths[id], ""))
        
format(szLengths[id], 10"0")
    
    
formatex(szTextcharsmax(szText), "\w%s \rPlayer"szKBText[szKB[id]])
    
menu_additem(KBszText"1"0)
    
    
formatex(szTextcharsmax(szText), "\rReason: \w%s"szReasons[id])
    
menu_additem(KBszText"2"0)
    
    if(
szKB[id] == 0)
        
formatex(szTextcharsmax(szText), "\dLength: %s %s"szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
    if(
szKB[id] == 1)
        
formatex(szTextcharsmax(szText), "\rLength: \w%s %s"szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
    
    
menu_additem(KBszText"3"0)
    
    
get_players(playersnum)
    
    for( new 
0numi++ )
    {
        new 
tempid players]
        
        
get_user_name(tempidnamecharsmax(name))
        
num_to_str(tempidszTempid31)
        
        if(
tempid == id || access(tempidIMMUNITY) || is_user_bot(tempid))
            
formatex(szTextcharsmax(szText), "\d%s \r%s"name, (is_user_bot(tempid) ? "Bot":"*"))
        else
            
formatex(szTextcharsmax(szText), "%s"name)
        
menu_additem(KBszTextszTempid0)
    }
    
menu_display(idKB)
    return 
PLUGIN_CONTINUE
}
public 
KBMenuHandle(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[5], name[64]
    new 
Accesscallback
    menu_item_getinfo
(menuitemAccessdata4name63callback)
    
    new 
tempid str_to_num(data)
    
    new 
szAdminName[32], szPlayerName[32], IPa[32], szAuthid[32]
    
get_user_name(idszAdminNamecharsmax(szAdminName))
    
get_user_name(tempidszPlayerNamecharsmax(szPlayerName))
    
get_user_ip(tempidIPacharsmax(IPa), 1)
    
get_user_authid(tempidszAuthidcharsmax(szAuthid))
    
    switch( 
item )
    {
        case 
0:
        {
            if(
szKB[id] == 0)
            {
                
szKB[id] = 1
                KBMenu
(id)
                return 
PLUGIN_HANDLED
            
}
            if(
szKB[id] == 1)
            {
                
szKB[id] = 0
                KBMenu
(id)
                return 
PLUGIN_HANDLED
            
}
        }
        case 
1:
        {
            
client_cmd(id"messagemode Reason")
            return 
PLUGIN_HANDLED
        
}
        case 
2:
        {
            if(
szKB[id] == 0)
            {
                
KBMenu(id)
                return 
PLUGIN_HANDLED
            
}
            if(
szKB[id] == 1)
            {
                
client_cmd(id"messagemode Length")
                return 
PLUGIN_HANDLED
            
}
        }
        default:
        {
            if(
tempid == id || access(tempidIMMUNITY) || is_user_bot(tempid))
            {
                
KBMenu(id)
                return 
PLUGIN_CONTINUE
            
}
            
            new 
KBMotd[2214], title[64], pos 0
            
            
if(szKB[id] == 0)
                
format(titlecharsmax(title), "You Have Been Kicked")
            if(
szKB[id] == 1)
                
format(titlecharsmax(title), "You Have Been Banned")
            
            
pos += format(KBMotd[pos],2213-pos"<html><head><style type=^"text/css^">pre{color:#FF0505;}body{background:#000000;margin-left:16px;margin-top:1px;}</style></head><pre><body>")
            
            if(
szKB[id] == 0)
                
pos += format(KBMotd[pos],2213-pos"<h1><center>You Have Been Kicked</center></h1>")
            if(
szKB[id] == 1)
                
pos += format(KBMotd[pos],2213-pos"<h1><center>You Have Been Banned</center></h1>")
            
            
pos += format(KBMotd[pos],2213-pos"<h2><center>Reason: %s</center></h2>"szReasons[id])
            
            if(
szKB[id] == 1)
                
pos += format(KBMotd[pos],2213-pos"<h2><center>Length: %s %s</center></h2>"szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
            
            if(
szKB[id] == 0)
                
pos += format(KBMotd[pos],2213-pos"<h3><center>Kicked~By~Admin: %s</center></h3>"szAdminName)
            if(
szKB[id] == 1)
                
pos += format(KBMotd[pos],2213-pos"<h3><center>Banned~By~Admin: %s</center></h3>"szAdminName)
            
            if(
equal(szAuthid"STEAM_ID_LAN"))
                
pos += format(KBMotd[pos],2213-pos"<h1><center>IP: %s</center></h1>"IPa)
            else
                
pos += format(KBMotd[pos],2213-pos"<h1><center>Steam_ID: %s</center></h1>"szAuthid)
            
            
szKB[tempid] = szKB[id]
            
szLengths[tempid] = szLengths[id]
            
KBTiming[tempid] = 5
            
            
if(szKB[id] == 0)
            {
                
ColorChat(0NORMAL"^4Admin ^1%s^3: ^1Has ^3Kicked ^4%s^3|^1Reason: ^4%s^3!"szAdminNameszPlayerNameszReasons[id])
                
log_amx("%s Has Kicked %s Reason %s"szAdminNameszPlayerNameszReasons[id])
            }
            if(
szKB[id] == 1)
            {
                
ColorChat(0NORMAL"^4Admin ^1%s^3: ^1Has ^3Banned ^4%s^3|^1Reason: ^4%s^3|^1Length: ^4%s %s^3!"szAdminNameszPlayerNameszReasons[id], szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
                
log_amx("%s Has Banned %s Reason %s Length %s %s"szAdminNameszPlayerNameszReasons[id], szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
            }
            
show_motd(tempidKBMotdtitle)
            
set_task(1.0"KBTime"tempid__"b")
        }
    }
    return 
PLUGIN_HANDLED
}
public 
KBTime(id)
{
    static 
name[32], IPa[32], authid[32], szLogBan[MAX_LEN]
    
get_user_name(idnamecharsmax(name))
    
get_user_ip(idIPacharsmax(IPa), 1)
    
get_user_authid(idauthidcharsmax(authid))
    
    if(
KBTiming[id] > 0)
    {
        
set_hudmessage(42170255, -1.0, -1.006.01.00.50.52)
        
show_hudmessage(id"Leaving in %i Seconds"KBTiming[id])
        
        new 
szWord[32]
        
num_to_word(KBTiming[id], szWord31)
        
client_cmd(id"spk %s"szWord)
        
        
KBTiming[id] --
        return 
PLUGIN_CONTINUE
    
}
    
    
remove_task(id)
    
    if(
szKB[id] == 0)
    {
        
server_cmd("kick ^"%s^""name)
        return 
PLUGIN_HANDLED
    
}
    if(
szKB[id] == 1)
    {
        if (
equal("4294967295"authid)
            || 
equal("HLTV"authid)
            || 
equal("STEAM_ID_LAN"authid)
            || 
equali("VALVE_ID_LAN"authid))
        {
            
format(szLogBanMAX_LEN"^n^"IP^" ^"%s^" ^"%s^" ^"%s^""szLengths[id], IPaname)
            
write_file(szBanListszLogBan, -1)
            
server_cmd("addip %s ^"%s^""szLengths[id], IPa)
            return 
PLUGIN_HANDLED
        
}
        else
        {
            
format(szLogBanMAX_LEN"^n^"ID^" ^"%s^" ^"%s^" ^"%s^""szLengths[id], authidname)
            
write_file(szBanListszLogBan, -1)
            
server_cmd("banid %s ^"%s^""szLengths[id], authid)
            return 
PLUGIN_HANDLED
        
}            
    }
    return 
PLUGIN_HANDLED
}
public 
KBReason(id)
{
    new 
Reason[53]
    
read_args(Reason52)
    
    
remove_quotes(Reason)
    
    new 
len strlen(Reason)
    
    for( new 
0leni++ )
    {
        if(!
isalpha(Reason[i]) && !isspace(Reason[i]) && Reason[i] != '+')
        {
            
client_print(idprint_center"Only Alphabet")
            
KBMenu(id)
            return
        }
    }
    
    if(
equal(Reason""))
        
format(szReasons[id], 52"None")
    else
        
format(szReasons[id], 52"%s"Reason)
    
    
KBMenu(id)
}
public 
KBLength(id)
{
    new 
Length[11]
    
read_args(Length10)
    
    
remove_quotes(Length)
    
    new 
len strlen(Length)
    
    for( new 
0leni++ )
    {
        if(!
isdigit(Length[i]))
        {
            
client_print(idprint_center"Only Numbers")
            
KBMenu(id)
            return
        }
    }
    
    if(
equal(Length"") || equal(Length"00"1))
        
format(szLengths[id], 10"0")
    else
        
format(szLengths[id], 10"%s"Length)
    
    
KBMenu(id)

I will upload ScreenShots so you can see what i made : https://anonfile.com/xbU5Kdl3n6/Ban_...creenshots_rar

and the sma file also :
Attached Files
File Type: sma Get Plugin or Get Source (KBmenu.sma - 390 views - 8.9 KB)
LearninG is offline