mapchooser_extended: remove nativevotes (nobody uses that shit)
This commit is contained in:
		
							parent
							
								
									83cab5941a
								
							
						
					
					
						commit
						a7a4acdcc4
					
				@ -1,915 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * vim: set ts=4 :
 | 
			
		||||
 * =============================================================================
 | 
			
		||||
 * NativeVotes
 | 
			
		||||
 * Copyright (C) 2011-2013 Ross Bemrose (Powerlord).  All rights reserved.
 | 
			
		||||
 * =============================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify it under
 | 
			
		||||
 * the terms of the GNU General Public License, version 3.0, as published by the
 | 
			
		||||
 * Free Software Foundation.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, but WITHOUT
 | 
			
		||||
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 | 
			
		||||
 * details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License along with
 | 
			
		||||
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 *
 | 
			
		||||
 * As a special exception, AlliedModders LLC gives you permission to link the
 | 
			
		||||
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 | 
			
		||||
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 | 
			
		||||
 * by the Valve Corporation.  You must obey the GNU General Public License in
 | 
			
		||||
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 | 
			
		||||
 * this exception to all derivative works.  AlliedModders LLC defines further
 | 
			
		||||
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 | 
			
		||||
 * or <http://www.sourcemod.net/license.php>.
 | 
			
		||||
 *
 | 
			
		||||
 * Version: $Id$
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <menus>
 | 
			
		||||
#include <sourcemod>
 | 
			
		||||
 | 
			
		||||
// NativeVotes 0.8 series
 | 
			
		||||
 | 
			
		||||
#if defined _nativevotes_included
 | 
			
		||||
 #endinput
 | 
			
		||||
#endif
 | 
			
		||||
#define _nativevotes_included
 | 
			
		||||
 | 
			
		||||
#define CLIENT_DISCONNECTED			-1
 | 
			
		||||
 | 
			
		||||
#define NATIVEVOTES_EXTEND 			"Extend current Map" /** Defined in TF2, but doesn't appear to be localized */
 | 
			
		||||
 | 
			
		||||
#define NATIVEVOTES_ALL_TEAMS		-1 // Defined by TF2, may be the same in L4D/L4D2
 | 
			
		||||
#define NATIVEVOTES_TF2_ALL_TEAMS	0 // Defined by TF2, may be the same in L4D/L4D2
 | 
			
		||||
#define NATIVEVOTES_TEAM_UNASSIGNED 0 // For completeness, do not otherwise use
 | 
			
		||||
#define NATIVEVOTES_TEAM_SPECTATOR	1 // Spectators
 | 
			
		||||
#define NATIVEVOTES_TEAM_1			2 // RED/Survivors/Terrorists
 | 
			
		||||
#define NATIVEVOTES_TEAM_2			3 // BLU/Infected/Counter-Terrorists
 | 
			
		||||
 | 
			
		||||
#define NATIVEVOTES_SERVER_INDEX 	99 // Defined by TF2, may be the same in L4D/L4D2
 | 
			
		||||
 | 
			
		||||
// These may seem backwards, but this is the order that the votes appear in the vote screen
 | 
			
		||||
#define NATIVEVOTES_VOTE_INVALID	-1		/**< Vote was invalid, currently only valid internally */
 | 
			
		||||
#define NATIVEVOTES_VOTE_YES		0		/**< Vote was yes */
 | 
			
		||||
#define NATIVEVOTES_VOTE_NO			1		/**< Vote was no */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
The following MenuActions are supported.  Arguments are also listed, as they differ slightly from the default
 | 
			
		||||
MenuAction_Start		A menu has been started (nothing passed). Only exists for compat reasons.
 | 
			
		||||
MenuAction_Display		A menu is about to be displayed (param1=client). If you choose to change the vote text,
 | 
			
		||||
 						To change the text, use RedrawVoteTitle()
 | 
			
		||||
						If you do so, return 1 or _:Plugin_Changed  Otherwise, return _:Plugin_Continue or 0.
 | 
			
		||||
MenuAction_Select		An item was selected (param1=client, param2=item). For subplugin support.
 | 
			
		||||
MenuAction_End			A vote has fully ended and the vote object is ready to be cleaned up
 | 
			
		||||
						param1 is MenuEnd reason, either MenuEnd_VotingCancelled or MenuEnd_VotingDone
 | 
			
		||||
MenuAction_VoteEnd		A vote sequence has succeeded (param1=chosen item)
 | 
			
		||||
						This is not called if NativeVotes_SetResultCallback has been used on the vote.
 | 
			
		||||
						You should call NativeVotes_DisplayPass or NativeVotes_DisplayPassEx after this
 | 
			
		||||
MenuAction_VoteStart	A vote sequence has started (nothing passed).  Use this instead of MenuAction_Start
 | 
			
		||||
MenuAction_VoteCancel	A vote sequence has been cancelled (param1=reason)
 | 
			
		||||
MenuAction_DisplayItem	Item text is being drawn to the display (param1=client, param2=item)
 | 
			
		||||
						To change the text, use RedrawVoteItem().
 | 
			
		||||
						If you do so, return 1 or _:Plugin_Changed.  Otherwise, return _:Plugin_Continue or 0.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#define NATIVEVOTES_ACTIONS_DEFAULT		MenuAction_VoteStart|MenuAction_VoteCancel|MenuAction_VoteEnd|MenuAction_End
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Vote types. These are mapped to translation strings and pass strings by VoteStart and VotePass handlers
 | 
			
		||||
 */
 | 
			
		||||
enum NativeVotesType
 | 
			
		||||
{
 | 
			
		||||
	NativeVotesType_None = 0,		/** Special placeholder for callvote with no arguments for NativeVotes_OnCallVote */
 | 
			
		||||
	NativeVotesType_Custom_YesNo,	/**< Yes/No, details are vote text. */
 | 
			
		||||
	NativeVotesType_Custom_Mult,	/**< TF2/CS:GO: Multiple-choice, details are vote text. */
 | 
			
		||||
	NativeVotesType_ChgCampaign,	/**< L4D/L4D2: Yes/No, details are campaign name */
 | 
			
		||||
	NativeVotesType_ChgDifficulty,	/**< L4D/L4D2: Yes/No, details are difficulty number in L4D/L4D2 */
 | 
			
		||||
	NativeVotesType_ReturnToLobby,	/**< L4D/L4D2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_AlltalkOn,		/**< L4D2: Yes/No, details are ignored (handled internally by extension) */
 | 
			
		||||
	NativeVotesType_AlltalkOff,		/**< L4D2: Yes/No, details are ignored (handled internally by extension) */
 | 
			
		||||
	NativeVotesType_Restart,		/**< Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_Kick,			/**< Yes/No, target is player userid, details are auto-set by target */
 | 
			
		||||
	NativeVotesType_KickIdle,		/**< TF2/CS:GO: Yes/No, target is player userid, details are auto-set by target */
 | 
			
		||||
	NativeVotesType_KickScamming,	/**< TF2/CS:GO: Yes/No, target is player userid, details are auto-set by target */
 | 
			
		||||
	NativeVotesType_KickCheating,	/**< TF2/CS:GO: Yes/No, target is player userid, details are auto-set by target */
 | 
			
		||||
	NativeVotesType_ChgLevel,		/**< Yes/No, details are level number in L4D/L4D2 or map name in TF2 */
 | 
			
		||||
	NativeVotesType_NextLevel,		/**< TF2/CS:GO: Yes/No, details are map name */
 | 
			
		||||
	NativeVotesType_NextLevelMult,	/**< TF2/CS:GO: Multiple-choice, details are ignored */
 | 
			
		||||
	NativeVotesType_ScrambleNow,	/**< TF2/CS:GO: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_ScrambleEnd,	/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_ChgMission,		/**< TF2: Yes/No, details are popfile */
 | 
			
		||||
	NativeVotesType_SwapTeams,		/**< CS:GO: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_Surrender,		/**< CS:GO: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_Rematch,		/**< CS:GO: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_Continue,		/**< CS:GO: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_StartRound,		/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_Eternaween,		/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_AutoBalanceOn,	/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_AutoBalanceOff,	/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_ClassLimitsOn,	/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesType_ClassLimitsOff,	/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum NativeVotesPassType
 | 
			
		||||
{
 | 
			
		||||
	NativeVotesPass_None = 0,			/**< Special placeholder for error value */
 | 
			
		||||
	NativeVotesPass_Custom,				/**< Details are custom pass message */
 | 
			
		||||
	NativeVotesPass_ChgCampaign,		/**< L4D/L4D2: Details are campaign name */
 | 
			
		||||
	NativeVotesPass_ChgDifficulty,		/**< L4D/L4D2/TF2: Details are difficulty number in L4D/L4D2 and mission name in TF2 */
 | 
			
		||||
	NativeVotesPass_ReturnToLobby,      /**< L4D/L4D2: Details are ignored */
 | 
			
		||||
	NativeVotesPass_AlltalkOn,			/**< L4D2: Details are ignored */
 | 
			
		||||
	NativeVotesPass_AlltalkOff,			/**< L4D2: Details are ignored */
 | 
			
		||||
	NativeVotesPass_Restart,			/**< Details are ignored */
 | 
			
		||||
	NativeVotesPass_Kick,				/**< Details are player name */
 | 
			
		||||
	NativeVotesPass_ChgLevel,			/**< Details are level number in L4D/L4D2 or map name in TF2/CS:GO */
 | 
			
		||||
	NativeVotesPass_NextLevel,			/**< TF2/CS:GO: Details are map name */
 | 
			
		||||
	NativeVotesPass_Extend,				/**< TF2/CS:GO: Details are ignored */
 | 
			
		||||
	NativeVotesPass_Scramble,			/**< TF2/CS:GO: Details are ignored */
 | 
			
		||||
	NativeVotesPass_ChgMission,			/**< TF2: Details are popfile */
 | 
			
		||||
	NativeVotesPass_SwapTeams,			/**< CS:GO: Details are ignored */
 | 
			
		||||
	NativeVotesPass_Surrender,			/**< CS:GO: Details are ignored */
 | 
			
		||||
	NativeVotesPass_Rematch,			/**< CS:GO: Details are ignored */
 | 
			
		||||
	NativeVotesPass_Continue,			/**< CS:GO: Details are ignored */
 | 
			
		||||
	NativeVotesPass_StartRound,			/**< TF2: Details are ignored */
 | 
			
		||||
	NativeVotesPass_Eternaween,			/**< TF2: Details are ignored */
 | 
			
		||||
	NativeVotesPass_AutoBalanceOn,		/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesPass_AutoBalanceOff,		/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesPass_ClassLimitsOn,		/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
	NativeVotesPass_ClassLimitsOff,		/**< TF2: Yes/No, details are ignored */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reasons a vote was canceled.  Not used for L4D/L4D2, as they don't care
 | 
			
		||||
 */
 | 
			
		||||
enum NativeVotesFailType
 | 
			
		||||
{
 | 
			
		||||
	NativeVotesFail_Generic = 0,		/**< Vote was generically cancelled. */
 | 
			
		||||
	NativeVotesFail_Loses = 3,			/**< No votes outnumbered Yes votes */
 | 
			
		||||
	NativeVotesFail_NotEnoughVotes = 4,	/**< Vote did not receive enough votes. */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reasons a callvote command failed.
 | 
			
		||||
 * This is provided as a convenience to plugin authors as it's not strictly part of the vote system
 | 
			
		||||
 */
 | 
			
		||||
enum NativeVotesCallFailType
 | 
			
		||||
{
 | 
			
		||||
	NativeVotesCallFail_Generic = 0,			/**< Generic fail. */
 | 
			
		||||
	NativeVotesCallFail_Loading = 1,			/**< L4D/L4D2: Players are still loading. */
 | 
			
		||||
	NativeVotesCallFail_Recent = 2,				/**< TF2/CS:GO: You can't call another vote yet: Argument is seconds until you can call another vote. */
 | 
			
		||||
	NativeVotesCallFail_Disabled = 5,			/**< TF2/CS:GO: Server has disabled that issue. */
 | 
			
		||||
	NativeVotesCallFail_MapNotFound = 6,		/**< TF2/CS:GO: Server does not have that map. */
 | 
			
		||||
	NativeVotesCallFail_SpecifyMap = 7,			/**< TF2/CS:GO: You must specify a map. */
 | 
			
		||||
	NativeVotesCallFail_Failed = 8,				/**< TF2/CS:GO: This vote failed recently. */
 | 
			
		||||
	NativeVotesCallFail_WrongTeam = 9,			/**< TF2/CS:GO: Team can't call this vote. */
 | 
			
		||||
	NativeVotesCallFail_Waiting = 10,			/**< TF2/CS:GO: Vote can't be called during Waiting For Players. */
 | 
			
		||||
	NativeVotesCallFail_PlayerNotFound = 11,	/**< TF2/CS:GO: Player to kick can't be found. Buggy in TF2. */
 | 
			
		||||
	NativeVotesCallFail_Unknown = 11,
 | 
			
		||||
	NativeVotesCallFail_CantKickAdmin = 12,		/**< TF2/CS:GO: Can't kick server admin. */
 | 
			
		||||
	NativeVotesCallFail_ScramblePending = 13,	/**< TF2/CS:GO: Team Scramble is pending.. */
 | 
			
		||||
	NativeVotesCallFail_Spectators = 14,		/**< TF2/CS:GO: Spectators aren't allowed to call votes. */
 | 
			
		||||
	NativeVotesCallFail_LevelSet = 15,			/**< TF2/CS:GO: Next level already set. */
 | 
			
		||||
	NativeVotesCallFail_MapNotValid = 16,		/**< ???: Map is invalid. */
 | 
			
		||||
	NativeVotesCallFail_KickTime = 17,			/**< ???: Cannot kick for time. */
 | 
			
		||||
	NativeVotesCallFail_KickDuringRound = 18,	/**< ???: Cannot kick during a round. */
 | 
			
		||||
	NativeVotesCallFail_AlreadyActive = 19		/**< TF2: Cannot call vote because modification (Eternaween) is already active (may not work) */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Is a specific vote type supported by this game?
 | 
			
		||||
 *
 | 
			
		||||
 * @param voteType			Vote type
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_IsVoteTypeSupported(NativeVotesType:voteType);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Creates a new, empty vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param handler			Function which will receive vote actions.
 | 
			
		||||
 * @param voteType			Vote type, cannot be changed after set
 | 
			
		||||
 * @param actions			Optionally set which actions to receive.  Start,
 | 
			
		||||
 *							Cancel, and End will always be received regardless
 | 
			
		||||
 *							of whether they are set or not.  They are also
 | 
			
		||||
 *							the only default actions.
 | 
			
		||||
 * @return					A new vote Handle on INVALID_HANDLE if a vote type is unsupported by this game.
 | 
			
		||||
 */
 | 
			
		||||
native Handle:NativeVotes_Create(MenuHandler:handler, NativeVotesType:voteType,
 | 
			
		||||
							MenuAction:actions=NATIVEVOTES_ACTIONS_DEFAULT);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Frees all handles related to a vote.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS MUST BE CALLED TO AVOID HANDLE LEAKS
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote handle
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
native Handle:NativeVotes_Close(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Appends a new item to the end of a vote.  Only valid for Multiple Choice votes
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				NativeVotes Handle.
 | 
			
		||||
 * @param info				Item information string.
 | 
			
		||||
 * @return					True on success, false on failure.
 | 
			
		||||
 * @error					Invalid Handle, item limit reached, or if the vote is not multiple choice.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_AddItem(Handle:vote, const String:info[], const String:display[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Inserts an item into the menu before a certain position; the new item will
 | 
			
		||||
 * be at the given position and all next items pushed forward.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param position			Position, starting from 0.
 | 
			
		||||
 * @param info				Item information string.
 | 
			
		||||
 * @return					True on success, false on failure.
 | 
			
		||||
 * @error					Invalid Handle or vote position, or if the vote is not multiple choice.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_InsertItem(Handle:vote, position, const String:info[], const String:display[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Removes an item from the menu.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param position			Position, starting from 0.
 | 
			
		||||
 * @return					True on success, false on failure.
 | 
			
		||||
 * @error					Invalid Handle or vote position,  or if the vote is not multiple choice.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_RemoveItem(Handle:vote, position);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Removes all items from a vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle or vote position, or if the vote is not multiple choice.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_RemoveAllItems(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Retrieves information about a vote item.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param position			Position, starting from 0.
 | 
			
		||||
 * @param infoBuf			Info buffer.
 | 
			
		||||
 * @param infoBufLen		Maximum length of the info buffer.
 | 
			
		||||
 * @return					True on success, false if position is invalid.
 | 
			
		||||
 * @error					Invalid Handlem
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_GetItem(Handle:vote,
 | 
			
		||||
						position,
 | 
			
		||||
						String:infoBuf[],
 | 
			
		||||
						infoBufLen,
 | 
			
		||||
						String:dispBuf[]="",
 | 
			
		||||
						dispBufLen=0);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns the number of items in a vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @return					Number of items in the vote.
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetItemCount(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sets the vote's details for votes that support details
 | 
			
		||||
 * If this is a custom vote, use NativeVotes_SetTitle to set the vote's title.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param argument			Details string. See vote types for what details stands for.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetDetails(Handle:vote, const String:argument[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns the text of a vote's details if set.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param buffer			Buffer to store details.
 | 
			
		||||
 * @param maxlength			Maximum length of the buffer.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetDetails(Handle:vote, String:buffer[], maxlength);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sets a custom vote's title
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param title			 	Vote title string.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetTitle(Handle:vote, const String:argument[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Return the vote's Title.
 | 
			
		||||
 * If not set, returns Details instead.
 | 
			
		||||
 *     This behavior is for compatibility with NativeVotes 0.8.0 and below.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param buffer			Buffer to store title.
 | 
			
		||||
 * @param maxlength			Maximum length of the buffer.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetTitle(Handle:vote, String:buffer[], maxlength);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sets the target userid for vote
 | 
			
		||||
 * This should be used instead of SetArgument for votes that target players
 | 
			
		||||
 *
 | 
			
		||||
 * Also sets target SteamID
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param userid			Client index of target player
 | 
			
		||||
 * @param setDetails		If true, also sets vote details to client's name
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetTarget(Handle:vote, client, bool:setDetails=true);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns the userid of a vote's target
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @return					Client index of target player or 0 for no target or target disconnected since vote started
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetTarget(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the Steam ID of a vote's target
 | 
			
		||||
 * Useful if the target has disconnect from the server during a vote.
 | 
			
		||||
 * This was added in specifically for Kick/Ban votes
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param buffer			Buffer to store steamId.  Should be 19 characters or more..
 | 
			
		||||
 * @param maxlength			Maximum length of the buffer.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetTargetSteam(Handle:vote, String:buffer[], maxlength);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns whether a vote is in progress.
 | 
			
		||||
 *
 | 
			
		||||
 * @return					True if a NativeVotes vote is in progress, false otherwise.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_IsVoteInProgress();
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns a style's maximum items
 | 
			
		||||
 *
 | 
			
		||||
 * @return Maximum items
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetMaxItems();
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sets a vote's option flags.
 | 
			
		||||
 *
 | 
			
		||||
 * If a certain bit is not supported, it will be stripped before being set.
 | 
			
		||||
 *
 | 
			
		||||
 * NOTE: This is currently unused, but reserved for future use.
 | 
			
		||||
 *
 | 
			
		||||
 * @param menu				Builtin Vote Handle.
 | 
			
		||||
 * @param flags				A new bitstring of VOTEFLAG bits.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetOptionFlags(Handle:vote, flags);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Retrieves a menu's option flags.
 | 
			
		||||
 *
 | 
			
		||||
 * NOTE: This is currently unused, but reserved for future use.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Builtin Vote Handle.
 | 
			
		||||
 * @return					A bitstring of VOTEFLAG bits.
 | 
			
		||||
 * @error					Invalid Handle.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetOptionFlags(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Cancels the vote in progress.
 | 
			
		||||
 *
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					If no vote is in progress.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_Cancel();
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Callback for when a vote has ended and results are available.
 | 
			
		||||
 *
 | 
			
		||||
 * Due to SourceMod Forward limitations in plugins, multi-dimension arrays can't be passed
 | 
			
		||||
 * to forwards.  This means we have to split the client_info and item_info arrays into
 | 
			
		||||
 * their components.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				The vote being voted on.
 | 
			
		||||
 * @param num_votes			Number of votes tallied in total.
 | 
			
		||||
 * @param num_clients		Number of clients who could vote.
 | 
			
		||||
 * @param client_indexes	Array of client indexes. Parallel with client_votes.
 | 
			
		||||
 * @param client_votes		Array of client votes. Parallel with client_indexes.
 | 
			
		||||
 * @param num_items			Number of unique items that were selected.
 | 
			
		||||
 * @param item_indexes		Array of vote item indexes. Parallel with item_votes..
 | 
			
		||||
 * @param item_votes		Array of vote vote counts. Parallel with item_indexes.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
typedef NativeVotes_VoteHandler = function int (Handle vote,
 | 
			
		||||
							int num_votes,
 | 
			
		||||
							int num_clients,
 | 
			
		||||
							const int[] client_indexes,
 | 
			
		||||
							const int[] client_votes,
 | 
			
		||||
							int num_items,
 | 
			
		||||
							const int[] item_indexes,
 | 
			
		||||
							const int[] item_votes);
 | 
			
		||||
/**
 | 
			
		||||
 * Function to convert client/vote arrays into their two-dimensional versions,
 | 
			
		||||
 * which can then be passed to a standard vote handler.
 | 
			
		||||
 *
 | 
			
		||||
 * client_info and item_info are the resulting arrays.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: When declaring client_info and item_info, you'll probably want to declare them like this:
 | 
			
		||||
 * new client_info[num_clients][2];
 | 
			
		||||
 * new item_info[num_items][2];
 | 
			
		||||
 *
 | 
			
		||||
 * @param num_clients		Number of clients who could vote.
 | 
			
		||||
 * @param client_indexes	Array of client indexes. Parallel with client_votes.
 | 
			
		||||
 * @param client_votes		Array of client votes. Parallel with client_indexes.
 | 
			
		||||
 * @param num_items			Number of unique items that were selected.
 | 
			
		||||
 * @param item_indexes		Array of vote item indexes. Parallel with item_votes..
 | 
			
		||||
 * @param item_votes		Array of vote vote counts. Parallel with item_indexes.
 | 
			
		||||
 * @param client_info		Array of clients.  Use VOTEINFO_CLIENT_ defines.
 | 
			
		||||
 * @param item_info			Array of items, sorted by count.  Use VOTEINFO_ITEM
 | 
			
		||||
 *							defines.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
stock NativeVotes_FixResults(num_clients,
 | 
			
		||||
							const client_indexes[],
 | 
			
		||||
							const client_votes[],
 | 
			
		||||
							num_items,
 | 
			
		||||
							const item_indexes[],
 | 
			
		||||
							const item_votes[],
 | 
			
		||||
							client_info[][],
 | 
			
		||||
							item_info[][])
 | 
			
		||||
{
 | 
			
		||||
	for (new i = 0; i < num_clients; ++i)
 | 
			
		||||
	{
 | 
			
		||||
		client_info[i][VOTEINFO_CLIENT_INDEX] = client_indexes[i];
 | 
			
		||||
		client_info[i][VOTEINFO_CLIENT_ITEM] = client_votes[i];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (new i = 0; i < num_items; ++i)
 | 
			
		||||
	{
 | 
			
		||||
		item_info[i][VOTEINFO_ITEM_INDEX] = item_indexes[i];
 | 
			
		||||
		item_info[i][VOTEINFO_ITEM_VOTES] = item_votes[i];
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sets an advanced vote handling callback.  If this callback is set,
 | 
			
		||||
 * MenuAction_VoteEnd will not be called.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				NativeVotes Handle.
 | 
			
		||||
 * @param callback			Callback function.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle or callback.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetResultCallback(Handle:vote, NativeVotes_VoteHandler:callback);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns the number of seconds you should "wait" before displaying
 | 
			
		||||
 * a public vote.  This number is the time remaining until
 | 
			
		||||
 * (last_vote + sm_vote_delay).
 | 
			
		||||
 *
 | 
			
		||||
 * @return					Number of seconds to wait, or 0 for none.
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_CheckVoteDelay();
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns whether a client is in the pool of clients allowed
 | 
			
		||||
 * to participate in the current vote.  This is determined by
 | 
			
		||||
 * the client list passed to NativeVotes_Display().
 | 
			
		||||
 *
 | 
			
		||||
 * @param client			Client index.
 | 
			
		||||
 * @return					True if client is allowed to vote, false otherwise.
 | 
			
		||||
 * @error					If no vote is in progress or client index is invalid.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_IsClientInVotePool(client);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Redraws the current vote to a client in the voting pool.
 | 
			
		||||
 *
 | 
			
		||||
 * @param client			Client index.
 | 
			
		||||
 * @param revotes			True to allow revotes, false otherwise.
 | 
			
		||||
 * @return					True on success, false if the client is in the vote pool
 | 
			
		||||
 *							but cannot vote again.
 | 
			
		||||
 * @error					No vote in progress, client is not in the voting pool,
 | 
			
		||||
 *							or client index is invalid.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_RedrawClientVote(client, bool:revotes=true);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Retrieve the vote type
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				NativeVotes Handle.
 | 
			
		||||
 * @return					The built in vote type
 | 
			
		||||
 * @error					Invalid Handle
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotesType:NativeVotes_GetType(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Set the team this vote is for, or NATIVEVOTES_ALL_TEAMS for all teams.
 | 
			
		||||
 *
 | 
			
		||||
 * Defaults to NATIVEVOTES_ALL_TEAMS if not explicitly set.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				NativeVotes Handle.
 | 
			
		||||
 * @param team				Team number this vote is for
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetTeam(Handle:vote, team);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Retrieve the team this vote is for
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				NativeVotes Handle.
 | 
			
		||||
 * @return					Team index or NATIVEVOTES_ALL_TEAMS for all teams.
 | 
			
		||||
 * @error					Invalid Handle
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetTeam(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Set the client index of the player who initiated the vote.
 | 
			
		||||
 * Use NATIVEVOTES_SERVER_INDEX if initiated by the server itself.
 | 
			
		||||
 *
 | 
			
		||||
 * Defaults to NATIVEVOTES_SERVER_INDEX if not explicitly set.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				NativeVotes Handle.
 | 
			
		||||
 * @param client			Client who initiated the vote or NATIVEVOTES_SERVER_INDEX
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 * @error					Invalid Handle
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_SetInitiator(Handle:vote, client);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Retrieve the client index of the player who initiated the vote or NATIVEVOTES_SERVER_INDEX if
 | 
			
		||||
 * initiated by the server itself.
 | 
			
		||||
 *
 | 
			
		||||
 * @param					Vote handle
 | 
			
		||||
 * @return					Client index or NATIVEVOTES_SERVER_INDEX
 | 
			
		||||
 * @error					Invalid Handle
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_GetInitiator(Handle:vote);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Broadcasts a vote to a list of clients.  The most selected item will be
 | 
			
		||||
 * returned through MenuAction_VoteEnd.  On a tie, a random item will be returned
 | 
			
		||||
 * from a list of the tied items.
 | 
			
		||||
 *
 | 
			
		||||
 * Note that MenuAction_VoteStart, MenuAction_VoteCancel, MenuAction_VoteEnd, and MenuAction_End are all
 | 
			
		||||
 * default callbacks and do not need to be enabled.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param clients			Array of clients to broadcast to.
 | 
			
		||||
 * @param numClients		Number of clients in the array.
 | 
			
		||||
 * @param time				Maximum time to leave menu on the screen.
 | 
			
		||||
 * @return					True on success, false if a vote is already in progress.
 | 
			
		||||
 * @error					Invalid Handle, or a vote is already in progress.
 | 
			
		||||
 */
 | 
			
		||||
native bool:NativeVotes_Display(Handle:vote, clients[], numClients, time);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sends a vote menu to all clients.  See NativeVotes_Display() for more information.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param time				Maximum time to leave menu on the screen.
 | 
			
		||||
 * @return					True on success, false if this menu already has a vote session
 | 
			
		||||
 *							in progress.
 | 
			
		||||
 * @error					Invalid Handle, or a vote is already in progress.
 | 
			
		||||
 */
 | 
			
		||||
stock bool:NativeVotes_DisplayToAll(Handle:vote, time)
 | 
			
		||||
{
 | 
			
		||||
	new total = 0;
 | 
			
		||||
	decl players[MaxClients];
 | 
			
		||||
 | 
			
		||||
	for (new i=1; i<=MaxClients; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (!IsClientInGame(i) || IsFakeClient(i))
 | 
			
		||||
		{
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		players[total++] = i;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NativeVotes_Display(vote, players, total, time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sends a vote menu to a single team.  See NativeVotes_Display() for more information.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param team				Team to send vote to. 1 = spectators, 2 = RED/Survivors/Terrorists, 3 = BLU/Infected/Counter-Terrorists
 | 
			
		||||
 * @param time				Maximum time to leave menu on the screen.
 | 
			
		||||
 * @return					True on success, false if this menu already has a vote session
 | 
			
		||||
 *							in progress.
 | 
			
		||||
 * @error					Invalid Handle, or a vote is already in progress.
 | 
			
		||||
 */
 | 
			
		||||
stock bool:NativeVotes_DisplayToTeam(Handle:vote, team, time)
 | 
			
		||||
{
 | 
			
		||||
	NativeVotes_SetTeam(vote, team);
 | 
			
		||||
 | 
			
		||||
	new total;
 | 
			
		||||
	decl players[MaxClients];
 | 
			
		||||
 | 
			
		||||
	for (new i=1; i<=MaxClients; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (!IsClientInGame(i) || IsFakeClient(i) || (GetClientTeam(i) != team))
 | 
			
		||||
		{
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		players[total++] = i;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NativeVotes_Display(vote, players, total, time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sends a vote menu to all clients who are not spectators or waiting to choose a team.  See NativeVotes_Display() for more information.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote Handle.
 | 
			
		||||
 * @param time				Maximum time to leave menu on the screen.
 | 
			
		||||
 * @return					True on success, false if this menu already has a vote session
 | 
			
		||||
 *							in progress.
 | 
			
		||||
 * @error					Invalid Handle, or a vote is already in progress.
 | 
			
		||||
 */
 | 
			
		||||
stock bool:NativeVotes_DisplayToAllNonSpectators(Handle:vote, time)
 | 
			
		||||
{
 | 
			
		||||
	new total;
 | 
			
		||||
	decl players[MaxClients];
 | 
			
		||||
 | 
			
		||||
	for (new i=1; i<=MaxClients; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (!IsClientInGame(i) || IsFakeClient(i) || (GetClientTeam(i) < 2))
 | 
			
		||||
		{
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		players[total++] = i;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NativeVotes_Display(vote, players, total, time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Display vote passed screen
 | 
			
		||||
 *
 | 
			
		||||
 * You MUST call one of the NativeVotesDisplayPass* or NativeVotes_DisplayFail functions
 | 
			
		||||
 * to hide the vote screen for users who didn't vote, and to clear out their selection
 | 
			
		||||
 * for the next vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote handle
 | 
			
		||||
 * @param details			Normally the item that won the vote or format string. Also used for custom vote winners
 | 
			
		||||
 * @param ...				Variable number of format parameters.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_DisplayPass(Handle:vote, const String:details[]="");
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Display vote passed screen with custom text to a single user
 | 
			
		||||
 *
 | 
			
		||||
 * You MUST call one of the NativeVotesDisplayPass* or NativeVotes_DisplayFail functions
 | 
			
		||||
 * to hide the vote screen for users who didn't vote, and to clear out their selection
 | 
			
		||||
 * for the next vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote handle
 | 
			
		||||
 * @param client			client to display to
 | 
			
		||||
 * @param format			A format string.
 | 
			
		||||
 * @param any				Variable number of format parameters
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_DisplayPassCustomToOne(Handle:vote, client, const String:format[], any:...);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Display vote passed screen with custom text
 | 
			
		||||
 *
 | 
			
		||||
 * You MUST call one of the NativeVotesDisplayPass* or NativeVotes_DisplayFail functions
 | 
			
		||||
 * to hide the vote screen for users who didn't vote, and to clear out their selection
 | 
			
		||||
 * for the next vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param vote				Vote handle
 | 
			
		||||
 * @param format			A format string.
 | 
			
		||||
 * @param any				Variable number of format parameters
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
stock NativeVotes_DisplayPassCustom(Handle:vote, const String:format[], any:...)
 | 
			
		||||
{
 | 
			
		||||
	decl String:buffer[192];
 | 
			
		||||
 | 
			
		||||
	for (new i = 1; i <= MaxClients; ++i)
 | 
			
		||||
	{
 | 
			
		||||
		if (IsClientInGame(i))
 | 
			
		||||
		{
 | 
			
		||||
			SetGlobalTransTarget(i);
 | 
			
		||||
			VFormat(buffer, sizeof(buffer), format, 3);
 | 
			
		||||
			NativeVotes_DisplayPassCustomToOne(vote, i, "%s", buffer);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Display vote passed screen with a custom type.
 | 
			
		||||
 *
 | 
			
		||||
 * A sample usage of this would be if Extend won an RTV vote: NativeVotes_DisplayPassEx(vote, NativeVotesPass_Extend, map);
 | 
			
		||||
 *
 | 
			
		||||
 * You MUST call one of NativeVotes_DisplayPass, NativeVotes_DisplayPassEx,
 | 
			
		||||
 * or NativeVotes_DisplayFail to hide the vote screen for users who didn't vote
 | 
			
		||||
 * and to clear out their selection for the next vote.
 | 
			
		||||
 *
 | 
			
		||||
 * #param vote				Vote handle
 | 
			
		||||
 * @param passType			The pass screen to display
 | 
			
		||||
 * @param details			Normally the item that won the vote. Also used for custom vote winners
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_DisplayPassEx(Handle:vote, NativeVotesPassType:passType, const String:details[]="");
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Display failure screen.
 | 
			
		||||
 *
 | 
			
		||||
 * You MUST call one of NativeVotes_DisplayPass, NativeVotes_DisplayPassEx,
 | 
			
		||||
 * or NativeVotes_DisplayFail to hide the vote screen for users who didn't vote,
 | 
			
		||||
 * and to clear out their selection for the next vote.
 | 
			
		||||
 *
 | 
			
		||||
 * @param reason			Vote failure reason from NativeVotesFailType enum
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_DisplayFail(Handle:vote, NativeVotesFailType:reason=NativeVotesFail_Generic);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Quick stock to determine whether voting is allowed.  This doesn't let you
 | 
			
		||||
 * fine-tune a reason for not voting, so it's not recommended for lazily
 | 
			
		||||
 * telling clients that voting isn't allowed.
 | 
			
		||||
 *
 | 
			
		||||
 * @return				True if voting is allowed, false if voting is in progress
 | 
			
		||||
 *						or the cooldown is active.
 | 
			
		||||
 */
 | 
			
		||||
stock bool:NativeVotes_IsNewVoteAllowed()
 | 
			
		||||
{
 | 
			
		||||
	if (NativeVotes_IsVoteInProgress() || NativeVotes_CheckVoteDelay() != 0)
 | 
			
		||||
	{
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Used when callvote is called with no arguments.
 | 
			
		||||
 *
 | 
			
		||||
 * This is used to configure the VoteSetup usermessage on TF2 and CS:GO
 | 
			
		||||
 *
 | 
			
		||||
 * @param client		Client, in case the votes are restricted by client
 | 
			
		||||
 * @param voteTypes		Populate this array with the vote types this server supports
 | 
			
		||||
 * 						Custom and multiple choice votes are not supported from
 | 
			
		||||
 * 						the GUI and are thus ignored.
 | 
			
		||||
 * @return				Plugin_Continue to allow the server itself (or another plugin) to process the callvote
 | 
			
		||||
 * 						Plugin_Changed if you're changing the voteTypes,
 | 
			
		||||
 * 						Plugin_Handled to return a blank VoteSetup usermessage
 | 
			
		||||
 * 						Plugin_Stop to prevent VoteSetup usermessage (not recommended)
 | 
			
		||||
 */
 | 
			
		||||
//functag public Action:NativeVotes_CallVoteSetupHandler(client, NativeVotesType:voteTypes[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Forward for "callvote" handling
 | 
			
		||||
 *
 | 
			
		||||
 * You should respond to this by starting a vote or by calling NativeVotes_DisplayCallVoteFail
 | 
			
		||||
 *
 | 
			
		||||
 * @param client		Client
 | 
			
		||||
 * @param voteType		Type of vote being called.  This will NEVER be a multiple-choice or custom vote.
 | 
			
		||||
 * @param voteArgument	Vote argument or blank if the vote type has no argument.
 | 
			
		||||
 * @param target		target userid for kick votes or 0 for all other votes
 | 
			
		||||
 * @return				Plugin_Continue to allow the server itself (or another plugin) to process the callvote
 | 
			
		||||
 * 						Plugin_Handled if you processed this vote type
 | 
			
		||||
 * 						Plugin_Stop to block the vote type (not recommended)
 | 
			
		||||
 */
 | 
			
		||||
//functag public Action:NativeVotes_CallVoteHandler(client, NativeVotesType:voteType, const String:voteArgument[], target);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Register a plugin as a vote manager.
 | 
			
		||||
 * This is used to abstract away the details of the callvote command.
 | 
			
		||||
 *
 | 
			
		||||
 * @param callHandler	Handler for callvote commands.
 | 
			
		||||
 * @param setupHandler	Handler to override the which vote types your server supports.  Only useful on TF2 and CS:GO.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
//native NativeVotes_RegisterVoteManager(NativeVotes_CallVoteHandler:callHandler, NativeVotes_CallVoteSetupHandler:setupHandler=INVALID_FUNCTION);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *  Send a call vote fail screen to a user
 | 
			
		||||
 * Used to respond to a callvote with invalid arguments or for other reasons
 | 
			
		||||
 * (such as trying to target an admin for a kick/ban vote)
 | 
			
		||||
 *
 | 
			
		||||
 * @param client		The client to display the fail screen to
 | 
			
		||||
 * @param reason		A vote call fail reason
 | 
			
		||||
 * @param time			For NativeVotesCallFail_Recent, the number of seconds until the vote
 | 
			
		||||
 * 						can be called again
 | 
			
		||||
 */
 | 
			
		||||
native NativeVotes_DisplayCallVoteFail(client, NativeVotesCallFailType:reason, time);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Redraws the vote title from inside a MenuAction_Display callback
 | 
			
		||||
 * Not supported on L4D
 | 
			
		||||
 *
 | 
			
		||||
 * @param text			Vote title to draw
 | 
			
		||||
 * @error 				If called from outside MenuAction_Display
 | 
			
		||||
 * @return				Plugin_Changed if the change is allowed, Plugin_Continue if it isn't.
 | 
			
		||||
 */
 | 
			
		||||
native Action:NativeVotes_RedrawVoteTitle(const String:text[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Redraws the vote text from inside a MenuAction_DisplayItem callback.
 | 
			
		||||
 * Only supported on multiple-choice votes
 | 
			
		||||
 *
 | 
			
		||||
 * @param text			Vote text to draw.
 | 
			
		||||
 * @error 				If called from outside MenuAction_DisplayItem
 | 
			
		||||
 * @return				Plugin_Changed if the change is allowed, Plugin_Continue if it isn't.
 | 
			
		||||
 */
 | 
			
		||||
native Action:NativeVotes_RedrawVoteItem(const String:text[]);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Retrieves voting information from MenuAction_VoteEnd.
 | 
			
		||||
 *
 | 
			
		||||
 * @param param2		Second parameter of MenuAction_VoteEnd.
 | 
			
		||||
 * @param winningVotes	Number of votes received by the winning option.
 | 
			
		||||
 * @param totalVotes	Number of total votes received.
 | 
			
		||||
 * @noreturn
 | 
			
		||||
 */
 | 
			
		||||
stock NativeVotes_GetInfo(param2, &winningVotes, &totalVotes)
 | 
			
		||||
{
 | 
			
		||||
	winningVotes = param2 & 0xFFFF;
 | 
			
		||||
	totalVotes = param2 >> 16;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Do not edit below this line!
 | 
			
		||||
 */
 | 
			
		||||
public SharedPlugin:__pl_nativevotes =
 | 
			
		||||
{
 | 
			
		||||
	name = "nativevotes",
 | 
			
		||||
	file = "nativevotes.smx",
 | 
			
		||||
#if defined REQUIRE_PLUGINS
 | 
			
		||||
	required = 1,
 | 
			
		||||
#else
 | 
			
		||||
	required = 0,
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
public __pl_nativevotes_SetNTVOptional()
 | 
			
		||||
{
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_IsVoteTypeSupported");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_Create");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_Close");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_AddItem");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_InsertItem");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RemoveItem");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RemoveAllItems");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetItem");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetItemCount");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetDetails");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetDetails");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetTitle");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetTitle");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetTarget");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetTarget");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetTargetSteam");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_IsVoteInProgress");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetMaxItems");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetOptionFlags");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetOptionFlags");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_Cancel");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetResultCallback");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_CheckVoteDelay");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_IsClientInVotePool");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RedrawClientVote");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RedrawClientVote");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetType");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetTeam");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetTeam");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_SetInitiator");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_GetInitiator");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_Display");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_DisplayPass");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_DisplayPassCustomToOne");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_DisplayPassEx");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_DisplayFail");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RegisterVoteManager");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_DisplayCallVoteFail");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RedrawVoteTitle");
 | 
			
		||||
	MarkNativeAsOptional("NativeVotes_RedrawVoteItem");
 | 
			
		||||
}
 | 
			
		||||
@ -50,15 +50,10 @@
 | 
			
		||||
#include <sdktools>
 | 
			
		||||
#include <multicolors>
 | 
			
		||||
 | 
			
		||||
#undef REQUIRE_PLUGIN
 | 
			
		||||
#include <nativevotes>
 | 
			
		||||
#define REQUIRE_PLUGIN
 | 
			
		||||
 | 
			
		||||
#pragma semicolon 1
 | 
			
		||||
#pragma newdecls required
 | 
			
		||||
 | 
			
		||||
#define MCE_VERSION "1.13.0"
 | 
			
		||||
#define NV "nativevotes"
 | 
			
		||||
 | 
			
		||||
enum RoundCounting
 | 
			
		||||
{
 | 
			
		||||
@ -158,7 +153,6 @@ ConVar g_Cvar_StartTimePercent;
 | 
			
		||||
ConVar g_Cvar_StartTimePercentEnable;
 | 
			
		||||
ConVar g_Cvar_WarningTime;
 | 
			
		||||
ConVar g_Cvar_RunOffWarningTime;
 | 
			
		||||
ConVar g_Cvar_MenuStyle;
 | 
			
		||||
ConVar g_Cvar_TimerLocation;
 | 
			
		||||
ConVar g_Cvar_ExtendPosition;
 | 
			
		||||
ConVar g_Cvar_MarkCustomMaps;
 | 
			
		||||
@ -179,7 +173,6 @@ Handle g_MapVoteRunoffStartForward = INVALID_HANDLE;
 | 
			
		||||
/* Mapchooser Extended Globals */
 | 
			
		||||
int g_RunoffCount = 0;
 | 
			
		||||
int g_mapOfficialFileSerial = -1;
 | 
			
		||||
bool g_NativeVotes = false;
 | 
			
		||||
char g_GameModName[64];
 | 
			
		||||
bool g_WarningInProgress = false;
 | 
			
		||||
bool g_AddNoVote = false;
 | 
			
		||||
@ -259,7 +252,6 @@ public void OnPluginStart()
 | 
			
		||||
	g_Cvar_StartTimePercentEnable = CreateConVar("mce_start_percent_enable", "0", "Enable or Disable percentage calculations when to start vote.", _, true, 0.0, true, 1.0);
 | 
			
		||||
	g_Cvar_WarningTime = CreateConVar("mce_warningtime", "15.0", "Warning time in seconds.", _, true, 0.0, true, 60.0);
 | 
			
		||||
	g_Cvar_RunOffWarningTime = CreateConVar("mce_runoffvotewarningtime", "5.0", "Warning time for runoff vote in seconds.", _, true, 0.0, true, 30.0);
 | 
			
		||||
	g_Cvar_MenuStyle = CreateConVar("mce_menustyle", "0", "Menu Style.  0 is the game's default, 1 is the older Valve style that requires you to press Escape to see the menu, 2 is the newer 1-9 button Voice Command style, unavailable in some games. Ignored on TF2 if NativeVotes Plugin is loaded.", _, true, 0.0, true, 2.0);
 | 
			
		||||
	g_Cvar_TimerLocation = CreateConVar("mce_warningtimerlocation", "0", "Location for the warning timer text. 0 is HintBox, 1 is Center text, 2 is Chat.  Defaults to HintBox.", _, true, 0.0, true, 2.0);
 | 
			
		||||
	g_Cvar_MarkCustomMaps = CreateConVar("mce_markcustommaps", "1", "Mark custom maps in the vote list. 0 = Disabled, 1 = Mark with *, 2 = Mark with phrase.", _, true, 0.0, true, 2.0);
 | 
			
		||||
	g_Cvar_ExtendPosition = CreateConVar("mce_extendposition", "0", "Position of Extend/Don't Change options. 0 = at end, 1 = at start.", _, true, 0.0, true, 1.0);
 | 
			
		||||
@ -420,23 +412,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
 | 
			
		||||
	return APLRes_Success;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void OnAllPluginsLoaded()
 | 
			
		||||
{
 | 
			
		||||
	g_NativeVotes = LibraryExists(NV) && NativeVotes_IsVoteTypeSupported(NativeVotesType_NextLevelMult);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void OnLibraryAdded(const char[] name)
 | 
			
		||||
{
 | 
			
		||||
	if(StrEqual(name, NV) && NativeVotes_IsVoteTypeSupported(NativeVotesType_NextLevelMult))
 | 
			
		||||
		g_NativeVotes = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void OnLibraryRemoved(const char[] name)
 | 
			
		||||
{
 | 
			
		||||
	if(StrEqual(name, NV))
 | 
			
		||||
		g_NativeVotes = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void OnMapStart()
 | 
			
		||||
{
 | 
			
		||||
	static char folder[64];
 | 
			
		||||
@ -981,10 +956,8 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
 | 
			
		||||
	g_WaitingForVote = true;
 | 
			
		||||
	g_WarningInProgress = false;
 | 
			
		||||
 | 
			
		||||
	// Check if a nativevotes vots is in progress first
 | 
			
		||||
	// NativeVotes running at the same time as a regular vote can cause hintbox problems,
 | 
			
		||||
	// so always check for a standard vote
 | 
			
		||||
	if(IsVoteInProgress() || (g_NativeVotes && NativeVotes_IsVoteInProgress()))
 | 
			
		||||
	// Check if a vote is in progress first
 | 
			
		||||
	if(IsVoteInProgress())
 | 
			
		||||
	{
 | 
			
		||||
		// Can't start a vote, try again in 5 seconds.
 | 
			
		||||
		//g_RetryTimer = CreateTimer(5.0, Timer_StartMapVote, _, TIMER_FLAG_NO_MAPCHANGE);
 | 
			
		||||
@ -1021,52 +994,34 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
 | 
			
		||||
 | 
			
		||||
	g_HasVoteStarted = true;
 | 
			
		||||
 | 
			
		||||
	if(g_NativeVotes)
 | 
			
		||||
	{
 | 
			
		||||
		g_VoteMenu = NativeVotes_Create(Handler_MapVoteMenu, NativeVotesType_NextLevelMult, MenuAction_End | MenuAction_VoteCancel | MenuAction_Display | MenuAction_DisplayItem);
 | 
			
		||||
		NativeVotes_SetResultCallback(g_VoteMenu, Handler_NativeVoteFinished);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		Handle menuStyle = GetMenuStyleHandle(view_as<MenuStyle>(GetConVarInt(g_Cvar_MenuStyle)));
 | 
			
		||||
	g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
 | 
			
		||||
 | 
			
		||||
		if(menuStyle != INVALID_HANDLE)
 | 
			
		||||
	g_AddNoVote = GetConVarBool(g_Cvar_NoVoteOption);
 | 
			
		||||
 | 
			
		||||
	// Block Vote Slots
 | 
			
		||||
	if(GetConVarBool(g_Cvar_BlockSlots))
 | 
			
		||||
	{
 | 
			
		||||
		Handle radioStyle = GetMenuStyleHandle(MenuStyle_Radio);
 | 
			
		||||
 | 
			
		||||
		if(GetMenuStyle(g_VoteMenu) == radioStyle)
 | 
			
		||||
		{
 | 
			
		||||
			g_VoteMenu = CreateMenuEx(menuStyle, Handler_MapVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
 | 
			
		||||
			g_BlockedSlots = true;
 | 
			
		||||
			AddMenuItem(g_VoteMenu, LINE_ONE, "Choose something...", ITEMDRAW_DISABLED);
 | 
			
		||||
			AddMenuItem(g_VoteMenu, LINE_TWO, "...will ya?", ITEMDRAW_DISABLED);
 | 
			
		||||
 | 
			
		||||
			if(!g_AddNoVote)
 | 
			
		||||
				AddMenuItem(g_VoteMenu, LINE_SPACER, "", ITEMDRAW_SPACER);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			// You chose... poorly
 | 
			
		||||
			g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		g_AddNoVote = GetConVarBool(g_Cvar_NoVoteOption);
 | 
			
		||||
 | 
			
		||||
		// Block Vote Slots
 | 
			
		||||
		if(GetConVarBool(g_Cvar_BlockSlots))
 | 
			
		||||
		{
 | 
			
		||||
			Handle radioStyle = GetMenuStyleHandle(MenuStyle_Radio);
 | 
			
		||||
 | 
			
		||||
			if(GetMenuStyle(g_VoteMenu) == radioStyle)
 | 
			
		||||
			{
 | 
			
		||||
				g_BlockedSlots = true;
 | 
			
		||||
				AddMenuItem(g_VoteMenu, LINE_ONE, "Choose something...", ITEMDRAW_DISABLED);
 | 
			
		||||
				AddMenuItem(g_VoteMenu, LINE_TWO, "...will ya?", ITEMDRAW_DISABLED);
 | 
			
		||||
 | 
			
		||||
				if(!g_AddNoVote)
 | 
			
		||||
					AddMenuItem(g_VoteMenu, LINE_SPACER, "", ITEMDRAW_SPACER);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				g_BlockedSlots = false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(g_AddNoVote)
 | 
			
		||||
			SetMenuOptionFlags(g_VoteMenu, MENUFLAG_BUTTON_NOVOTE);
 | 
			
		||||
 | 
			
		||||
		SetMenuTitle(g_VoteMenu, "Vote Nextmap");
 | 
			
		||||
		SetVoteResultCallback(g_VoteMenu, Handler_MapVoteFinished);
 | 
			
		||||
			g_BlockedSlots = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(g_AddNoVote)
 | 
			
		||||
		SetMenuOptionFlags(g_VoteMenu, MENUFLAG_BUTTON_NOVOTE);
 | 
			
		||||
 | 
			
		||||
	SetMenuTitle(g_VoteMenu, "Vote Nextmap");
 | 
			
		||||
	SetVoteResultCallback(g_VoteMenu, Handler_MapVoteFinished);
 | 
			
		||||
 | 
			
		||||
	/* Call OnMapVoteStarted() Forward */
 | 
			
		||||
//	Call_StartForward(g_MapVoteStartedForward);
 | 
			
		||||
//	Call_Finish();
 | 
			
		||||
@ -1091,16 +1046,6 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
 | 
			
		||||
 | 
			
		||||
		int voteSize = GetVoteSize(2);
 | 
			
		||||
 | 
			
		||||
		// The if and else if could be combined, but it looks extremely messy
 | 
			
		||||
		// This is a hack to lower the vote menu size by 1 when Don't Change or Extend Map should appear
 | 
			
		||||
		if(g_NativeVotes)
 | 
			
		||||
		{
 | 
			
		||||
			if((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange))
 | 
			
		||||
				voteSize--;
 | 
			
		||||
			else if(GetConVarBool(g_Cvar_Extend) && g_Extends < GetConVarInt(g_Cvar_Extend))
 | 
			
		||||
				voteSize--;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Smaller of the two - It should be impossible for nominations to exceed the size though (cvar changed mid-map?) */
 | 
			
		||||
		int nominationsToAdd = nominateCount >= voteSize ? voteSize : nominateCount;
 | 
			
		||||
 | 
			
		||||
@ -1220,17 +1165,11 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
 | 
			
		||||
			// New in Mapchooser Extended
 | 
			
		||||
			else if(StrEqual(map, VOTE_DONTCHANGE))
 | 
			
		||||
			{
 | 
			
		||||
				if(g_NativeVotes)
 | 
			
		||||
					NativeVotes_AddItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
 | 
			
		||||
				else
 | 
			
		||||
					AddMenuItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
 | 
			
		||||
				AddMenuItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
 | 
			
		||||
			}
 | 
			
		||||
			else if(StrEqual(map, VOTE_EXTEND))
 | 
			
		||||
			{
 | 
			
		||||
				if(g_NativeVotes)
 | 
			
		||||
					NativeVotes_AddItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
 | 
			
		||||
				else
 | 
			
		||||
					AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
 | 
			
		||||
				AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		delete inputlist;
 | 
			
		||||
@ -1238,23 +1177,16 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
 | 
			
		||||
 | 
			
		||||
	int voteDuration = GetConVarInt(g_Cvar_VoteDuration);
 | 
			
		||||
 | 
			
		||||
	if(g_NativeVotes)
 | 
			
		||||
	{
 | 
			
		||||
		NativeVotes_DisplayToAll(g_VoteMenu, voteDuration);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		//SetMenuExitButton(g_VoteMenu, false);
 | 
			
		||||
	//SetMenuExitButton(g_VoteMenu, false);
 | 
			
		||||
 | 
			
		||||
		if(GetVoteSize(2) <= GetMaxPageItems(GetMenuStyle(g_VoteMenu)))
 | 
			
		||||
		{
 | 
			
		||||
			//This is necessary to get items 9 and 0 as usable voting items
 | 
			
		||||
			SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		VoteMenuToAll(g_VoteMenu, voteDuration);
 | 
			
		||||
	if(GetVoteSize(2) <= GetMaxPageItems(GetMenuStyle(g_VoteMenu)))
 | 
			
		||||
	{
 | 
			
		||||
		//This is necessary to get items 9 and 0 as usable voting items
 | 
			
		||||
		SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	VoteMenuToAll(g_VoteMenu, voteDuration);
 | 
			
		||||
 | 
			
		||||
	/* Call OnMapVoteStarted() Forward */
 | 
			
		||||
	Call_StartForward(g_MapVoteStartForward); // Deprecated
 | 
			
		||||
	Call_Finish();
 | 
			
		||||
@ -1266,23 +1198,6 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
 | 
			
		||||
	CPrintToChatAll("[MCE] %t", "Nextmap Voting Started");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public int Handler_NativeVoteFinished(Handle vote,
 | 
			
		||||
									   int num_votes,
 | 
			
		||||
									   int num_clients,
 | 
			
		||||
									   const int[] client_indexes,
 | 
			
		||||
									   const int[] client_votes,
 | 
			
		||||
									   int num_items,
 | 
			
		||||
									   const int[] item_indexes,
 | 
			
		||||
									   const int[] item_votes)
 | 
			
		||||
{
 | 
			
		||||
	int[][] client_info = new int[num_clients][2];
 | 
			
		||||
	int[][] item_info = new int[num_items][2];
 | 
			
		||||
 | 
			
		||||
	NativeVotes_FixResults(num_clients, client_indexes, client_votes, num_items, item_indexes, item_votes, client_info, item_info);
 | 
			
		||||
	Handler_MapVoteFinished(vote, num_votes, num_clients, client_info, num_items, item_info);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public void Handler_VoteFinishedGeneric(Handle menu,
 | 
			
		||||
										int num_votes,
 | 
			
		||||
										int num_clients,
 | 
			
		||||
@ -1329,9 +1244,6 @@ public void Handler_VoteFinishedGeneric(Handle menu,
 | 
			
		||||
				SetConVarInt(g_Cvar_Fraglimit, fraglimit + GetConVarInt(g_Cvar_ExtendFragStep));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(g_NativeVotes)
 | 
			
		||||
			NativeVotes_DisplayPassEx(menu, NativeVotesPass_Extend);
 | 
			
		||||
 | 
			
		||||
		CPrintToChatAll("[MCE] %t", "Current Map Extended", RoundToFloor(float(item_info[0][VOTEINFO_ITEM_VOTES])/float(num_votes)*100), num_votes);
 | 
			
		||||
		LogAction(-1, -1, "Voting for next map has finished. The current map has been extended.");
 | 
			
		||||
 | 
			
		||||
@ -1343,9 +1255,6 @@ public void Handler_VoteFinishedGeneric(Handle menu,
 | 
			
		||||
	}
 | 
			
		||||
	else if(strcmp(map, VOTE_DONTCHANGE, false) == 0)
 | 
			
		||||
	{
 | 
			
		||||
		if(g_NativeVotes)
 | 
			
		||||
			NativeVotes_DisplayPassEx(menu, NativeVotesPass_Extend);
 | 
			
		||||
 | 
			
		||||
		CPrintToChatAll("[MCE] %t", "Current Map Stays", RoundToFloor(float(item_info[0][VOTEINFO_ITEM_VOTES])/float(num_votes)*100), num_votes);
 | 
			
		||||
		LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner");
 | 
			
		||||
 | 
			
		||||
@ -1358,9 +1267,6 @@ public void Handler_VoteFinishedGeneric(Handle menu,
 | 
			
		||||
		if(g_ChangeTime == MapChange_MapEnd)
 | 
			
		||||
		{
 | 
			
		||||
			SetNextMap(map);
 | 
			
		||||
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_DisplayPass(menu, map);
 | 
			
		||||
		}
 | 
			
		||||
		else if(g_ChangeTime == MapChange_Instant)
 | 
			
		||||
		{
 | 
			
		||||
@ -1368,17 +1274,11 @@ public void Handler_VoteFinishedGeneric(Handle menu,
 | 
			
		||||
			CreateDataTimer(4.0, Timer_ChangeMap, data);
 | 
			
		||||
			WritePackString(data, map);
 | 
			
		||||
			g_ChangeMapInProgress = false;
 | 
			
		||||
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_DisplayPassEx(menu, NativeVotesPass_ChgLevel, map);
 | 
			
		||||
		}
 | 
			
		||||
		else // MapChange_RoundEnd
 | 
			
		||||
		{
 | 
			
		||||
			SetNextMap(map);
 | 
			
		||||
			g_ChangeMapAtRoundEnd = true;
 | 
			
		||||
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_DisplayPass(menu, map);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		g_HasVoteStarted = false;
 | 
			
		||||
@ -1425,9 +1325,6 @@ public void Handler_MapVoteFinished(Handle menu,
 | 
			
		||||
					break;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_DisplayFail(menu, NativeVotesFail_NotEnoughVotes);
 | 
			
		||||
 | 
			
		||||
			CPrintToChatAll("[MCE] %t", "Tie Vote", GetArraySize(mapList));
 | 
			
		||||
			SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList);
 | 
			
		||||
			return;
 | 
			
		||||
@ -1458,9 +1355,6 @@ public void Handler_MapVoteFinished(Handle menu,
 | 
			
		||||
					break;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_DisplayFail(menu, NativeVotesFail_NotEnoughVotes);
 | 
			
		||||
 | 
			
		||||
			CPrintToChatAll("[MCE] %t", "Revote Is Needed", required_percent);
 | 
			
		||||
			SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList);
 | 
			
		||||
			return;
 | 
			
		||||
@ -1471,7 +1365,6 @@ public void Handler_MapVoteFinished(Handle menu,
 | 
			
		||||
	Handler_VoteFinishedGeneric(menu, num_votes, num_clients, client_info, num_items, item_info);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// This is shared by NativeVotes now, but NV doesn't support Display or DisplayItem
 | 
			
		||||
public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int param2)
 | 
			
		||||
{
 | 
			
		||||
	switch(action)
 | 
			
		||||
@ -1479,22 +1372,15 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
 | 
			
		||||
		case MenuAction_End:
 | 
			
		||||
		{
 | 
			
		||||
			g_VoteMenu = INVALID_HANDLE;
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_Close(menu);
 | 
			
		||||
			else
 | 
			
		||||
				delete menu;
 | 
			
		||||
			delete menu;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		case MenuAction_Display:
 | 
			
		||||
		{
 | 
			
		||||
			// NativeVotes uses the standard TF2/CSGO vote screen
 | 
			
		||||
			if(!g_NativeVotes)
 | 
			
		||||
			{
 | 
			
		||||
				static char buffer[255];
 | 
			
		||||
				Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1);
 | 
			
		||||
				Handle panel = view_as<Handle>(param2);
 | 
			
		||||
				SetPanelTitle(panel, buffer);
 | 
			
		||||
			}
 | 
			
		||||
			static char buffer[255];
 | 
			
		||||
			Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1);
 | 
			
		||||
			Handle panel = view_as<Handle>(param2);
 | 
			
		||||
			SetPanelTitle(panel, buffer);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		case MenuAction_DisplayItem:
 | 
			
		||||
@ -1503,10 +1389,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
 | 
			
		||||
			char buffer[255];
 | 
			
		||||
			int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
 | 
			
		||||
 | 
			
		||||
			if(g_NativeVotes)
 | 
			
		||||
				NativeVotes_GetItem(menu, param2, map, PLATFORM_MAX_PATH);
 | 
			
		||||
			else
 | 
			
		||||
				GetMenuItem(menu, param2, map, PLATFORM_MAX_PATH);
 | 
			
		||||
			GetMenuItem(menu, param2, map, PLATFORM_MAX_PATH);
 | 
			
		||||
 | 
			
		||||
			if(StrEqual(map, VOTE_EXTEND, false))
 | 
			
		||||
			{
 | 
			
		||||
@ -1544,13 +1427,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
 | 
			
		||||
 | 
			
		||||
			if(buffer[0] != '\0')
 | 
			
		||||
			{
 | 
			
		||||
				if(g_NativeVotes)
 | 
			
		||||
				{
 | 
			
		||||
					NativeVotes_RedrawVoteItem(buffer);
 | 
			
		||||
					return view_as<int>(Plugin_Continue);
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					return RedrawMenuItem(buffer);
 | 
			
		||||
				return RedrawMenuItem(buffer);
 | 
			
		||||
			}
 | 
			
		||||
			// End Mapchooser Extended
 | 
			
		||||
		}
 | 
			
		||||
@ -1560,11 +1437,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
 | 
			
		||||
			// If we receive 0 votes, pick at random.
 | 
			
		||||
			if(param1 == VoteCancel_NoVotes && GetConVarBool(g_Cvar_NoVoteMode))
 | 
			
		||||
			{
 | 
			
		||||
				int count;
 | 
			
		||||
				if(g_NativeVotes)
 | 
			
		||||
					count = NativeVotes_GetItemCount(menu);
 | 
			
		||||
				else
 | 
			
		||||
					count = GetMenuItemCount(menu);
 | 
			
		||||
				int count = GetMenuItemCount(menu);
 | 
			
		||||
 | 
			
		||||
				int item;
 | 
			
		||||
				static char map[PLATFORM_MAX_PATH];
 | 
			
		||||
@ -1572,7 +1445,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
 | 
			
		||||
				do
 | 
			
		||||
				{
 | 
			
		||||
					int startInt = 0;
 | 
			
		||||
					if(!g_NativeVotes && g_BlockedSlots)
 | 
			
		||||
					if(g_BlockedSlots)
 | 
			
		||||
					{
 | 
			
		||||
						if(g_AddNoVote)
 | 
			
		||||
						{
 | 
			
		||||
@ -1585,26 +1458,12 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
 | 
			
		||||
					}
 | 
			
		||||
					item = GetRandomInt(startInt, count - 1);
 | 
			
		||||
 | 
			
		||||
					if(g_NativeVotes)
 | 
			
		||||
						NativeVotes_GetItem(menu, item, map, PLATFORM_MAX_PATH);
 | 
			
		||||
					else
 | 
			
		||||
						GetMenuItem(menu, item, map, PLATFORM_MAX_PATH);
 | 
			
		||||
					GetMenuItem(menu, item, map, PLATFORM_MAX_PATH);
 | 
			
		||||
				}
 | 
			
		||||
				while(strcmp(map, VOTE_EXTEND, false) == 0);
 | 
			
		||||
 | 
			
		||||
				SetNextMap(map);
 | 
			
		||||
				g_MapVoteCompleted = true;
 | 
			
		||||
 | 
			
		||||
				if(g_NativeVotes)
 | 
			
		||||
					NativeVotes_DisplayPass(menu, map);
 | 
			
		||||
			}
 | 
			
		||||
			else if(g_NativeVotes)
 | 
			
		||||
			{
 | 
			
		||||
				NativeVotesFailType reason = NativeVotesFail_Generic;
 | 
			
		||||
				if(param1 == VoteCancel_NoVotes)
 | 
			
		||||
					reason = NativeVotesFail_NotEnoughVotes;
 | 
			
		||||
 | 
			
		||||
				NativeVotes_DisplayFail(menu, reason);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			g_HasVoteStarted = false;
 | 
			
		||||
@ -2348,18 +2207,12 @@ public int Native_GetExtendsLeft(Handle plugin, int numParams)
 | 
			
		||||
 | 
			
		||||
stock void AddMapItem(const char[] map)
 | 
			
		||||
{
 | 
			
		||||
	if(g_NativeVotes)
 | 
			
		||||
		NativeVotes_AddItem(g_VoteMenu, map, map);
 | 
			
		||||
	else
 | 
			
		||||
		AddMenuItem(g_VoteMenu, map, map);
 | 
			
		||||
	AddMenuItem(g_VoteMenu, map, map);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stock void GetMapItem(Handle menu, int position, char[] map, int mapLen)
 | 
			
		||||
{
 | 
			
		||||
	if(g_NativeVotes)
 | 
			
		||||
		NativeVotes_GetItem(menu, position, map, mapLen);
 | 
			
		||||
	else
 | 
			
		||||
		GetMenuItem(menu, position, map, mapLen);
 | 
			
		||||
	GetMenuItem(menu, position, map, mapLen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stock void AddExtendToMenu(Handle menu, MapChange when)
 | 
			
		||||
@ -2370,17 +2223,11 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
 | 
			
		||||
	if((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange))
 | 
			
		||||
	{
 | 
			
		||||
		// Built-in votes doesn't have "Don't Change", send Extend instead
 | 
			
		||||
		if(g_NativeVotes)
 | 
			
		||||
			NativeVotes_AddItem(menu, VOTE_DONTCHANGE, "Don't Change");
 | 
			
		||||
		else
 | 
			
		||||
			AddMenuItem(menu, VOTE_DONTCHANGE, "Don't Change");
 | 
			
		||||
		AddMenuItem(menu, VOTE_DONTCHANGE, "Don't Change");
 | 
			
		||||
	}
 | 
			
		||||
	else if(GetConVarBool(g_Cvar_Extend) && g_Extends < GetConVarInt(g_Cvar_Extend))
 | 
			
		||||
	{
 | 
			
		||||
		if(g_NativeVotes)
 | 
			
		||||
			NativeVotes_AddItem(menu, VOTE_EXTEND, "Extend Map");
 | 
			
		||||
		else
 | 
			
		||||
			AddMenuItem(menu, VOTE_EXTEND, "Extend Map");
 | 
			
		||||
		AddMenuItem(menu, VOTE_EXTEND, "Extend Map");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2396,17 +2243,6 @@ stock int GetVoteSize(int what=0)
 | 
			
		||||
	if(what == 1 || what == 2)
 | 
			
		||||
		voteSize += includeMapsReserved;
 | 
			
		||||
 | 
			
		||||
	// New in 1.9.5 to let us bump up the included maps count
 | 
			
		||||
	if(g_NativeVotes)
 | 
			
		||||
	{
 | 
			
		||||
		int max = NativeVotes_GetMaxItems();
 | 
			
		||||
 | 
			
		||||
		if(voteSize > max)
 | 
			
		||||
			voteSize = max;
 | 
			
		||||
		if(includeMaps > max)
 | 
			
		||||
			includeMaps = max;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(what == 1)
 | 
			
		||||
		return voteSize - includeMaps;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user