Port funvotes.sp.

This commit is contained in:
David Anderson 2014-11-09 16:28:03 -08:00
parent c425305cde
commit 8fd0cbecf7

View File

@ -53,10 +53,10 @@ public Plugin:myinfo =
new Handle:g_hVoteMenu = INVALID_HANDLE; new Handle:g_hVoteMenu = INVALID_HANDLE;
new Handle:g_Cvar_Limits[5] = {INVALID_HANDLE, ...}; ConVar g_Cvar_Limits[5] = {null, ...};
new Handle:g_Cvar_Gravity = INVALID_HANDLE; ConVar g_Cvar_Gravity;
new Handle:g_Cvar_Alltalk = INVALID_HANDLE; ConVar g_Cvar_Alltalk;
new Handle:g_Cvar_FF = INVALID_HANDLE; ConVar g_Cvar_FF;
// new Handle:g_Cvar_Show = INVALID_HANDLE; // new Handle:g_Cvar_Show = INVALID_HANDLE;
@ -199,8 +199,9 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
} }
else if (action == MenuAction_VoteEnd) else if (action == MenuAction_VoteEnd)
{ {
decl String:item[64]; char item[64];
new Float:percent, Float:limit, votes, totalVotes; float percent, limit;
int votes, totalVotes;
GetMenuVoteInfo(param2, votes, totalVotes); GetMenuVoteInfo(param2, votes, totalVotes);
GetMenuItem(menu, param1, item, sizeof(item)); GetMenuItem(menu, param1, item, sizeof(item));
@ -212,7 +213,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
percent = GetVotePercent(votes, totalVotes); percent = GetVotePercent(votes, totalVotes);
limit = GetConVarFloat(g_Cvar_Limits[g_voteType]); limit = g_Cvar_Limits[g_voteType].FloatValue;
/* :TODO: g_voteClient[userid] needs to be checked. /* :TODO: g_voteClient[userid] needs to be checked.
*/ */
@ -235,7 +236,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
{ {
PrintToChatAll("[SM] %t", "Cvar changed", "sv_gravity", item); PrintToChatAll("[SM] %t", "Cvar changed", "sv_gravity", item);
LogAction(-1, -1, "Changing gravity to %s due to vote.", item); LogAction(-1, -1, "Changing gravity to %s due to vote.", item);
SetConVarInt(g_Cvar_Gravity, StringToInt(item)); g_Cvar_Gravity.IntValue = StringToInt(item);
} }
case (voteType:burn): case (voteType:burn):
@ -257,16 +258,16 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
case (voteType:alltalk): case (voteType:alltalk):
{ {
PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1")); PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (g_Cvar_Alltalk.BoolValue ? "0" : "1"));
LogAction(-1, -1, "Changing alltalk to %s due to vote.", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1")); LogAction(-1, -1, "Changing alltalk to %s due to vote.", (g_Cvar_Alltalk.BoolValue ? "0" : "1"));
SetConVarBool(g_Cvar_Alltalk, !GetConVarBool(g_Cvar_Alltalk)); g_Cvar_Alltalk.BoolValue = !g_Cvar_Alltalk.BoolValue;
} }
case (voteType:ff): case (voteType:ff):
{ {
PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (GetConVarBool(g_Cvar_FF) ? "0" : "1")); PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (g_Cvar_FF.BoolValue ? "0" : "1"));
LogAction(-1, -1, "Changing friendly fire to %s due to vote.", (GetConVarBool(g_Cvar_FF) ? "0" : "1")); LogAction(-1, -1, "Changing friendly fire to %s due to vote.", (g_Cvar_FF.BoolValue ? "0" : "1"));
SetConVarBool(g_Cvar_FF, !GetConVarBool(g_Cvar_FF)); g_Cvar_FF.BoolValue = !g_Cvar_FF.BoolValue;
} }
} }
} }