Member
Join Date: Dec 2018
Location: Romania
|
03-26-2019
, 09:34
Re: [CSGO] Local Bans
|
#3
|
Quote:
Originally Posted by Cruze
Try this:
util.sp
PHP Code:
void UTIL_OfflineBan(int iAdmin, int iID, const char[] szReason)
{
DebugMessage("%N (%i) UTIL_OfflineBan -> %i (%s)", iAdmin, iAdmin, iID, szReason)
DataPack hPack = CreateDataPack();
hPack.WriteCell(UID(iAdmin));
hPack.WriteCell(iID);
hPack.WriteString(szReason);
char szQuery[256];
FormatEx(szQuery, sizeof(szQuery), "SELECT `name`, `auth`, `ip` FROM `table_offline` WHERE `id` = %i;", iID);
g_hDatabase.Query(SQL_Callback_OfflineBanSelectInfo, szQuery, hPack);
}
public void SQL_Callback_OfflineBanSelectInfo(Database hDatabase, DBResultSet results, const char[] sError, any hDataPack)
{
if(sError[0])
{
LogError("SQL_Callback_OfflineBanSelectInfo: %s", sError);
return;
}
ResetPack(hDataPack);
int iClient = CID(ReadPackCell(hDataPack));
if(iClient && results.FetchRow())
{
char szQuery[256], szReason[128], szName[MAX_NAME_LENGTH], szAuth[32], szIp[16];
FormatEx(szQuery, sizeof(szQuery), "DELETE FROM `table_offline` WHERE `id` = '%i';", ReadPackCell(hDataPack));
g_hDatabase.Query(SQL_Callback_CheckError, szQuery);
ReadPackString(hDataPack, szReason, sizeof(szReason));
results.FetchString(0, szName, sizeof(szName));
results.FetchString(1, szAuth, sizeof(szAuth));
results.FetchString(2, szIp, sizeof(szIp));
DebugMessage("SQL_Callback_OfflineBanSelectInfo -> '%s', '%s', '%s'", szName, szAuth, szIp)
UTIL_CreateBan(iClient, _, szAuth, szName, szIp, g_iBanTime[iClient], szReason);
}
CloseHandle(hDataPack);
}
void UTIL_CreateBan(int iAdmin = 0, int iTarget = 0, const char[] szSourceAuth = "", const char[] szSourceName = "", const char[] szSourceIp = "", int iLength, const char[] szSourceReason, int iType = 0)
{
DebugMessage("%N (%i) UTIL_CreateBan -> %i (%s), (%s)", iAdmin, iAdmin, iTarget, szSourceAuth, szSourceName)
char szName[MAX_NAME_LENGTH*2+1], szIp[16], szQuery[512], szAuth[32], szAdminName[MAX_NAME_LENGTH*2+1], szAdminAuth[32];
int iAdminUserID = strlen(szSourceReason)*2+1;
char[] szReason = new char[iAdminUserID];
g_hDatabase.Escape(szSourceReason, szReason, iAdminUserID);
int iTargetUserID;
if(iAdmin)
{
iAdminUserID = UID(iAdmin);
GetClientName(iAdmin, szQuery, MAX_NAME_LENGTH);
g_hDatabase.Escape(szQuery, szAdminName, sizeof(szAdminName));
GetClientAuthId(iAdmin, AuthId_Engine, szAdminAuth, sizeof(szAdminAuth));
}
else
{
iAdminUserID = 0;
strcopy(szAdminName, sizeof(szAdminName), "CONSOLE");
strcopy(szAdminAuth, sizeof(szAdminAuth), "STEAM_ID_SERVER");
}
if(iTarget)
{
iTargetUserID = UID(iTarget);
GetClientAuthId(iTarget, AuthId_Engine, szAuth, sizeof(szAuth));
GetClientName(iTarget, szQuery, MAX_NAME_LENGTH);
g_hDatabase.Escape(szQuery, szName, sizeof(szName));
GetClientIP(iTarget, szIp, sizeof(szIp));
}
else
{
iTargetUserID = 0;
if(szSourceAuth[0])
{
strcopy(szAuth, sizeof(szAuth), szSourceAuth);
}
else
{
strcopy(szAuth, sizeof(szAuth), "unknown");
}
g_hDatabase.Escape(szSourceName, szName, sizeof(szName));
if(szSourceIp[0])
{
strcopy(szIp, sizeof(szIp), szSourceIp);
}
else
{
strcopy(szIp, sizeof(szIp), "unknown");
}
}
Handle hDataPack = CreateDataPack();
WritePackCell(hDataPack, iAdminUserID);
WritePackCell(hDataPack, iTargetUserID);
FormatEx(szQuery, sizeof(szQuery), "INSERT INTO `table_bans` (`auth`, `ip`, `name`, `ban_time`, `length`, `reason`, `admin_auth`, `admin_name`, `ban_type`) VALUES ( '%s', '%s', '%s', %i, %i, '%s', '%s', '%s', '%i');", szAuth, szIp, szName, GetTime(), iLength, szReason, szAdminAuth, szAdminName, iType);
DebugMessage("szQuery: '%s'", szQuery)
g_hDatabase.Query(SQL_Callback_InsertBan, szQuery, hDataPack);
}
public void SQL_Callback_InsertBan(Database hDatabase, DBResultSet results, const char[] sError, any hDataPack)
{
if(sError[0])
{
LogError("SQL_Callback_InsertBan: %s", sError);
CloseHandle(hDataPack);
return;
}
ResetPack(hDataPack);
int iClient = CID(ReadPackCell(hDataPack));
if(iClient)
{
PrintToChat(iClient, "Ban successfully added!");
}
iClient = CID(ReadPackCell(hDataPack));
if(iClient)
{
UTIL_SearchBan(iClient);
}
CloseHandle(hDataPack);
}
void UTIL_SearchBan(int iClient)
{
char szQuery[256], szAuth[32], szIp[16];
GetClientAuthId(iClient, AuthId_Engine, szAuth, sizeof(szAuth));
GetClientIP(iClient, szIp, sizeof(szIp));
if(g_bCheckBanMode)
{
FormatEx(szQuery, sizeof(szQuery), "SELECT `id`, `ban_time`, `length`, `reason`, `admin_name`, `admin_auth` FROM `table_bans` WHERE `remove_type` = '0' AND (`auth` = '%s' OR `ip` = '%s');", szAuth, szIp);
}
else
{
FormatEx(szQuery, sizeof(szQuery), "SELECT `id`, `ban_time`, `length`, `reason`, `admin_name`, `admin_auth` FROM `table_bans` WHERE `remove_type` = '0' AND ((`auth` = '%s' AND `ban_type` = 0) OR (`ip` = '%s' AND `ban_type` = 1));", szAuth, szIp);
}
DebugMessage("szQuery: '%s'", szQuery)
g_hDatabase.Query(SQL_Callback_SearchClientBan, szQuery, UID(iClient));
}
public void SQL_Callback_SearchClientBan(Database hDatabase, DBResultSet results, const char[] sError, any iUserID)
{
if(sError[0])
{
LogError("SQL_Callback_SearchClientBan: %s", sError);
return;
}
int iClient = GetClientOfUserId(iUserID);
if(iClient)
{
if(results.FetchRow())
{
DebugMessage("FetchRow")
int iBanTime = results.FetchInt(1);
int iLength = results.FetchInt(2);
int iTime = GetTime();
if(iLength && iTime > iBanTime+iLength)
{
DebugMessage("UTIL_UnBan")
UTIL_UnBan(results.FetchInt(0));
return;
}
char szAuth[32], szBanReason[256], szAdminName[MAX_NAME_LENGTH], szAdminAuth[32], szBanTime[64], szDuration[64], szExp[64];
GetClientAuthId(iClient, AuthId_Engine, szAuth, sizeof(szAuth));
FormatTime(szBanTime, sizeof(szBanTime), g_szTimeFormat, iBanTime);
if(!GetDuration(iLength, szDuration, sizeof(szDuration)))
{
FormatEx(szDuration, sizeof(szDuration), "%i min.", iLength/60);
}
if(iLength)
{
UTIL_GetTimeFromStamp(szExp, sizeof(szExp), ((iBanTime+iLength)-iTime), iClient);
Format(szExp, sizeof(szExp), "Expires %s", szExp);
}
else
{
strcopy(szExp, sizeof(szExp), "Never");
}
results.FetchString(3, szBanReason, sizeof(szBanReason));
results.FetchString(4, szAdminName, sizeof(szAdminName));
results.FetchString(5, szAdminAuth, sizeof(szAdminAuth));
PrintToConsole(iClient, "####################################################################");
PrintToConsole(iClient, "####################################################################");
PrintToConsole(iClient, "####################################################################");
PrintToConsole(iClient, "###\t \t You are banned on this server.");
PrintToConsole(iClient, "###\t \t Your SteamID: %s", szAuth);
PrintToConsole(iClient, "###\t \t Who banned you: %s (%s)", szAdminName, szAdminAuth);
PrintToConsole(iClient, "###\t \t Reason: %s", szBanReason);
PrintToConsole(iClient, "###\t \t Ban time: %s", szBanTime);
PrintToConsole(iClient, "###\t \t Duration: %s", szDuration);
PrintToConsole(iClient, "###\t \t Expires: %s", szExp);
PrintToConsole(iClient, "###\t \t %s", g_szBanInfo);
PrintToConsole(iClient, "####################################################################");
PrintToConsole(iClient, "####################################################################");
PrintToConsole(iClient, "####################################################################");
char szBuffer[256];
strcopy(szBuffer, sizeof(szBuffer), g_szBanInfoPanel);
ReplaceString(szBuffer, sizeof(szBuffer), "\\n", "\n");
ReplaceString(szBuffer, sizeof(szBuffer), "{AUTH}", szAuth);
ReplaceString(szBuffer, sizeof(szBuffer), "{ADMIN_NAME}", szAdminName);
ReplaceString(szBuffer, sizeof(szBuffer), "{ADMIN_AUTH}", szAdminAuth);
ReplaceString(szBuffer, sizeof(szBuffer), "{REASON}", szBanReason);
ReplaceString(szBuffer, sizeof(szBuffer), "{BAN_TIME}", szBanTime);
ReplaceString(szBuffer, sizeof(szBuffer), "{DURATION}", szDuration);
ReplaceString(szBuffer, sizeof(szBuffer), "{EXPIRES}", szExp);
ReplaceString(szBuffer, sizeof(szBuffer), "{BAN_INFO}", g_szBanInfo);
DebugMessage("Banned")
DataPack hPack;
CreateDataTimer(KICK_DELAY, Timer_KickDelay, hPack);
hPack.WriteCell(UID(iClient));
hPack.WriteString(szBuffer);
}
}
}
bool GetDuration(int iDuration, char[] szBuffer, int iMaxLen)
{
g_hKeyValues.Rewind();
char szKey[64];
FormatEx(szKey, sizeof(szKey), "ban_times/%i", iDuration/60);
g_hKeyValues.GetString(szKey, szBuffer, iMaxLen);
return (szBuffer[0]);
}
public Action Timer_KickDelay(Handle hTimer, Handle hDataPack)
{
ResetPack(hDataPack);
int iClient = CID(ReadPackCell(hDataPack));
DebugMessage("Timer_KickDelay: %i", iClient)
if(iClient)
{
char szMessage[512];
ReadPackString(hDataPack, szMessage, sizeof(szMessage));
KickClient(iClient, szMessage);
}
return Plugin_Stop;
}
void UTIL_UnBan(int iBanID, int iType = 1)
{
char szQuery[256];
FormatEx(szQuery, sizeof(szQuery), "UPDATE `table_bans` SET `remove_type` = %i WHERE `id` = '%i';", iType, iBanID);
g_hDatabase.Query(SQL_Callback_CheckError, szQuery);
}
void UTIL_RemoveBan(int iBanID)
{
char szQuery[256];
FormatEx(szQuery, sizeof(szQuery), "DELETE FROM `table_bans` WHERE `id` = '%i';", iBanID);
g_hDatabase.Query(SQL_Callback_CheckError, szQuery);
}
void UTIL_GetTimeFromStamp(char[] szBuffer, int iMaxLen, int iTimeStamp)
{
if (iTimeStamp > 31536000)
{
int years = iTimeStamp / 31536000;
int days = iTimeStamp / 86400 % 365;
if (days > 0)
{
FormatEx(szBuffer, iMaxLen, "%d y. %d d.", years, days);
}
else
{
FormatEx(szBuffer, iMaxLen, "%d y.", years);
}
return;
}
if (iTimeStamp > 86400)
{
int days = iTimeStamp / 86400 % 365;
int hours = (iTimeStamp / 3600) % 24;
if (hours > 0)
{
FormatEx(szBuffer, iMaxLen, "%d d. %d h.", days, hours);
}
else
{
FormatEx(szBuffer, iMaxLen, "%d d.", days);
}
return;
}
else
{
int Hours = (iTimeStamp / 3600);
int Mins = (iTimeStamp / 60) % 60;
int Secs = iTimeStamp % 60;
if (Hours > 0)
{
FormatEx(szBuffer, iMaxLen, "%02d:%02d:%02d", Hours, Mins, Secs);
}
else
{
FormatEx(szBuffer, iMaxLen, "%02d:%02d", Mins, Secs);
}
}
}
cmds.sp
PHP Code:
public Action Command_Ban(int iClient, int iArgs)
{
if (iArgs < 2)
{
ReplyToCommand(iClient, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
return Plugin_Handled;
}
char szArg[64];
GetCmdArg(1, szArg, sizeof(szArg));
int iTarget = FindTarget(iClient, szArg, true);
if (iTarget == -1)
{
ReplyToCommand(iClient, "[SM] Игрок не найден!");
return Plugin_Handled;
}
GetCmdArg(2, szArg, sizeof(szArg));
char szReason[128];
if (iArgs == 3)
{
GetCmdArg(3, szReason, sizeof(szReason));
}
UTIL_CreateBan(iClient, iTarget, _, _, _, S2I(szArg)*60, szReason);
return Plugin_Handled;
}
public Action Command_AddBan(int iClient, int iArgs)
{
if (iArgs < 2)
{
ReplyToCommand(iClient, "[SM] Usage: sm_addban <steamid> <time> [reason] [name]");
return Plugin_Handled;
}
char szAuth[32];
GetCmdArg(1, szAuth, sizeof(szAuth));
if (!(!strncmp(szAuth, "STEAM_", 6) && szAuth[7] == ':') && strncmp(szAuth, "[U:", 3))
{
ReplyToCommand(iClient, "[SM] %t", "Invalid SteamID specified");
return Plugin_Handled;
}
char szTime[16];
GetCmdArg(2, szTime, sizeof(szTime));
char szReason[128], szName[MAX_NAME_LENGTH];
if (iArgs == 3)
{
GetCmdArg(3, szReason, sizeof(szReason));
}
if (iArgs == 4)
{
GetCmdArg(4, szName, sizeof(szName));
}
UTIL_CreateBan(iClient, _, szAuth, szName, _, S2I(szTime)*60, szReason);
return Plugin_Handled;
}
public Action Command_BanIp(int iClient, int iArgs)
{
if (iArgs < 2)
{
ReplyToCommand(iClient, "[SM] Usage: sm_banip <ip|#userid|name> <time> [reason]");
return Plugin_Handled;
}
char szArg[64];
GetCmdArg(1, szArg, sizeof(szArg));
int iTarget = FindTarget(iClient, szArg, true);
if (iTarget == -1)
{
ReplyToCommand(iClient, "[SM] Player not found!");
return Plugin_Handled;
}
GetCmdArg(2, szArg, sizeof(szArg));
char szReason[128];
if (iArgs == 3)
{
GetCmdArg(3, szReason, sizeof(szReason));
}
UTIL_CreateBan(iClient, iTarget, _, _, _, S2I(szArg)*60, szReason, 1);
return Plugin_Handled;
}
public Action Command_Unban(int iClient, int iArgs)
{
if (iArgs < 1)
{
ReplyToCommand(iClient, "[SM] Usage: sm_unban <steamid|ip>");
return Plugin_Handled;
}
char szQuery[256], szAuth[32], szPart[128];
GetCmdArg(1, szAuth, sizeof(szAuth));
if(g_bUnBanMode && !(GetUserFlagBits(iClient) & ADMFLAG_ROOT))
{
char szAdminAuth[32];
GetClientAuthId(iClient, AuthId_Engine, szAdminAuth, sizeof(szAdminAuth));
FormatEx(szPart, sizeof(szPart), " AND (`admin_auth` = '%s');", szAdminAuth);
}
else
{
szPart[0] = 0;
}
FormatEx(szQuery, sizeof(szQuery), "UPDATE `table_bans` SET `remove_type` = 1 WHERE `remove_type` = '0' AND (`auth` = '%s' OR `ip` = '%s')%s;", szAuth, szAuth, szPart);
g_hDatabase.Query(SQL_Callback_UnBan, szQuery, iClient ? UID(iClient):0);
return Plugin_Handled;
}
public void SQL_Callback_UnBan(Database hDatabase, DBResultSet results, const char[] sError, any iClient)
{
if(sError[0])
{
LogError("SQL_Callback_UnBan: %s", sError);
return;
}
if(iClient)
{
iClient = GetClientOfUserId(iClient);
if(!iClient)
{
return;
}
}
if(results.AffectedRows)
{
ReplyToCommand(iClient, "[SM] The player is broken!");
}
else
{
ReplyToCommand(iClient, "[SM] Ban not found!");
}
}
|
Now i got other error
PHP Code:
//// LocalBans.sp
//
// LocalBans/util.sp(182) : error 092: number of arguments does not match definition
// LocalBans/banlist.sp(164) : error 092: number of arguments does not match definition
banlist.sp
PHP Code:
public void AdminMenu_BanList(Handle hTopMenu, TopMenuAction action, TopMenuObject topobj_id, int iClient, char[] szBuffer, int iMaxLength)
{
if (action == TopMenuAction_DisplayOption)
{
FormatEx(szBuffer, iMaxLength, "BanList");
}
else if (action == TopMenuAction_SelectOption)
{
g_iClientOffset[iClient] = 0;
DisplayBanListMenu(iClient);
}
}
void DisplayBanListMenu(int iClient)
{
char szQuery[256];
if(g_bShowBansMode)
{
FormatEx(szQuery, sizeof(szQuery), "SELECT `id`, `name`, `remove_type` FROM `table_bans` LIMIT %i, %i;", g_iClientOffset[iClient], g_iClientOffset[iClient]+g_iShowBansCount);
}
else
{
FormatEx(szQuery, sizeof(szQuery), "SELECT `id`, `name` FROM `table_bans` WHERE `remove_type` = '0' LIMIT %i, %i;", g_iClientOffset[iClient], g_iClientOffset[iClient]+g_iShowBansCount);
}
g_hDatabase.Query(SQL_Callback_SelectBanList, szQuery, UID(iClient));
}
public void SQL_Callback_SelectBanList(Database hDatabase, DBResultSet results, const char[] sError, any iUserID)
{
if(sError[0])
{
LogError("SQL_Callback_SelectBanList: %s", sError);
return;
}
int iClient = GetClientOfUserId(iUserID);
if(iClient)
{
Menu hMenu = CreateMenu(MenuHandler_BanList);
hMenu.SetTitle("Ban list:\n ");
hMenu.ExitBackButton = true;
if(results.RowCount)
{
hMenu.AddItem("search", "Search\n ");
char szName[MAX_NAME_LENGTH*2], szID[16];
int i = 0;
while(results.FetchRow())
{
results.FetchString(0, szID, sizeof(szID));
results.FetchString(1, szName, sizeof(szName));
hMenu.AddItem(szID, szName);
if(g_bShowBansMode)
{
switch(results.FetchInt(2))
{
case 1: StrCat(szName, sizeof(szName), " (Has expired)");
case 2: StrCat(szName, sizeof(szName), " (Banned)");
}
}
++i;
}
if(i == g_iShowBansCount)
{
hMenu.AddItem("more", "Show more bans");
}
}
else
{
hMenu.AddItem("", "No ban available", ITEMDRAW_DISABLED);
}
hMenu.Display(iClient, MENU_TIME_FOREVER);
}
}
public int MenuHandler_BanList(Menu hMenu, MenuAction action, int iClient, int Item)
{
switch(action)
{
case MenuAction_End:
{
delete hMenu;
}
case MenuAction_Cancel:
{
if (Item == MenuCancel_ExitBack && g_hTopMenu)
{
g_hTopMenu.Display(iClient, TopMenuPosition_LastCategory);
}
}
case MenuAction_Select:
{
char szID[16];
hMenu.GetItem(Item, szID, sizeof(szID));
if(strcmp(szID, "more") == 0)
{
g_iClientOffset[iClient] += g_iShowBansCount;
DisplayBanListMenu(iClient);
return 0;
}
if(strcmp(szID, "search") == 0)
{
g_bWaitChat[iClient] = true;
g_bSearch[iClient] = true;
g_bOffBan[iClient] = false;
DisplayWaitChatMenu(iClient);
return 0;
}
DisplayBanInfoMenu(iClient, S2I(szID));
}
}
return 0;
}
void DisplayBanInfoMenu(int iClient, int iID)
{
char szQuery[256];
FormatEx(szQuery, sizeof(szQuery), "SELECT `id`, `name`, `admin_name`, `admin_auth`, `ban_time`, `length`, `reason`, `remove_type` FROM `table_bans` WHERE `id` = '%i';", iID);
g_hDatabase.Query(SQL_Callback_SelectBanInfo, szQuery, UID(iClient));
}
public void SQL_Callback_SelectBanInfo(Database hDatabase, DBResultSet results, const char[] sError, any iUserID)
{
if(sError[0])
{
LogError("SQL_Callback_SelectBanInfo: %s", sError);
return;
}
int iClient = GetClientOfUserId(iUserID);
if(iClient && results.FetchRow())
{
Menu hMenu = CreateMenu(MenuHandler_BanInfo);
hMenu.ExitBackButton = true;
int iID = results.FetchInt(0);
int iBanTime = results.FetchInt(4);
int iLength = results.FetchInt(5);
int iTime = GetTime();
char szID[16], szAuth[32], szName[MAX_NAME_LENGTH], szBanReason[256], szAdminName[MAX_NAME_LENGTH], szAdminAuth[32], szAdminAuth2[32], szBanTime[64], szDuration[64], szExp[64];
results.FetchString(1, szName, sizeof(szName));
results.FetchString(2, szAdminName, sizeof(szAdminName));
results.FetchString(3, szAdminAuth, sizeof(szAdminAuth));
results.FetchString(6, szBanReason, sizeof(szBanReason));
GetClientAuthId(iClient, AuthId_Engine, szAdminAuth2, sizeof(szAdminAuth2));
FormatTime(szBanTime, sizeof(szBanTime), g_szTimeFormat, iBanTime);
if(!GetDuration(iLength, szDuration, sizeof(szDuration)))
{
FormatEx(szDuration, sizeof(szDuration), "%i min.", iLength/60);
}
if(iLength)
{
UTIL_GetTimeFromStamp(szExp, sizeof(szExp), ((iBanTime+iLength)-iTime), iClient);
Format(szExp, sizeof(szExp), "Expires %s", szExp);
}
else
{
strcopy(szExp, sizeof(szExp), "Никогда");
}
if(g_bShowBansMode)
{
char szBuffer[64];
switch(results.FetchInt(7))
{
case 0: FormatEx(szBuffer, sizeof(szBuffer), "Active\nExpires: %s", szExp);
case 1: strcopy(szBuffer, sizeof(szBuffer), "Has expired");
case 2: strcopy(szBuffer, sizeof(szBuffer), "Banned");
}
hMenu.SetTitle("SteamID: %s\n\
Name: %s\n\
Admin who banned you: %s\n\
Reason: %s\n\
Ban issued: %s\n\
Duration: %s\n\
Other: %s",
szAuth,
szName,
szAdminName,
szBanReason,
szBanTime,
szDuration,
szBuffer);
}
else
{
hMenu.SetTitle("SteamID: %s\n\
Name: %s\n\
Admin who banned you: %s\n\
Reason: %s\n\
Ban issued: %s\n\
Duration: %s\n\
Expires: %s",
szAuth,
szName,
szAdminName,
szBanReason,
szBanTime,
szDuration,
szExp);
}
/*
bool bRemoveBanAccess = CheckCommandAccess(iClient, "sm_remove_ban", ADMFLAG_UNBAN);
bool bUnBanAccess = CheckCommandAccess(iClient, "sm_unban", ADMFLAG_UNBAN);
*/
bool bIsRoot = (GetUserFlagBits(iClient) & ADMFLAG_ROOT != 0);
bool bItsHimBan = (strcmp(szAdminAuth2, szAdminAuth) == 0);
/*if((g_bUnBanMode && (bItsHimBan || bUnBanAccess)) || (!g_bUnBanMode && bUnBanAccess))
{
FormatEx(szID, sizeof(szID), "u%i", iID);
hMenu.AddItem(szID, "To unban");
}
if((g_bRemoveBanMode && (bItsHimBan || bRemoveBanAccess)) || (!g_bRemoveBanMode && bRemoveBanAccess))
{
FormatEx(szID, sizeof(szID), "r%i", iID);
hMenu.AddItem(szID, "Delete");
}*/
if(bIsRoot || (g_bUnBanMode && bItsHimBan))
{
FormatEx(szID, sizeof(szID), "u%i", iID);
hMenu.AddItem(szID, "To unban");
}
if(bIsRoot || (g_bRemoveBanMode && bItsHimBan))
{
FormatEx(szID, sizeof(szID), "r%i", iID);
hMenu.AddItem(szID, "Delete");
}
hMenu.AddItem("", "", ITEMDRAW_NOTEXT);
hMenu.AddItem("", "", ITEMDRAW_NOTEXT);
hMenu.AddItem("", "", ITEMDRAW_NOTEXT);
hMenu.AddItem("", "", ITEMDRAW_NOTEXT);
hMenu.Display(iClient, MENU_TIME_FOREVER);
}
}
public int MenuHandler_BanInfo(Menu hMenu, MenuAction action, int iClient, int Item)
{
switch(action)
{
case MenuAction_End:
{
delete hMenu;
}
case MenuAction_Cancel:
{
if (Item == MenuCancel_ExitBack)
{
DisplayBanListMenu(iClient);
}
}
case MenuAction_Select:
{
char szID[16];
hMenu.GetItem(Item, szID, sizeof(szID));
int iID = S2I(szID[1]);
if(szID[0] == 'u')
{
UTIL_UnBan(iID, 2);
DisplayBanInfoMenu(iClient, iID);
PrintToChat(iClient, "Player banned!");
return 0;
}
if(szID[0] == 'r')
{
UTIL_RemoveBan(iID);
DisplayBanListMenu(iClient);
PrintToChat(iClient, "Ban removed!");
return 0;
}
}
}
return 0;
}
__________________
|
|