Skip to content

Commit 2d971a9

Browse files
Prevent voteban evading & add ban length cvar (#1249)
1 parent 3b38637 commit 2d971a9

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

plugins/basevotes.sp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public Plugin myinfo =
5454
Menu g_hVoteMenu = null;
5555

5656
ConVar g_Cvar_Limits[3] = {null, ...};
57+
ConVar g_Cvar_Voteban = null;
5758
//ConVar g_Cvar_VoteSay = null;
5859

5960
enum voteType
@@ -108,6 +109,7 @@ public void OnPluginStart()
108109
g_Cvar_Limits[0] = CreateConVar("sm_vote_map", "0.60", "percent required for successful map vote.", 0, true, 0.05, true, 1.0);
109110
g_Cvar_Limits[1] = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);
110111
g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);
112+
g_Cvar_Voteban = CreateConVar("sm_voteban_time", "30", "length of ban in minutes.", 0, true, 0.0);
111113

112114
AutoExecConfig(true, "basevotes");
113115

@@ -344,23 +346,32 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
344346

345347
case (ban):
346348
{
349+
if (g_voteArg[0] == '\0')
350+
{
351+
strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned");
352+
}
353+
354+
int minutes = g_Cvar_Voteban.IntValue;
355+
356+
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], minutes);
357+
347358
int voteTarget;
348359
if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0)
349360
{
350-
LogAction(-1, -1, "Vote ban failed, unable to ban \"%s\" (reason \"%s\")", g_voteInfo[VOTE_NAME], "Player no longer available");
361+
LogAction(-1, -1, "Vote ban successful, banned \"%s\" (%s) (minutes \"%d\") (reason \"%s\")", g_voteInfo[VOTE_NAME], g_voteInfo[VOTE_AUTHID], minutes, g_voteArg);
362+
363+
BanIdentity(g_voteInfo[VOTE_AUTHID],
364+
minutes,
365+
BANFLAG_AUTHID,
366+
g_voteArg,
367+
"sm_voteban");
351368
}
352369
else
353370
{
354-
if (g_voteArg[0] == '\0')
355-
{
356-
strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned");
357-
}
371+
LogAction(-1, voteTarget, "Vote ban successful, banned \"%L\" (minutes \"%d\") (reason \"%s\")", voteTarget, minutes, g_voteArg);
358372

359-
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30);
360-
LogAction(-1, voteTarget, "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", voteTarget, g_voteArg);
361-
362373
BanClient(voteTarget,
363-
30,
374+
minutes,
364375
BANFLAG_AUTO,
365376
g_voteArg,
366377
"Banned by vote",

plugins/basevotes/voteban.sp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void DisplayVoteBanMenu(int client, int target)
3636
g_voteTarget = GetClientUserId(target);
3737

3838
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
39+
GetClientAuthId(target, AuthId_Steam2, g_voteInfo[VOTE_AUTHID], sizeof(g_voteInfo[]));
3940
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
4041

4142
LogAction(client, target, "\"%L\" initiated a ban vote against \"%L\"", client, target);

0 commit comments

Comments
 (0)