Raised This Month: $51 Target: $400
 12% 

VoteBan


Post New Thread Reply   
 
Thread Tools Display Modes
Author
MockingBird
Member
Join Date: Mar 2005
Plugin ID:
936
Plugin Version:
Plugin Category:
All
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Unapprover:
    Reason for Unapproving:
    duplicates many other plugins
    Old 06-18-2009 , 05:19   VoteBan
    Reply With Quote #1

    Allows voteban functionality similar to manimod.

    Cvar:
    Code:
    sm_voteban_rate - The percentage of players needed to voteban.
    Sauce:
    Code:
    #include <sourcemod>
    #include <menus>
    #include <banning>
    #include <clients>
    
    public Plugin:myinfo =
    {
    	name = "Voteban",
    	author = "Glen Chatfield",
    	description = "Allows players to voteban other players.",
    	version = "0.0.0.1",
    	url = ""
    };
    
    new count[65]
    new choice[65]
    
    new Handle:g_BanPercentage	// Percentage needed to ban
    
    public OnPluginStart()
    {
    	g_BanPercentage = CreateConVar("sm_voteban_rate", "0.6", "The percentage of players needed to voteban.")
    
    	RegConsoleCmd("say", SayHandle, "")
    }
    
    public Action:SayHandle(index, args)
    {
    	decl String:text[192]
    	
    	GetCmdArg(1, text, sizeof(text))
    
    	if(StrEqual(text, "voteban"))
    	{
    		VoteBanMenu(index)
    	}
    }
    
    VoteBanMenu(index)
    {
    	new Handle:menu = CreateMenu(VoteBanMenuHandle)
    	SetMenuTitle(menu, "Vote Ban")
    
    	new maxPlayers = GetMaxClients()
    
    	for(new i = 1;i < maxPlayers + 1;i++)
    	{
    		if(IsClientAuthorized(i) && IsClientConnected(i))
    		{
    			decl String:name[64]
    			GetClientName(i, name, sizeof(name))
    
    			decl String:sIndex[4]
    			IntToString(i, sIndex, sizeof(sIndex))
    
    			decl String:menuItem[128]
    			Format(menuItem, sizeof(menuItem), "[%i] %s", count[i], name)
    
    			AddMenuItem(menu, sIndex, menuItem)
    		}
    	}
    
    	DisplayMenu(menu, index, 120)
    }
    
    public VoteBanMenuHandle(Handle:menu, MenuAction:action, index, selection)
    {
    	/* If an option was selected, tell the client about the item. */
    	if (action == MenuAction_Select)
    	{
    		new String:info[32]
    		new bool:found = GetMenuItem(menu, selection, info, sizeof(info))
    		if(!found)
    		{
    			PrintCenterText(index, "Error, Selection Not Found!")
    			CloseHandle(menu)
    			VoteBanMenu(index)
    			return
    		}
    
    		new i = StringToInt(info)
    
    		if(choice[index] != 0)
    		{
    			count[choice[index]]--
    		}
    
    		choice[index] = i
    		count[i]++
    
    		decl String:name[64]
    		GetClientName(i, name, sizeof(name))
    
    		new clientCount = GetClientCount()
    
    		if(clientCount <= 1)
    		{
    			PrintToChat(index, "\x04[VoteBan]\x03 There must be at least 2 people on to voteban!")
    		}
    
    		new votesNeeded = RoundFloat(float(clientCount) * GetConVarFloat(g_BanPercentage))
    
    		new votesLeft = votesNeeded - count[i]
    
    		if(votesLeft > 0)
    		{
    			PrintToChatAll("\x01\x04[VoteBan]\x03 %i more votes required to ban %s", votesLeft, name)
    		}
    		else
    		{
    			BanClient(i, 30, BANFLAG_AUTO, "Votebanned", "You have been votebanned for 30 minutes.")
    			PrintToChatAll("\x01\x04[VoteBan]\x03Player %s has been banned due to a vote.", name)
    		}
    
    		CloseHandle(menu)
    	}
    	/* If the menu was cancelled, print a message to the server about it. */
    	else if (action == MenuAction_Cancel)
    	{
    		// CloseHandle(menu)
    	}
    	/* If the menu has ended, destroy it */
    	else if (action == MenuAction_End)
    	{
    		CloseHandle(menu)
    	}
    }
    How it works:
    Players type 'voteban', and the voteban menu will be displayed, showing the current number of votes for each player next to that players name. If more than (by default) 60% of the players on the server vote a player, that player will be banned for 30 minutes. This allows players to 'self-moderate' servers when there are no admins on.
    Attached Files
    File Type: sp Get Plugin or Get Source (voteban.sp - 1070 views - 2.7 KB)

    Last edited by MockingBird; 06-18-2009 at 05:23.
    MockingBird is offline
    shustas
    SourceMod Donor
    Join Date: May 2007
    Location: London
    Old 06-18-2009 , 05:24   Re: VoteBan
    Reply With Quote #2

    There is about 2 other plugins with even more options already
    __________________
    shustas is offline
    MockingBird
    Member
    Join Date: Mar 2005
    Old 06-18-2009 , 05:26   Re: VoteBan
    Reply With Quote #3

    http://www.sourcemod.com/plugins.php...tion=&search=1

    Where? I made this as a quick fix for my server because I couldn't find a voteban plugin, and I thought I might share it.
    MockingBird is offline
    PStar
    Veteran Member
    Join Date: Mar 2008
    Old 06-18-2009 , 05:29   Re: VoteBan
    Reply With Quote #4

    For example here:
    http://forums.alliedmods.net/showthread.php?p=632031
    PStar is offline
    MockingBird
    Member
    Join Date: Mar 2005
    Old 06-18-2009 , 05:37   Re: VoteBan
    Reply With Quote #5

    W/e.

    Dont shoot me for sharing or anything.
    MockingBird is offline
    PStar
    Veteran Member
    Join Date: Mar 2008
    Old 06-18-2009 , 08:04   Re: VoteBan
    Reply With Quote #6

    Quote:
    Originally Posted by MockingBird View Post
    W/e.

    Dont shoot me for sharing or anything.
    No of course not
    Nice work bcw.
    PStar is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 20:23.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode