Senior Member
Join Date: Apr 2019
Location: Iran
|
05-01-2019
, 22:45
Re: Admin Menu By Natsheh
|
#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(PLUGIN, VERSION, AUTHOR)
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(id, NORMAL, "^4You ^1Are ^3Not ^4Admin^3!")
return PLUGIN_HANDLED
}
new AMenu = menu_create("Admin Menu^n\yChoose Option", "AdminMenuHandle")
new szAdminOptionNum[8]
for( new i = 0; i < sizeof szAdminOption; i ++ )
{
num_to_str(i, szAdminOptionNum, 7)
menu_additem(AMenu, szAdminOption[i], szAdminOptionNum, 0)
}
menu_display(id, AMenu)
return PLUGIN_CONTINUE
}
public AdminMenuHandle(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[9], name[64]
new access, callback
menu_item_getinfo(menu, item, access, data, 8, name, 63, callback)
new tempOption = str_to_num(data)
switch( tempOption )
{
case 0: KBMenu(id)
}
return PLUGIN_HANDLED
}
public KBMenu(id)
{
new szText[64]
formatex(szText, charsmax(szText), "Kick/Ban Menu")
new KB = menu_create(szText, "KBMenuHandle")
new players[32], num, name[32], szTempid[32]
if(equal(szReasons[id], ""))
format(szReasons[id], 31, "None")
if(equal(szLengths[id], ""))
format(szLengths[id], 10, "0")
formatex(szText, charsmax(szText), "\w%s \rPlayer", szKBText[szKB[id]])
menu_additem(KB, szText, "1", 0)
formatex(szText, charsmax(szText), "\rReason: \w%s", szReasons[id])
menu_additem(KB, szText, "2", 0)
if(szKB[id] == 0)
formatex(szText, charsmax(szText), "\dLength: %s %s", szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
if(szKB[id] == 1)
formatex(szText, charsmax(szText), "\rLength: \w%s %s", szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
menu_additem(KB, szText, "3", 0)
get_players(players, num)
for( new i = 0; i < num; i++ )
{
new tempid = players[ i ]
get_user_name(tempid, name, charsmax(name))
num_to_str(tempid, szTempid, 31)
if(tempid == id || access(tempid, IMMUNITY) || is_user_bot(tempid))
formatex(szText, charsmax(szText), "\d%s \r%s", name, (is_user_bot(tempid) ? "Bot":"*"))
else
formatex(szText, charsmax(szText), "%s", name)
menu_additem(KB, szText, szTempid, 0)
}
menu_display(id, KB)
return PLUGIN_CONTINUE
}
public KBMenuHandle(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[5], name[64]
new Access, callback
menu_item_getinfo(menu, item, Access, data, 4, name, 63, callback)
new tempid = str_to_num(data)
new szAdminName[32], szPlayerName[32], IPa[32], szAuthid[32]
get_user_name(id, szAdminName, charsmax(szAdminName))
get_user_name(tempid, szPlayerName, charsmax(szPlayerName))
get_user_ip(tempid, IPa, charsmax(IPa), 1)
get_user_authid(tempid, szAuthid, charsmax(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(tempid, IMMUNITY) || is_user_bot(tempid))
{
KBMenu(id)
return PLUGIN_CONTINUE
}
new KBMotd[2214], title[64], pos = 0
if(szKB[id] == 0)
format(title, charsmax(title), "You Have Been Kicked")
if(szKB[id] == 1)
format(title, charsmax(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(0, NORMAL, "^4Admin ^1%s^3: ^1Has ^3Kicked ^4%s^3|^1Reason: ^4%s^3!", szAdminName, szPlayerName, szReasons[id])
log_amx("%s Has Kicked %s Reason %s", szAdminName, szPlayerName, szReasons[id])
}
if(szKB[id] == 1)
{
ColorChat(0, NORMAL, "^4Admin ^1%s^3: ^1Has ^3Banned ^4%s^3|^1Reason: ^4%s^3|^1Length: ^4%s %s^3!", szAdminName, szPlayerName, szReasons[id], szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
log_amx("%s Has Banned %s Reason %s Length %s %s", szAdminName, szPlayerName, szReasons[id], szLengths[id], equal(szLengths[id], "0") ? "Permanent":"Minute")
}
show_motd(tempid, KBMotd, title)
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(id, name, charsmax(name))
get_user_ip(id, IPa, charsmax(IPa), 1)
get_user_authid(id, authid, charsmax(authid))
if(KBTiming[id] > 0)
{
set_hudmessage(42, 170, 255, -1.0, -1.0, 0, 6.0, 1.0, 0.5, 0.5, 2)
show_hudmessage(id, "Leaving in %i Seconds", KBTiming[id])
new szWord[32]
num_to_word(KBTiming[id], szWord, 31)
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(szLogBan, MAX_LEN, "^n^"IP^" ^"%s^" ^"%s^" ^"%s^"", szLengths[id], IPa, name)
write_file(szBanList, szLogBan, -1)
server_cmd("addip %s ^"%s^"", szLengths[id], IPa)
return PLUGIN_HANDLED
}
else
{
format(szLogBan, MAX_LEN, "^n^"ID^" ^"%s^" ^"%s^" ^"%s^"", szLengths[id], authid, name)
write_file(szBanList, szLogBan, -1)
server_cmd("banid %s ^"%s^"", szLengths[id], authid)
return PLUGIN_HANDLED
}
}
return PLUGIN_HANDLED
}
public KBReason(id)
{
new Reason[53]
read_args(Reason, 52)
remove_quotes(Reason)
new len = strlen(Reason)
for( new i = 0; i < len; i++ )
{
if(!isalpha(Reason[i]) && !isspace(Reason[i]) && Reason[i] != '+')
{
client_print(id, print_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(Length, 10)
remove_quotes(Length)
new len = strlen(Length)
for( new i = 0; i < len; i++ )
{
if(!isdigit(Length[i]))
{
client_print(id, print_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 :
|
|