plugins/funvotes/voteff.sp
author Nicholas Hastings <skamonkey@gmail.com>
Fri Mar 29 12:28:02 2013 -0400 (2013-03-29)
changeset 3871 4edce76aefe3
parent 2289 44045ead61cd
permissions -rw-r--r--
Triggering build.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod Basefunvotes Plugin
     5  * Provides vote ff functionality
     6  *
     7  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     8  * =============================================================================
     9  *
    10  * This program is free software; you can redistribute it and/or modify it under
    11  * the terms of the GNU General Public License, version 3.0, as published by the
    12  * Free Software Foundation.
    13  * 
    14  * This program is distributed in the hope that it will be useful, but WITHOUT
    15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    17  * details.
    18  *
    19  * You should have received a copy of the GNU General Public License along with
    20  * this program.  If not, see <http://www.gnu.org/licenses/>.
    21  *
    22  * As a special exception, AlliedModders LLC gives you permission to link the
    23  * code of this program (as well as its derivative works) to "Half-Life 2," the
    24  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    25  * by the Valve Corporation.  You must obey the GNU General Public License in
    26  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    27  * this exception to all derivative works.  AlliedModders LLC defines further
    28  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    29  * or <http://www.sourcemod.net/license.php>.
    30  *
    31  * Version: $Id$
    32  */
    33 
    34 DisplayVoteFFMenu(client)
    35 {
    36 	if (IsVoteInProgress())
    37 	{
    38 		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
    39 		return;
    40 	}	
    41 	
    42 	if (!TestVoteDelay(client))
    43 	{
    44 		return;
    45 	}
    46 	
    47 	LogAction(client, -1, "\"%L\" initiated a friendly fire vote.", client);
    48 	ShowActivity2(client, "[SM] ", "%t", "Initiated Vote FF");
    49 	
    50 	g_voteType = voteType:ff;
    51 	g_voteInfo[VOTE_NAME][0] = '\0';
    52 	
    53 	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
    54 	
    55 	if (GetConVarBool(g_Cvar_FF))
    56 	{
    57 		SetMenuTitle(g_hVoteMenu, "Voteff Off");
    58 	}
    59 	else
    60 	{
    61 		SetMenuTitle(g_hVoteMenu, "Voteff On");
    62 	}
    63 	
    64 	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
    65 	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
    66 	SetMenuExitButton(g_hVoteMenu, false);
    67 	VoteMenuToAll(g_hVoteMenu, 20);
    68 }
    69 
    70 public AdminMenu_VoteFF(Handle:topmenu, 
    71 							  TopMenuAction:action,
    72 							  TopMenuObject:object_id,
    73 							  param,
    74 							  String:buffer[],
    75 							  maxlength)
    76 {
    77 	if (action == TopMenuAction_DisplayOption)
    78 	{
    79 		Format(buffer, maxlength, "%T", "Vote FF", param);
    80 	}
    81 	else if (action == TopMenuAction_SelectOption)
    82 	{
    83 		DisplayVoteFFMenu(param);
    84 	}
    85 	else if (action == TopMenuAction_DrawOption)
    86 	{	
    87 		/* disable this option if a vote is already running */
    88 		buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
    89 	}
    90 }
    91 
    92 public Action:Command_VoteFF(client, args)
    93 {
    94 	if (args > 0)
    95 	{
    96 		ReplyToCommand(client, "[SM] Usage: sm_voteff");
    97 		return Plugin_Handled;	
    98 	}
    99 	
   100 	DisplayVoteFFMenu(client);
   101 	
   102 	return Plugin_Handled;
   103 }