Prevent voteban evading & add ban length cvar (#1249)
This commit is contained in:
parent
3b386379dd
commit
2d971a9fb7
@ -54,6 +54,7 @@ public Plugin myinfo =
|
|||||||
Menu g_hVoteMenu = null;
|
Menu g_hVoteMenu = null;
|
||||||
|
|
||||||
ConVar g_Cvar_Limits[3] = {null, ...};
|
ConVar g_Cvar_Limits[3] = {null, ...};
|
||||||
|
ConVar g_Cvar_Voteban = null;
|
||||||
//ConVar g_Cvar_VoteSay = null;
|
//ConVar g_Cvar_VoteSay = null;
|
||||||
|
|
||||||
enum voteType
|
enum voteType
|
||||||
@ -108,6 +109,7 @@ public void OnPluginStart()
|
|||||||
g_Cvar_Limits[0] = CreateConVar("sm_vote_map", "0.60", "percent required for successful map vote.", 0, true, 0.05, true, 1.0);
|
g_Cvar_Limits[0] = CreateConVar("sm_vote_map", "0.60", "percent required for successful map vote.", 0, true, 0.05, true, 1.0);
|
||||||
g_Cvar_Limits[1] = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);
|
g_Cvar_Limits[1] = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);
|
||||||
g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);
|
g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);
|
||||||
|
g_Cvar_Voteban = CreateConVar("sm_voteban_time", "30", "length of ban in minutes.", 0, true, 0.0);
|
||||||
|
|
||||||
AutoExecConfig(true, "basevotes");
|
AutoExecConfig(true, "basevotes");
|
||||||
|
|
||||||
@ -344,23 +346,32 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
|
|
||||||
case (ban):
|
case (ban):
|
||||||
{
|
{
|
||||||
|
if (g_voteArg[0] == '\0')
|
||||||
|
{
|
||||||
|
strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned");
|
||||||
|
}
|
||||||
|
|
||||||
|
int minutes = g_Cvar_Voteban.IntValue;
|
||||||
|
|
||||||
|
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], minutes);
|
||||||
|
|
||||||
int voteTarget;
|
int voteTarget;
|
||||||
if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0)
|
if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0)
|
||||||
{
|
{
|
||||||
LogAction(-1, -1, "Vote ban failed, unable to ban \"%s\" (reason \"%s\")", g_voteInfo[VOTE_NAME], "Player no longer available");
|
LogAction(-1, -1, "Vote ban successful, banned \"%s\" (%s) (minutes \"%d\") (reason \"%s\")", g_voteInfo[VOTE_NAME], g_voteInfo[VOTE_AUTHID], minutes, g_voteArg);
|
||||||
|
|
||||||
|
BanIdentity(g_voteInfo[VOTE_AUTHID],
|
||||||
|
minutes,
|
||||||
|
BANFLAG_AUTHID,
|
||||||
|
g_voteArg,
|
||||||
|
"sm_voteban");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (g_voteArg[0] == '\0')
|
LogAction(-1, voteTarget, "Vote ban successful, banned \"%L\" (minutes \"%d\") (reason \"%s\")", voteTarget, minutes, g_voteArg);
|
||||||
{
|
|
||||||
strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned");
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30);
|
|
||||||
LogAction(-1, voteTarget, "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", voteTarget, g_voteArg);
|
|
||||||
|
|
||||||
BanClient(voteTarget,
|
BanClient(voteTarget,
|
||||||
30,
|
minutes,
|
||||||
BANFLAG_AUTO,
|
BANFLAG_AUTO,
|
||||||
g_voteArg,
|
g_voteArg,
|
||||||
"Banned by vote",
|
"Banned by vote",
|
||||||
|
@ -36,6 +36,7 @@ void DisplayVoteBanMenu(int client, int target)
|
|||||||
g_voteTarget = GetClientUserId(target);
|
g_voteTarget = GetClientUserId(target);
|
||||||
|
|
||||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||||
|
GetClientAuthId(target, AuthId_Steam2, g_voteInfo[VOTE_AUTHID], sizeof(g_voteInfo[]));
|
||||||
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
|
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
|
||||||
|
|
||||||
LogAction(client, target, "\"%L\" initiated a ban vote against \"%L\"", client, target);
|
LogAction(client, target, "\"%L\" initiated a ban vote against \"%L\"", client, target);
|
||||||
|
Loading…
Reference in New Issue
Block a user