KnifeBan: bunch of improvements
This commit is contained in:
parent
807e6d71ff
commit
84223aee22
@ -23,7 +23,7 @@ public Plugin myinfo =
|
||||
name = "KnifeBan",
|
||||
author = "Dogan",
|
||||
description = "Tools to handle Zombie Knifers in ZE",
|
||||
version = "1.0.0",
|
||||
version = "2.0.0",
|
||||
url = ""
|
||||
}
|
||||
|
||||
@ -162,6 +162,7 @@ public void CheckIfClientIsStillKnifeBanned(char sAuth[32], int client, int time
|
||||
{
|
||||
Banlist.SetNum("time", 0);
|
||||
Banlist.SetNum("duration", 0);
|
||||
Banlist.SetString("admin", "");
|
||||
Banlist.Rewind();
|
||||
Banlist.ExportToFile(g_sBanListFilePath);
|
||||
}
|
||||
@ -185,6 +186,9 @@ public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &dam
|
||||
if(!ZR_IsClientZombie(victim))
|
||||
return Plugin_Continue;
|
||||
|
||||
if(!ZR_IsClientHuman(attacker))
|
||||
return Plugin_Continue;
|
||||
|
||||
char sWeapon[32];
|
||||
int iWeapon = GetEntDataEnt2(attacker, g_hActiveWeapon);
|
||||
if(iWeapon != INVALID_ENT_REFERENCE)
|
||||
@ -235,6 +239,12 @@ public Action Command_Knifeban(int client, int args)
|
||||
}
|
||||
|
||||
g_bKnifeBanned[target] = true;
|
||||
int time = GetTime();
|
||||
|
||||
char sAdmin[32];
|
||||
GetClientName(client, sAdmin, sizeof(sAdmin));
|
||||
if(client == 0)
|
||||
sAdmin = "Console";
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(target, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
@ -247,13 +257,13 @@ public Action Command_Knifeban(int client, int args)
|
||||
{
|
||||
CPrintToChatAll("\x07%s[KnifeBan] \x07%s%N\x07%s knifebanned \x07%s%N\x07%s for \x07%s%d\x07%s minutes.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", length, "F16767");
|
||||
LogAction(client, target, "%L knifebanned %L for %d minutes.", client, target, length);
|
||||
int time = GetTime();
|
||||
if(Banlist.JumpToKey(sAuth, true))
|
||||
{
|
||||
int history = Banlist.GetNum("history");
|
||||
Banlist.SetNum("history", history + 1);
|
||||
Banlist.SetNum("time", time);
|
||||
Banlist.SetNum("duration", length);
|
||||
Banlist.SetString("admin", sAdmin);
|
||||
Banlist.Rewind();
|
||||
Banlist.ExportToFile(g_sBanListFilePath);
|
||||
}
|
||||
@ -266,8 +276,9 @@ public Action Command_Knifeban(int client, int args)
|
||||
{
|
||||
int history = Banlist.GetNum("history");
|
||||
Banlist.SetNum("history", history + 1);
|
||||
Banlist.SetNum("time", 0);
|
||||
Banlist.SetNum("time", time);
|
||||
Banlist.SetNum("duration", -1);
|
||||
Banlist.SetString("admin", sAdmin);
|
||||
Banlist.Rewind();
|
||||
Banlist.ExportToFile(g_sBanListFilePath);
|
||||
}
|
||||
@ -281,6 +292,8 @@ public Action Command_Knifeban(int client, int args)
|
||||
{
|
||||
int history = Banlist.GetNum("history");
|
||||
Banlist.SetNum("history", history + 1);
|
||||
Banlist.SetNum("time", time);
|
||||
Banlist.SetString("admin", sAdmin);
|
||||
Banlist.Rewind();
|
||||
Banlist.ExportToFile(g_sBanListFilePath);
|
||||
int accountid = GetSteamAccountID(target);
|
||||
@ -324,6 +337,7 @@ public Action Command_Knifeunban(int client, int args)
|
||||
Banlist.SetNum("history", history - 1);
|
||||
Banlist.SetNum("time", 0);
|
||||
Banlist.SetNum("duration", 0);
|
||||
Banlist.SetString("admin", "");
|
||||
Banlist.Rewind();
|
||||
Banlist.ExportToFile(g_sBanListFilePath);
|
||||
}
|
||||
@ -502,5 +516,148 @@ public Action Command_Knifebanlist(int client, int args)
|
||||
else
|
||||
CReplyToCommand(client, "\x07%s[KnifeBan] \x07%sCurrently knifebanned clients: \x07%snone", "E01B5D", "F16767", "EDEDED");
|
||||
|
||||
if(CheckCommandAccess(client, "", ADMFLAG_BAN))
|
||||
OpenKnifebanlistMenu(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void OpenKnifebanlistMenu(int client)
|
||||
{
|
||||
if(client == 0)
|
||||
return;
|
||||
|
||||
Menu menu = new Menu(MenuHandler_MainMenu);
|
||||
|
||||
menu.SetTitle("Currently knifebanned clients:", client);
|
||||
|
||||
char sBuffer[32];
|
||||
int iMenuItem;
|
||||
char sMenuItem[8];
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientInGame(i) && !IsFakeClient(i))
|
||||
{
|
||||
if(g_bKnifeBanned[i])
|
||||
{
|
||||
GetClientName(i, sBuffer, sizeof(sBuffer));
|
||||
IntToString(iMenuItem, sMenuItem, sizeof(sMenuItem));
|
||||
menu.AddItem(sMenuItem, sBuffer);
|
||||
iMenuItem++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu.Display(client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case(MenuAction_Select):
|
||||
{
|
||||
char sMenuItem[8];
|
||||
char sBuffer[32];
|
||||
int flag;
|
||||
menu.GetItem(selection, sMenuItem, sizeof(sMenuItem), flag, sBuffer, sizeof(sBuffer));
|
||||
OpenKnifebanlistOfTheClient(client, sBuffer);
|
||||
}
|
||||
case(MenuAction_End):
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenKnifebanlistOfTheClient(int client, char sBuffer[32])
|
||||
{
|
||||
Menu menuclient = new Menu(MenuHandler_ClientMenu);
|
||||
|
||||
char sTitle[64] = "Knifebanned client: ";
|
||||
|
||||
StrCat(sTitle, sizeof(sTitle), sBuffer);
|
||||
|
||||
int target;
|
||||
char sName[32];
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientInGame(i) && !IsFakeClient(i) && g_bKnifeBanned[i])
|
||||
{
|
||||
GetClientName(i, sName, sizeof(sName));
|
||||
|
||||
if(StrEqual(sName, sBuffer))
|
||||
{
|
||||
target = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(target, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
|
||||
Banlist.Rewind();
|
||||
|
||||
int length;
|
||||
int time;
|
||||
int history;
|
||||
char sAdmin[32];
|
||||
if(Banlist.JumpToKey(sAuth))
|
||||
{
|
||||
length = Banlist.GetNum("duration");
|
||||
time = Banlist.GetNum("time");
|
||||
history = Banlist.GetNum("history");
|
||||
Banlist.GetString("admin", sAdmin, sizeof(sAdmin));
|
||||
}
|
||||
|
||||
menuclient.SetTitle(sTitle, client);
|
||||
|
||||
char sInfo[256];
|
||||
Format(sInfo, sizeof(sInfo), "Banned by: %s", sAdmin);
|
||||
|
||||
menuclient.AddItem("0", sInfo);
|
||||
|
||||
if(length > 0)
|
||||
Format(sInfo, sizeof(sInfo), "Duration: %d Minutes", length);
|
||||
else if(length == -1)
|
||||
Format(sInfo, sizeof(sInfo), "Duration: Permanently");
|
||||
else
|
||||
Format(sInfo, sizeof(sInfo), "Duration: Temporarly");
|
||||
|
||||
menuclient.AddItem("1", sInfo);
|
||||
|
||||
char sTime[32];
|
||||
FormatTime(sTime, sizeof(sTime), "%c", time);
|
||||
Format(sInfo, sizeof(sInfo), "Date: %s", sTime);
|
||||
|
||||
menuclient.AddItem("2", sInfo);
|
||||
|
||||
Format(sInfo, sizeof(sInfo), "Ban History: %d times", history);
|
||||
|
||||
menuclient.AddItem("3", sInfo);
|
||||
|
||||
menuclient.AddItem("4", "Back to List");
|
||||
|
||||
menuclient.Display(client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public int MenuHandler_ClientMenu(Menu menuclient, MenuAction action, int client, int selection)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case(MenuAction_Select):
|
||||
{
|
||||
switch(selection)
|
||||
{
|
||||
case(4): OpenKnifebanlistMenu(client);
|
||||
}
|
||||
}
|
||||
case(MenuAction_End):
|
||||
{
|
||||
delete menuclient;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user