From 8fd0cbecf74998e17e2ed72a8586f4547dd9221b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 9 Nov 2014 16:28:03 -0800 Subject: [PATCH] Port funvotes.sp. --- plugins/funvotes.sp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/plugins/funvotes.sp b/plugins/funvotes.sp index d8a27a14..2d2c6e2e 100644 --- a/plugins/funvotes.sp +++ b/plugins/funvotes.sp @@ -53,10 +53,10 @@ public Plugin:myinfo = new Handle:g_hVoteMenu = INVALID_HANDLE; -new Handle:g_Cvar_Limits[5] = {INVALID_HANDLE, ...}; -new Handle:g_Cvar_Gravity = INVALID_HANDLE; -new Handle:g_Cvar_Alltalk = INVALID_HANDLE; -new Handle:g_Cvar_FF = INVALID_HANDLE; +ConVar g_Cvar_Limits[5] = {null, ...}; +ConVar g_Cvar_Gravity; +ConVar g_Cvar_Alltalk; +ConVar g_Cvar_FF; // 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) { - decl String:item[64]; - new Float:percent, Float:limit, votes, totalVotes; + char item[64]; + float percent, limit; + int votes, totalVotes; GetMenuVoteInfo(param2, votes, totalVotes); GetMenuItem(menu, param1, item, sizeof(item)); @@ -212,7 +213,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) 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. */ @@ -235,7 +236,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) { PrintToChatAll("[SM] %t", "Cvar changed", "sv_gravity", 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): @@ -257,16 +258,16 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) case (voteType:alltalk): { - PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1")); - LogAction(-1, -1, "Changing alltalk to %s due to vote.", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1")); - SetConVarBool(g_Cvar_Alltalk, !GetConVarBool(g_Cvar_Alltalk)); + PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (g_Cvar_Alltalk.BoolValue ? "0" : "1")); + LogAction(-1, -1, "Changing alltalk to %s due to vote.", (g_Cvar_Alltalk.BoolValue ? "0" : "1")); + g_Cvar_Alltalk.BoolValue = !g_Cvar_Alltalk.BoolValue; } case (voteType:ff): { - PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (GetConVarBool(g_Cvar_FF) ? "0" : "1")); - LogAction(-1, -1, "Changing friendly fire to %s due to vote.", (GetConVarBool(g_Cvar_FF) ? "0" : "1")); - SetConVarBool(g_Cvar_FF, !GetConVarBool(g_Cvar_FF)); + PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (g_Cvar_FF.BoolValue ? "0" : "1")); + LogAction(-1, -1, "Changing friendly fire to %s due to vote.", (g_Cvar_FF.BoolValue ? "0" : "1")); + g_Cvar_FF.BoolValue = !g_Cvar_FF.BoolValue; } } }