Vote plugin changes, added basefunvotes
authorMichael McKoy <ferret99gt@gmail.com>
Thu Aug 09 23:34:53 2007 +0000 (2007-08-09)
changeset 1295957df1c7b80a
parent 1294 63af7da6c82c
child 1296 0197a1212cb8
Vote plugin changes, added basefunvotes
plugins/basefunvotes.sp
plugins/basevotes.sp
translations/basefunvotes.phrases.txt
translations/common.phrases.txt
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/basefunvotes.sp	Thu Aug 09 23:34:53 2007 +0000
     1.3 @@ -0,0 +1,524 @@
     1.4 +/**
     1.5 + * basefunvotes.sp
     1.6 + * Implements extra fun vote commands.
     1.7 + * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
     1.8 + *
     1.9 + * This program is free software; you can redistribute it and/or
    1.10 + * modify it under the terms of the GNU General Public License
    1.11 + * as published by the Free Software Foundation; either version 2
    1.12 + * of the License, or (at your option) any later version.
    1.13 + *
    1.14 + * This program is distributed in the hope that it will be useful,
    1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.17 + * GNU General Public License for more details.
    1.18 + *
    1.19 + * You should have received a copy of the GNU General Public License
    1.20 + * along with this program; if not, write to the Free Software
    1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    1.22 + *
    1.23 + * Version: $Id$
    1.24 + */
    1.25 +
    1.26 +#include <sourcemod>
    1.27 +#include <sdktools>
    1.28 +
    1.29 +#pragma semicolon 1
    1.30 +
    1.31 +public Plugin:myinfo =
    1.32 +{
    1.33 +	name = "Fun Votes",
    1.34 +	author = "AlliedModders LLC",
    1.35 +	description = "Fun Vote Commands",
    1.36 +	version = SOURCEMOD_VERSION,
    1.37 +	url = "http://www.sourcemod.net/"
    1.38 +};
    1.39 +
    1.40 +#define VOTE_NO "###no###"
    1.41 +#define VOTE_YES "###yes###"
    1.42 +
    1.43 +new Handle:g_hVoteMenu = INVALID_HANDLE;
    1.44 +
    1.45 +new Handle:g_Cvar_Limits[5] = {INVALID_HANDLE, ...};
    1.46 +new Handle:g_Cvar_Gravity = INVALID_HANDLE;
    1.47 +new Handle:g_Cvar_Alltalk = INVALID_HANDLE;
    1.48 +new Handle:g_Cvar_FF = INVALID_HANDLE;
    1.49 +
    1.50 +// new Handle:g_Cvar_Show = INVALID_HANDLE;
    1.51 +
    1.52 +enum voteType
    1.53 +{
    1.54 +	gravity = 0,
    1.55 +	burn,
    1.56 +	slay,
    1.57 +	alltalk,
    1.58 +	ff
    1.59 +}
    1.60 +
    1.61 +new voteType:g_voteType = voteType:gravity;
    1.62 +
    1.63 +// Menu API does not provide us with a way to pass multiple peices of data with a single
    1.64 +// choice, so some globals are used to hold stuff.
    1.65 +//
    1.66 +#define VOTE_CLIENTID	0
    1.67 +#define VOTE_USERID	1
    1.68 +new g_voteClient[2];		/* Holds the target's client id and user id */
    1.69 +
    1.70 +#define VOTE_NAME	0
    1.71 +#define VOTE_AUTHID	1
    1.72 +#define	VOTE_IP		2
    1.73 +new String:g_voteInfo[3][65];	/* Holds the target's name, authid, and IP */
    1.74 +
    1.75 +public OnPluginStart()
    1.76 +{
    1.77 +	LoadTranslations("common.phrases");
    1.78 +	LoadTranslations("basevotes.phrases");
    1.79 +	LoadTranslations("basefunvotes.phrases");
    1.80 +	
    1.81 +	RegAdminCmd("sm_votegravity", Command_VoteGravity, ADMFLAG_VOTE, "sm_votegravity <amount> [amount2] ... [amount5]");
    1.82 +	RegAdminCmd("sm_voteburn", Command_VoteBurn, ADMFLAG_VOTE|ADMFLAG_SLAY, "sm_voteburn <player>");
    1.83 +	RegAdminCmd("sm_voteslay", Command_VoteSlay, ADMFLAG_VOTE|ADMFLAG_SLAY, "sm_voteslay <player>");
    1.84 +	RegAdminCmd("sm_votealltalk", Command_VoteAlltalk, ADMFLAG_VOTE, "sm_votealltalk");
    1.85 +	RegAdminCmd("sm_voteff", Command_VoteFF, ADMFLAG_VOTE, "sm_voteff");
    1.86 +
    1.87 +	g_Cvar_Limits[0] = CreateConVar("sm_vote_gravity", "0.60", "percent required for successful gravity vote.", 0, true, 0.05, true, 1.0);
    1.88 +	g_Cvar_Limits[1] = CreateConVar("sm_vote_burn", "0.60", "percent required for successful burn vote.", 0, true, 0.05, true, 1.0);
    1.89 +	g_Cvar_Limits[2] = CreateConVar("sm_vote_slay", "0.60", "percent required for successful slay vote.", 0, true, 0.05, true, 1.0);
    1.90 +	g_Cvar_Limits[3] = CreateConVar("sm_vote_alltalk", "0.60", "percent required for successful alltalk vote.", 0, true, 0.05, true, 1.0);
    1.91 +	g_Cvar_Limits[4] = CreateConVar("sm_vote_ff", "0.60", "percent required for successful friendly fire vote.", 0, true, 0.05, true, 1.0);
    1.92 +	
    1.93 +	g_Cvar_Gravity = FindConVar("sv_gravity");
    1.94 +	g_Cvar_Alltalk = FindConVar("sv_alltalk");
    1.95 +	g_Cvar_FF = FindConVar("mp_friendlyfire");
    1.96 +	
    1.97 +	/*
    1.98 +	g_Cvar_Show = FindConVar("sm_vote_show");
    1.99 +	if (g_Cvar_Show == INVALID_HANDLE)
   1.100 +	{
   1.101 +		g_Cvar_Show = CreateConVar("sm_vote_show", "1", "Show player's votes? Default on.", 0, true, 0.0, true, 1.0);
   1.102 +	}
   1.103 +	*/
   1.104 +}
   1.105 +
   1.106 +public Action:Command_VoteGravity(client, args)
   1.107 +{
   1.108 +	if (args < 1)
   1.109 +	{
   1.110 +		ReplyToCommand(client, "[SM] Usage: sm_votegravity <amount> [amount2] ... [amount5]");
   1.111 +		return Plugin_Handled;	
   1.112 +	}
   1.113 +	
   1.114 +	if (IsVoteInProgress())
   1.115 +	{
   1.116 +		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   1.117 +		return Plugin_Handled;
   1.118 +	}
   1.119 +	
   1.120 +	if (!TestVoteDelay(client))
   1.121 +	{
   1.122 +		return Plugin_Handled;
   1.123 +	}
   1.124 +	
   1.125 +	decl String:text[256];
   1.126 +	GetCmdArgString(text, sizeof(text));
   1.127 +
   1.128 +	decl String:items[5][64];
   1.129 +	new count;	
   1.130 +	new len, pos;
   1.131 +	
   1.132 +	while (pos != -1 && count < 5)
   1.133 +	{	
   1.134 +		pos = BreakString(text[len], items[count], sizeof(items[]));
   1.135 +		
   1.136 +		decl Float:temp;
   1.137 +		if (StringToFloatEx(items[count], temp) == 0)
   1.138 +		{
   1.139 +			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   1.140 +			return Plugin_Handled;
   1.141 +		}		
   1.142 +
   1.143 +		count++;
   1.144 +		
   1.145 +		if (pos != -1)
   1.146 +		{
   1.147 +			len += pos;
   1.148 +		}	
   1.149 +	}
   1.150 +
   1.151 +	ShowActivity(client, "%t", "Initiated Vote Gravity");
   1.152 +	
   1.153 +	g_voteType = voteType:gravity;
   1.154 +	
   1.155 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   1.156 +	
   1.157 +	if (count == 1)
   1.158 +	{
   1.159 +		strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), items[0]);
   1.160 +			
   1.161 +		SetMenuTitle(g_hVoteMenu, "Change Gravity To");
   1.162 +		AddMenuItem(g_hVoteMenu, items[0], "Yes");
   1.163 +		AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   1.164 +	}
   1.165 +	else
   1.166 +	{
   1.167 +		g_voteInfo[VOTE_NAME][0] = '\0';
   1.168 +		
   1.169 +		SetMenuTitle(g_hVoteMenu, "Gravity Vote");
   1.170 +		for (new i = 0; i < count; i++)
   1.171 +		{
   1.172 +			AddMenuItem(g_hVoteMenu, items[i], items[i]);
   1.173 +		}	
   1.174 +	}
   1.175 +	
   1.176 +	SetMenuExitButton(g_hVoteMenu, false);
   1.177 +	VoteMenuToAll(g_hVoteMenu, 20);		
   1.178 +	
   1.179 +	return Plugin_Handled;	
   1.180 +}
   1.181 +
   1.182 +public Action:Command_VoteBurn(client, args)
   1.183 +{
   1.184 +	if (args < 1)
   1.185 +	{
   1.186 +		ReplyToCommand(client, "[SM] Usage: sm_voteburn <player>");
   1.187 +		return Plugin_Handled;	
   1.188 +	}
   1.189 +	
   1.190 +	if (IsVoteInProgress())
   1.191 +	{
   1.192 +		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   1.193 +		return Plugin_Handled;
   1.194 +	}	
   1.195 +	
   1.196 +	if (!TestVoteDelay(client))
   1.197 +	{
   1.198 +		return Plugin_Handled;
   1.199 +	}
   1.200 +	
   1.201 +	decl String:text[256], String:arg[64];
   1.202 +	GetCmdArgString(text, sizeof(text));
   1.203 +	
   1.204 +	BreakString(text, arg, sizeof(arg));
   1.205 +	
   1.206 +	new target = FindTarget(client, arg);
   1.207 +	if (target == -1)
   1.208 +	{
   1.209 +		return Plugin_Handled;
   1.210 +	}
   1.211 +
   1.212 +	if (!IsPlayerAlive(target))
   1.213 +	{
   1.214 +		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   1.215 +		return Plugin_Handled;
   1.216 +	}
   1.217 +	
   1.218 +	g_voteClient[VOTE_CLIENTID] = target;
   1.219 +	GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
   1.220 +
   1.221 +	ShowActivity(client, "%t", "Initiated Vote Burn", g_voteInfo[VOTE_NAME]);
   1.222 +	
   1.223 +	g_voteType = voteType:burn;
   1.224 +	
   1.225 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   1.226 +	SetMenuTitle(g_hVoteMenu, "Voteburn Player");
   1.227 +	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   1.228 +	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   1.229 +	SetMenuExitButton(g_hVoteMenu, false);
   1.230 +	VoteMenuToAll(g_hVoteMenu, 20);
   1.231 +	
   1.232 +	return Plugin_Handled;
   1.233 +}
   1.234 +
   1.235 +public Action:Command_VoteSlay(client, args)
   1.236 +{
   1.237 +	if (args < 1)
   1.238 +	{
   1.239 +		ReplyToCommand(client, "[SM] Usage: sm_voteslay <player>");
   1.240 +		return Plugin_Handled;	
   1.241 +	}
   1.242 +	
   1.243 +	if (IsVoteInProgress())
   1.244 +	{
   1.245 +		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   1.246 +		return Plugin_Handled;
   1.247 +	}	
   1.248 +	
   1.249 +	if (!TestVoteDelay(client))
   1.250 +	{
   1.251 +		return Plugin_Handled;
   1.252 +	}
   1.253 +	
   1.254 +	decl String:text[256], String:arg[64];
   1.255 +	GetCmdArgString(text, sizeof(text));
   1.256 +	
   1.257 +	BreakString(text, arg, sizeof(arg));
   1.258 +	
   1.259 +	new target = FindTarget(client, arg);
   1.260 +	if (target == -1)
   1.261 +	{
   1.262 +		return Plugin_Handled;
   1.263 +	}
   1.264 +
   1.265 +	if (!IsPlayerAlive(target))
   1.266 +	{
   1.267 +		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   1.268 +		return Plugin_Handled;
   1.269 +	}
   1.270 +	
   1.271 +	g_voteClient[VOTE_CLIENTID] = target;
   1.272 +	GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
   1.273 +
   1.274 +	ShowActivity(client, "%t", "Initiated Vote Slay", g_voteInfo[VOTE_NAME]);
   1.275 +	
   1.276 +	g_voteType = voteType:slay;
   1.277 +	
   1.278 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   1.279 +	SetMenuTitle(g_hVoteMenu, "Voteslay Player");
   1.280 +	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   1.281 +	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   1.282 +	SetMenuExitButton(g_hVoteMenu, false);
   1.283 +	VoteMenuToAll(g_hVoteMenu, 20);
   1.284 +	
   1.285 +	return Plugin_Handled;
   1.286 +}
   1.287 +
   1.288 +public Action:Command_VoteAlltalk(client, args)
   1.289 +{
   1.290 +	if (args > 0)
   1.291 +	{
   1.292 +		ReplyToCommand(client, "[SM] Usage: sm_votealltalk");
   1.293 +		return Plugin_Handled;	
   1.294 +	}
   1.295 +	
   1.296 +	if (IsVoteInProgress())
   1.297 +	{
   1.298 +		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   1.299 +		return Plugin_Handled;
   1.300 +	}	
   1.301 +	
   1.302 +	if (!TestVoteDelay(client))
   1.303 +	{
   1.304 +		return Plugin_Handled;
   1.305 +	}
   1.306 +	
   1.307 +	ShowActivity(client, "%t", "Initiated Vote Alltalk");
   1.308 +	
   1.309 +	g_voteType = voteType:alltalk;
   1.310 +	g_voteInfo[VOTE_NAME][0] = '\0';
   1.311 +
   1.312 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   1.313 +	
   1.314 +	if (GetConVarBool(g_Cvar_Alltalk))
   1.315 +	{
   1.316 +		SetMenuTitle(g_hVoteMenu, "Votealltalk Off");
   1.317 +	}
   1.318 +	else
   1.319 +	{
   1.320 +		SetMenuTitle(g_hVoteMenu, "Votealltalk On");
   1.321 +	}
   1.322 +	
   1.323 +	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   1.324 +	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   1.325 +	SetMenuExitButton(g_hVoteMenu, false);
   1.326 +	VoteMenuToAll(g_hVoteMenu, 20);
   1.327 +	
   1.328 +	return Plugin_Handled;
   1.329 +}
   1.330 +
   1.331 +public Action:Command_VoteFF(client, args)
   1.332 +{
   1.333 +	if (args > 0)
   1.334 +	{
   1.335 +		ReplyToCommand(client, "[SM] Usage: sm_voteff");
   1.336 +		return Plugin_Handled;	
   1.337 +	}
   1.338 +	
   1.339 +	if (IsVoteInProgress())
   1.340 +	{
   1.341 +		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   1.342 +		return Plugin_Handled;
   1.343 +	}	
   1.344 +	
   1.345 +	if (!TestVoteDelay(client))
   1.346 +	{
   1.347 +		return Plugin_Handled;
   1.348 +	}
   1.349 +	
   1.350 +	ShowActivity(client, "%t", "Initiated Vote FF");
   1.351 +	
   1.352 +	g_voteType = voteType:ff;
   1.353 +	g_voteInfo[VOTE_NAME][0] = '\0';
   1.354 +	
   1.355 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   1.356 +	
   1.357 +	if (GetConVarBool(g_Cvar_Alltalk))
   1.358 +	{
   1.359 +		SetMenuTitle(g_hVoteMenu, "Voteff Off");
   1.360 +	}
   1.361 +	else
   1.362 +	{
   1.363 +		SetMenuTitle(g_hVoteMenu, "Voteff On");
   1.364 +	}
   1.365 +	
   1.366 +	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   1.367 +	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   1.368 +	SetMenuExitButton(g_hVoteMenu, false);
   1.369 +	VoteMenuToAll(g_hVoteMenu, 20);
   1.370 +	
   1.371 +	return Plugin_Handled;
   1.372 +}
   1.373 +
   1.374 +public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
   1.375 +{
   1.376 +	if (action == MenuAction_End)
   1.377 +	{
   1.378 +		VoteMenuClose();
   1.379 +	}
   1.380 +	else if (action == MenuAction_Display)
   1.381 +	{
   1.382 +	 	decl String:title[64];
   1.383 +		GetMenuTitle(g_hVoteMenu, title, sizeof(title));
   1.384 +
   1.385 +	 	decl String:buffer[255];
   1.386 +		Format(buffer, sizeof(buffer), "%T", title, param1, g_voteInfo[VOTE_NAME]);
   1.387 +
   1.388 +		SetMenuTitle(g_hVoteMenu, buffer);
   1.389 +	}
   1.390 +	else if (action == MenuAction_DisplayItem)
   1.391 +	{
   1.392 +		decl String:display[64];
   1.393 +		GetMenuItem(menu, param2, "", 0, _, display, sizeof(display));
   1.394 +	 
   1.395 +	 	if (strcmp(display, VOTE_NO) == 0 || strcmp(display, VOTE_YES) == 0)
   1.396 +	 	{
   1.397 +			decl String:buffer[255];
   1.398 +			Format(buffer, sizeof(buffer), "%T", display, param1);
   1.399 +
   1.400 +			return RedrawMenuItem(buffer);
   1.401 +		}
   1.402 +	}
   1.403 +	/* else if (action == MenuAction_Select)
   1.404 +	{
   1.405 +		VoteSelect(menu, param1, param2);
   1.406 +	}*/
   1.407 +	else if (action == MenuAction_NoVotes)
   1.408 +	{
   1.409 +		PrintToChatAll("[SM] %t", "No Votes Cast");
   1.410 +	}
   1.411 +	else if (action == MenuAction_VoteEnd)
   1.412 +	{
   1.413 +		decl String:item[64];
   1.414 +		new Float:percent, Float:limit, votes, totalVotes;
   1.415 +
   1.416 +		GetMenuVoteInfo(param2, votes, totalVotes);
   1.417 +		GetMenuItem(menu, param1, item, sizeof(item));
   1.418 +		
   1.419 +		if (strcmp(item, VOTE_NO) == 0 && param1 == 1)
   1.420 +		{
   1.421 +			votes = totalVotes - votes; // Reverse the votes to be in relation to the Yes option.
   1.422 +		}
   1.423 +		
   1.424 +		percent = GetVotePercent(votes, totalVotes);
   1.425 +		
   1.426 +		limit = GetConVarFloat(g_Cvar_Limits[g_voteType]);
   1.427 +
   1.428 +		// A multi-argument vote is "always successful", but have to check if its a Yes/No vote.
   1.429 +		if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1))
   1.430 +		{
   1.431 +			LogMessage("Vote failed.");
   1.432 +			PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
   1.433 +		}
   1.434 +		else
   1.435 +		{
   1.436 +			PrintToChatAll("[SM] %t", "Vote Successful", RoundToNearest(100.0*percent), totalVotes);
   1.437 +			
   1.438 +			switch (g_voteType)
   1.439 +			{
   1.440 +				case (voteType:gravity):
   1.441 +				{
   1.442 +					PrintToChatAll("[SM] %t", "Cvar changed", "sv_gravity", item);					
   1.443 +					LogMessage("Changing gravity to %s due to vote.", item);
   1.444 +					SetConVarInt(g_Cvar_Gravity, StringToInt(item));
   1.445 +				}
   1.446 +				
   1.447 +				case (voteType:burn):
   1.448 +				{
   1.449 +					PrintToChatAll("[SM] %t", "Ignited player", g_voteInfo[VOTE_NAME]);					
   1.450 +					LogMessage("Vote burn successful, igniting \"%L\"", g_voteClient[VOTE_CLIENTID]);
   1.451 +					
   1.452 +					IgniteEntity(g_voteClient[VOTE_CLIENTID], 19.8);	
   1.453 +				}
   1.454 +				
   1.455 +				case (voteType:slay):
   1.456 +				{
   1.457 +					PrintToChatAll("[SM] %t", "Slayed player", g_voteInfo[VOTE_NAME]);					
   1.458 +					LogMessage("Vote slay successful, slaying \"%L\"", g_voteClient[VOTE_CLIENTID]);
   1.459 +					
   1.460 +					ExtinguishEntity(g_voteClient[VOTE_CLIENTID]);
   1.461 +					ForcePlayerSuicide(g_voteClient[VOTE_CLIENTID]);
   1.462 +				}
   1.463 +				
   1.464 +				case (voteType:alltalk):
   1.465 +				{
   1.466 +					PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1"));
   1.467 +					LogMessage("Changing alltalk to %s due to vote.", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1"));
   1.468 +					SetConVarBool(g_Cvar_Alltalk, !GetConVarBool(g_Cvar_Alltalk));
   1.469 +				}
   1.470 +				
   1.471 +				case (voteType:ff):
   1.472 +				{
   1.473 +					PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (GetConVarBool(g_Cvar_FF) ? "0" : "1"));
   1.474 +					LogMessage("Changing friendly fire to %s due to vote.", (GetConVarBool(g_Cvar_FF) ? "0" : "1"));
   1.475 +					SetConVarBool(g_Cvar_FF, !GetConVarBool(g_Cvar_FF));
   1.476 +				}				
   1.477 +			}
   1.478 +		}
   1.479 +	}
   1.480 +	
   1.481 +	return 0;
   1.482 +}
   1.483 +
   1.484 +/*
   1.485 +VoteSelect(Handle:menu, param1, param2 = 0)
   1.486 +{
   1.487 +	if (GetConVarInt(g_Cvar_VoteShow) == 1)
   1.488 +	{
   1.489 +		decl String:voter[64], String:junk[64], String:choice[64];
   1.490 +		GetClientName(param1, voter, sizeof(voter));
   1.491 +		GetMenuItem(menu, param2, junk, sizeof(junk), _, choice, sizeof(choice));
   1.492 +		PrintToChatAll("[SM] %T", "Vote Select", LANG_SERVER, voter, choice);
   1.493 +	}
   1.494 +}
   1.495 +*/
   1.496 +
   1.497 +VoteMenuClose()
   1.498 +{
   1.499 +	CloseHandle(g_hVoteMenu);
   1.500 +	g_hVoteMenu = INVALID_HANDLE;
   1.501 +}
   1.502 +
   1.503 +Float:GetVotePercent(votes, totalVotes)
   1.504 +{
   1.505 +	return FloatDiv(float(votes),float(totalVotes));
   1.506 +}
   1.507 +
   1.508 +bool:TestVoteDelay(client)
   1.509 +{
   1.510 + 	new delay = CheckVoteDelay();
   1.511 + 	
   1.512 + 	if (delay > 0)
   1.513 + 	{
   1.514 + 		if (delay > 60)
   1.515 + 		{
   1.516 + 			ReplyToCommand(client, "[SM] %t", "Vote Delay Minutes", delay % 60);
   1.517 + 		}
   1.518 + 		else
   1.519 + 		{
   1.520 + 			ReplyToCommand(client, "[SM] %t", "Vote Delay Seconds", delay);
   1.521 + 		}
   1.522 + 		
   1.523 + 		return false;
   1.524 + 	}
   1.525 + 	
   1.526 +	return true;
   1.527 +}
   1.528 \ No newline at end of file
     2.1 --- a/plugins/basevotes.sp	Thu Aug 09 20:06:42 2007 +0000
     2.2 +++ b/plugins/basevotes.sp	Thu Aug 09 23:34:53 2007 +0000
     2.3 @@ -33,21 +33,22 @@
     2.4  	url = "http://www.sourcemod.net/"
     2.5  };
     2.6  
     2.7 +#define VOTE_NO "###no###"
     2.8 +#define VOTE_YES "###yes###"
     2.9 +
    2.10  new Handle:g_hVoteMenu = INVALID_HANDLE;
    2.11  
    2.12  new Handle:g_hBanForward = INVALID_HANDLE;
    2.13  
    2.14 -new Handle:g_Cvar_VoteMap = INVALID_HANDLE;
    2.15 -new Handle:g_Cvar_VoteKick = INVALID_HANDLE;
    2.16 -new Handle:g_Cvar_VoteBan = INVALID_HANDLE;
    2.17 +new Handle:g_Cvar_Limits[3] = {INVALID_HANDLE, ...};
    2.18  //new Handle:g_Cvar_VoteSay = INVALID_HANDLE;
    2.19  
    2.20  enum voteType
    2.21  {
    2.22 -	question = 0,
    2.23  	map,
    2.24  	kick,
    2.25 -	ban
    2.26 +	ban,
    2.27 +	question
    2.28  }
    2.29  
    2.30  new voteType:g_voteType = voteType:question;
    2.31 @@ -66,8 +67,6 @@
    2.32  
    2.33  new String:g_voteArg[256];	/* Used to hold ban/kick reasons or vote questions */
    2.34  
    2.35 -// Temporary global until GetMenuTitle() is added.
    2.36 -new String:g_votetitle[64];
    2.37  
    2.38  public OnPluginStart()
    2.39  {
    2.40 @@ -79,11 +78,17 @@
    2.41  	RegAdminCmd("sm_voteban", Command_Voteban, ADMFLAG_VOTE|ADMFLAG_BAN, "sm_voteban <player> [reason]");
    2.42  	RegAdminCmd("sm_vote", Command_Vote, ADMFLAG_VOTE, "sm_vote <question> [Answer1] [Answer2] ... [Answer5]");
    2.43  
    2.44 -	//g_Cvar_VoteShow = CreateConVar("sm_vote_show", "1", "Show player's votes? Default on.", 0, true, 0.0, true, 1.0);	
    2.45 +	/*
    2.46 +	g_Cvar_Show = FindConVar("sm_vote_show");
    2.47 +	if (g_Cvar_Show == INVALID_HANDLE)
    2.48 +	{
    2.49 +		g_Cvar_Show = CreateConVar("sm_vote_show", "1", "Show player's votes? Default on.", 0, true, 0.0, true, 1.0);
    2.50 +	}
    2.51 +	*/
    2.52  
    2.53 -	g_Cvar_VoteMap = CreateConVar("sm_vote_map", "0.60", "percent required for successful map vote.", 0, true, 0.05, true, 1.0);
    2.54 -	g_Cvar_VoteKick = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);	
    2.55 -	g_Cvar_VoteBan = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);	
    2.56 +	g_Cvar_Limits[0] = CreateConVar("sm_vote_map", "0.60", "percent required for successful map vote.", 0, true, 0.05, true, 1.0);
    2.57 +	g_Cvar_Limits[1] = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);	
    2.58 +	g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);		
    2.59  	
    2.60  	g_hBanForward = CreateGlobalForward("OnClientBanned", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_String);
    2.61  }
    2.62 @@ -101,6 +106,11 @@
    2.63  		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
    2.64  		return Plugin_Handled;
    2.65  	}
    2.66 +		
    2.67 +	if (!TestVoteDelay(client))
    2.68 +	{
    2.69 +		return Plugin_Handled;
    2.70 +	}
    2.71  	
    2.72  	decl String:text[256];
    2.73  	GetCmdArgString(text, sizeof(text));
    2.74 @@ -131,26 +141,20 @@
    2.75  	
    2.76  	g_voteType = voteType:map;
    2.77  	
    2.78 -	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MENU_ACTIONS_ALL);
    2.79 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
    2.80  	
    2.81  	if (mapCount == 1)
    2.82  	{
    2.83  		strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
    2.84 -		
    2.85 -		// Temp
    2.86 -		strcopy(g_votetitle, sizeof(g_votetitle), "Change Map To");
    2.87  			
    2.88  		SetMenuTitle(g_hVoteMenu, "Change Map To");
    2.89  		AddMenuItem(g_hVoteMenu, maps[0], "Yes");
    2.90 -		AddMenuItem(g_hVoteMenu, "no", "No");
    2.91 +		AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
    2.92  	}
    2.93  	else
    2.94  	{
    2.95  		g_voteInfo[VOTE_NAME][0] = '\0';
    2.96  		
    2.97 -		// Temp
    2.98 -		strcopy(g_votetitle, sizeof(g_votetitle), "Map Vote");
    2.99 -		
   2.100  		SetMenuTitle(g_hVoteMenu, "Map Vote");
   2.101  		for (new i = 0; i < mapCount; i++)
   2.102  		{
   2.103 @@ -177,6 +181,11 @@
   2.104  		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   2.105  		return Plugin_Handled;
   2.106  	}
   2.107 +		
   2.108 +	if (!TestVoteDelay(client))
   2.109 +	{
   2.110 +		return Plugin_Handled;
   2.111 +	}
   2.112  	
   2.113  	decl String:text[256];
   2.114  	GetCmdArgString(text, sizeof(text));
   2.115 @@ -201,13 +210,13 @@
   2.116  	
   2.117  	g_voteType = voteType:question;
   2.118  	
   2.119 -	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MENU_ACTIONS_ALL);
   2.120 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   2.121  	SetMenuTitle(g_hVoteMenu, "%s?", g_voteArg);
   2.122  	
   2.123  	if (answerCount < 2)
   2.124  	{
   2.125 -		AddMenuItem(g_hVoteMenu, "Yes", "Yes");
   2.126 -		AddMenuItem(g_hVoteMenu, "No", "No");
   2.127 +		AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   2.128 +		AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   2.129  	}
   2.130  	else
   2.131  	{
   2.132 @@ -236,7 +245,12 @@
   2.133  		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   2.134  		return Plugin_Handled;
   2.135  	}	
   2.136 -
   2.137 +	
   2.138 +	if (!TestVoteDelay(client))
   2.139 +	{
   2.140 +		return Plugin_Handled;
   2.141 +	}
   2.142 +	
   2.143  	decl String:text[256], String:arg[64];
   2.144  	GetCmdArgString(text, sizeof(text));
   2.145  	
   2.146 @@ -266,13 +280,10 @@
   2.147  	
   2.148  	g_voteType = voteType:kick;
   2.149  	
   2.150 -	// Temp
   2.151 -	strcopy(g_votetitle, sizeof(g_votetitle), "Votekick Player");	
   2.152 -	
   2.153 -	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MENU_ACTIONS_ALL);
   2.154 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   2.155  	SetMenuTitle(g_hVoteMenu, "Votekick Player");
   2.156 -	AddMenuItem(g_hVoteMenu, "No", "Yes");
   2.157 -	AddMenuItem(g_hVoteMenu, "No", "No");
   2.158 +	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   2.159 +	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   2.160  	SetMenuExitButton(g_hVoteMenu, false);
   2.161  	VoteMenuToAll(g_hVoteMenu, 20);
   2.162  	
   2.163 @@ -292,7 +303,12 @@
   2.164  		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
   2.165  		return Plugin_Handled;
   2.166  	}	
   2.167 -
   2.168 +	
   2.169 +	if (!TestVoteDelay(client))
   2.170 +	{
   2.171 +		return Plugin_Handled;
   2.172 +	}
   2.173 +	
   2.174  	decl String:text[256], String:arg[64];
   2.175  	GetCmdArgString(text, sizeof(text));
   2.176  	
   2.177 @@ -324,13 +340,10 @@
   2.178  
   2.179  	g_voteType = voteType:ban;
   2.180  	
   2.181 -	// Temp
   2.182 -	strcopy(g_votetitle, sizeof(g_votetitle), "Voteban Player");		
   2.183 -	
   2.184 -	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MENU_ACTIONS_ALL);
   2.185 +	g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   2.186  	SetMenuTitle(g_hVoteMenu, "Voteban Player");
   2.187 -	AddMenuItem(g_hVoteMenu, "No", "Yes");
   2.188 -	AddMenuItem(g_hVoteMenu, "No", "No");
   2.189 +	AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
   2.190 +	AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
   2.191  	SetMenuExitButton(g_hVoteMenu, false);
   2.192  	VoteMenuToAll(g_hVoteMenu, 20);
   2.193  	
   2.194 @@ -348,8 +361,7 @@
   2.195  	 	if (g_voteType != voteType:question)
   2.196  	 	{
   2.197  			decl String:title[64];
   2.198 -			//GetMenuTitle(g_hVoteMenu, title, sizeof(title));
   2.199 -			strcopy(title, sizeof(title), g_votetitle);
   2.200 +			GetMenuTitle(g_hVoteMenu, title, sizeof(title));
   2.201  			
   2.202  	 		decl String:buffer[255];
   2.203  			Format(buffer, sizeof(buffer), "%T", title, param1, g_voteInfo[VOTE_NAME]);
   2.204 @@ -374,41 +386,32 @@
   2.205  	{
   2.206  		VoteSelect(menu, param1, param2);
   2.207  	}*/
   2.208 +	else if (action == MenuAction_NoVotes)
   2.209 +	{
   2.210 +		PrintToChatAll("[SM] %t", "No Votes Cast");
   2.211 +	}	
   2.212  	else if (action == MenuAction_VoteEnd)
   2.213  	{
   2.214  		decl String:item[64], String:display[64];
   2.215  		new Float:percent, Float:limit, votes, totalVotes;
   2.216 +
   2.217  		GetMenuVoteInfo(param2, votes, totalVotes);
   2.218 -		
   2.219 -		if (totalVotes < 1)
   2.220 -		{
   2.221 -			PrintToChatAll("[SM] %t", "No Votes Cast");
   2.222 -			return 0;
   2.223 -		}
   2.224 -		
   2.225  		GetMenuItem(menu, param1, item, sizeof(item), _, display, sizeof(display));
   2.226  		
   2.227 -		if (strcmp(display,"No") == 0 && param1 == 1)
   2.228 +		if (strcmp(item, VOTE_NO) == 0 && param1 == 1)
   2.229  		{
   2.230  			votes = totalVotes - votes; // Reverse the votes to be in relation to the Yes option.
   2.231  		}
   2.232  		
   2.233  		percent = GetVotePercent(votes, totalVotes);
   2.234  		
   2.235 -		switch (g_voteType)
   2.236 +		if (g_voteType != voteType:question)
   2.237  		{
   2.238 -			case (voteType:map):
   2.239 -				limit = GetConVarFloat(g_Cvar_VoteMap);
   2.240 -				
   2.241 -			case (voteType:kick):
   2.242 -				limit = GetConVarFloat(g_Cvar_VoteKick);
   2.243 -				
   2.244 -			case (voteType:ban):
   2.245 -				limit = GetConVarFloat(g_Cvar_VoteBan);
   2.246 +			limit = GetConVarFloat(g_Cvar_Limits[g_voteType]);
   2.247  		}
   2.248  
   2.249  		// A multi-argument vote is "always successful", but have to check if its a Yes/No vote.
   2.250 -		if ((strcmp(display,"Yes") == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(display,"No") == 0 && param1 == 1))
   2.251 +		if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1))
   2.252  		{
   2.253  			LogMessage("Vote failed.");
   2.254  			PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
   2.255 @@ -421,6 +424,11 @@
   2.256  			{
   2.257  				case (voteType:question):
   2.258  				{
   2.259 +					if (strcmp(item, VOTE_NO) == 0 || strcmp(item, VOTE_YES) == 0)
   2.260 +					{
   2.261 +						strcopy(item, sizeof(item), display);
   2.262 +					}
   2.263 +					
   2.264  					PrintToChatAll("[SM] %t", "Vote End", g_voteArg, item);
   2.265  				}
   2.266  				
   2.267 @@ -498,6 +506,27 @@
   2.268  	return FloatDiv(float(votes),float(totalVotes));
   2.269  }
   2.270  
   2.271 +bool:TestVoteDelay(client)
   2.272 +{
   2.273 + 	new delay = CheckVoteDelay();
   2.274 + 	
   2.275 + 	if (delay > 0)
   2.276 + 	{
   2.277 + 		if (delay > 60)
   2.278 + 		{
   2.279 + 			ReplyToCommand(client, "[SM] %t", "Vote Delay Minutes", delay % 60);
   2.280 + 		}
   2.281 + 		else
   2.282 + 		{
   2.283 + 			ReplyToCommand(client, "[SM] %t", "Vote Delay Seconds", delay);
   2.284 + 		}
   2.285 + 		
   2.286 + 		return false;
   2.287 + 	}
   2.288 + 	
   2.289 +	return true;
   2.290 +}
   2.291 +
   2.292  public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
   2.293  {
   2.294  	decl String:mapname[65];
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/translations/basefunvotes.phrases.txt	Thu Aug 09 23:34:53 2007 +0000
     3.3 @@ -0,0 +1,78 @@
     3.4 +"Phrases"
     3.5 +{
     3.6 +	"Initiated Vote Gravity"
     3.7 +	{
     3.8 +		"en"			"Initiated a gravity vote."
     3.9 +	}	
    3.10 +	
    3.11 +	"Initiated Vote Burn"
    3.12 +	{
    3.13 +		"#format"		"{1:s}"
    3.14 +		"en"			"Initiated a voteburn against {1}."
    3.15 +	}
    3.16 +	
    3.17 +	"Initiated Vote Slay"
    3.18 +	{
    3.19 +		"#format"		"{1:s}"
    3.20 +		"en"			"Initiated a voteslay against {1}."
    3.21 +	}
    3.22 +	
    3.23 +	"Initiated Vote Alltalk"
    3.24 +	{
    3.25 +		"en"			"Initiated an alltalk vote."
    3.26 +	}
    3.27 +	
    3.28 +	"Initiated Vote FF"
    3.29 +	{
    3.30 +		"en"			"Initiated a friendly fire vote."
    3.31 +	}	
    3.32 +	
    3.33 +	"Gravity Vote"
    3.34 +	{
    3.35 +		"#format"		"{1:s}"
    3.36 +		"en"			"Gravity Vote: {1}"
    3.37 +	}
    3.38 +	
    3.39 +	"Change Gravity To"
    3.40 +	{
    3.41 +		"#format"		"{1:s}"
    3.42 +		"en"			"Change gravity to {1}?"
    3.43 +	}	
    3.44 +
    3.45 +	"Voteburn Player"
    3.46 +	{
    3.47 +		"#format"		"{1:s}"
    3.48 +		"en"			"Burn {1}?"
    3.49 +	}
    3.50 +	
    3.51 +	"Voteslay Player"
    3.52 +	{
    3.53 +		"#format"		"{1:s}"
    3.54 +		"en"			"Slay {1}?"
    3.55 +	}
    3.56 +	
    3.57 +	"Votealltalk Off"
    3.58 +	{
    3.59 +		"#format"		"{1:s}"
    3.60 +		"en"			"Turn alltalk off? {1}"
    3.61 +	}
    3.62 +	
    3.63 +	"Votealltalk On"
    3.64 +	{
    3.65 +		"#format"		"{1:s}"
    3.66 +		"en"			"Turn alltalk on? {1}"
    3.67 +	}	
    3.68 +	
    3.69 +	"Voteff Off"
    3.70 +	{
    3.71 +		"#format"		"{1:s}"
    3.72 +		"en"			"Turn friendly fire off? {1}"
    3.73 +	}
    3.74 +	
    3.75 +	"Voteff On"
    3.76 +	{
    3.77 +		"#format"		"{1:s}"
    3.78 +		"en"			"Turn friendly fire on? {1}"
    3.79 +	}
    3.80 +	
    3.81 +}
    3.82 \ No newline at end of file
     4.1 --- a/translations/common.phrases.txt	Thu Aug 09 20:06:42 2007 +0000
     4.2 +++ b/translations/common.phrases.txt	Thu Aug 09 23:34:53 2007 +0000
     4.3 @@ -199,4 +199,16 @@
     4.4  	{
     4.5  		"en"			"No votes were cast."
     4.6  	}	
     4.7 +	
     4.8 +	"Vote Delay Minutes"
     4.9 +	{
    4.10 +		"#format"		"{1:d}"
    4.11 +		"en"			"You must wait {1} minutes before starting another vote."
    4.12 +	}
    4.13 +	
    4.14 +	"Vote Delay Seconds"
    4.15 +	{
    4.16 +		"#format"		"{1:d}"
    4.17 +		"en"			"You must wait {1} seconds before starting another vote."
    4.18 +	}	
    4.19  }