diff --git a/plugins/basevotes.sp b/plugins/basevotes.sp index a428be7d..9fa38ffc 100644 --- a/plugins/basevotes.sp +++ b/plugins/basevotes.sp @@ -69,9 +69,7 @@ voteType g_voteType = question; // Menu API does not provide us with a way to pass multiple peices of data with a single // choice, so some globals are used to hold stuff. // -#define VOTE_CLIENTID 0 -#define VOTE_USERID 1 -int g_voteClient[2]; /* Holds the target's client id and user id */ +int g_voteTarget; /* Holds the target's user id */ #define VOTE_NAME 0 #define VOTE_AUTHID 1 @@ -287,12 +285,10 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa limit = g_Cvar_Limits[g_voteType].FloatValue; } - /* :TODO: g_voteClient[userid] needs to be checked */ - // A multi-argument vote is "always successful", but have to check if its a Yes/No vote. if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1)) { - /* :TODO: g_voteClient[userid] should be used here and set to -1 if not applicable. + /* :TODO: g_voteTarget should be used here and set to -1 if not applicable. */ LogAction(-1, -1, "Vote failed."); PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes); @@ -327,33 +323,49 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa case (kick): { - if (g_voteArg[0] == '\0') + int voteTarget; + if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0) { - strcopy(g_voteArg, sizeof(g_voteArg), "Votekicked"); + LogAction(-1, -1, "Vote kick failed, unable to kick \"%s\" (reason \"%s\")", g_voteInfo[VOTE_NAME], "Player no longer available"); + } + else + { + if (g_voteArg[0] == '\0') + { + strcopy(g_voteArg, sizeof(g_voteArg), "Votekicked"); + } + + PrintToChatAll("[SM] %t", "Kicked target", "_s", g_voteInfo[VOTE_NAME]); + LogAction(-1, voteTarget, "Vote kick successful, kicked \"%L\" (reason \"%s\")", voteTarget, g_voteArg); + + ServerCommand("kickid %d \"%s\"", g_voteTarget, g_voteArg); } - - PrintToChatAll("[SM] %t", "Kicked target", "_s", g_voteInfo[VOTE_NAME]); - LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote kick successful, kicked \"%L\" (reason \"%s\")", g_voteClient[VOTE_CLIENTID], g_voteArg); - - ServerCommand("kickid %d \"%s\"", g_voteClient[VOTE_USERID], g_voteArg); } case (ban): { - if (g_voteArg[0] == '\0') + int voteTarget; + if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0) { - strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned"); + LogAction(-1, -1, "Vote ban failed, unable to ban \"%s\" (reason \"%s\")", g_voteInfo[VOTE_NAME], "Player no longer available"); + } + else + { + if (g_voteArg[0] == '\0') + { + strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned"); + } + + PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30); + LogAction(-1, voteTarget, "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", voteTarget, g_voteArg); + + BanClient(voteTarget, + 30, + BANFLAG_AUTO, + g_voteArg, + "Banned by vote", + "sm_voteban"); } - - PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30); - LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", g_voteClient[VOTE_CLIENTID], g_voteArg); - - BanClient(g_voteClient[VOTE_CLIENTID], - 30, - BANFLAG_AUTO, - g_voteArg, - "Banned by vote", - "sm_voteban"); } } } diff --git a/plugins/basevotes/voteban.sp b/plugins/basevotes/voteban.sp index 2fbcab21..8db7b352 100644 --- a/plugins/basevotes/voteban.sp +++ b/plugins/basevotes/voteban.sp @@ -33,8 +33,7 @@ void DisplayVoteBanMenu(int client, int target) { - g_voteClient[VOTE_CLIENTID] = target; - g_voteClient[VOTE_USERID] = GetClientUserId(target); + g_voteTarget = GetClientUserId(target); GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[])); GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[])); diff --git a/plugins/basevotes/votekick.sp b/plugins/basevotes/votekick.sp index fcf83133..38405073 100644 --- a/plugins/basevotes/votekick.sp +++ b/plugins/basevotes/votekick.sp @@ -33,8 +33,7 @@ void DisplayVoteKickMenu(int client, int target) { - g_voteClient[VOTE_CLIENTID] = target; - g_voteClient[VOTE_USERID] = GetClientUserId(target); + g_voteTarget = GetClientUserId(target); GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[])); diff --git a/plugins/funvotes.sp b/plugins/funvotes.sp index c1b9eea9..59f6f8bb 100644 --- a/plugins/funvotes.sp +++ b/plugins/funvotes.sp @@ -76,14 +76,12 @@ voteType g_voteType = gravity; // Menu API does not provide us with a way to pass multiple peices of data with a single // choice, so some globals are used to hold stuff. // -#define VOTE_CLIENTID 0 -#define VOTE_USERID 1 -int g_voteClient[2]; /* Holds the target's client id and user id */ +int g_voteTarget; /* Holds the target's user id */ #define VOTE_NAME 0 #define VOTE_AUTHID 1 #define VOTE_IP 2 -char g_voteInfo[3][65]; /* Holds the target's name, authid, and IP */ +char g_voteInfo[3][65]; /* Holds the target's name, authid, and IP */ TopMenu hTopMenu; @@ -221,13 +219,10 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa limit = g_Cvar_Limits[g_voteType].FloatValue; - /* :TODO: g_voteClient[userid] needs to be checked. - */ - // A multi-argument vote is "always successful", but have to check if its a Yes/No vote. if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1)) { - /* :TODO: g_voteClient[userid] should be used here and set to -1 if not applicable. + /* :TODO: g_voteTarget should be used here and set to -1 if not applicable. */ LogAction(-1, -1, "Vote failed."); PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes); @@ -247,19 +242,35 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa case (burn): { - PrintToChatAll("[SM] %t", "Set target on fire", "_s", g_voteInfo[VOTE_NAME]); - LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote burn successful, igniting \"%L\"", g_voteClient[VOTE_CLIENTID]); - - IgniteEntity(g_voteClient[VOTE_CLIENTID], 19.8); + int voteTarget; + if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0) + { + LogAction(-1, -1, "Vote burn failed, unable to burn \"%s\" (reason \"%s\")", g_voteInfo[VOTE_NAME], "Player no longer available"); + } + else + { + PrintToChatAll("[SM] %t", "Set target on fire", "_s", g_voteInfo[VOTE_NAME]); + LogAction(-1, voteTarget, "Vote burn successful, igniting \"%L\"", voteTarget); + + IgniteEntity(voteTarget, 19.8); + } } case (slay): { - PrintToChatAll("[SM] %t", "Slayed player", g_voteInfo[VOTE_NAME]); - LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote slay successful, slaying \"%L\"", g_voteClient[VOTE_CLIENTID]); - - ExtinguishEntity(g_voteClient[VOTE_CLIENTID]); - ForcePlayerSuicide(g_voteClient[VOTE_CLIENTID]); + int voteTarget; + if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0) + { + LogAction(-1, -1, "Vote slay failed, unable to slay \"%s\" (reason \"%s\")", g_voteInfo[VOTE_NAME], "Player no longer available"); + } + else + { + PrintToChatAll("[SM] %t", "Slayed player", g_voteInfo[VOTE_NAME]); + LogAction(-1, voteTarget, "Vote slay successful, slaying \"%L\"", voteTarget); + + ExtinguishEntity(voteTarget); + ForcePlayerSuicide(voteTarget); + } } case (alltalk): diff --git a/plugins/funvotes/voteburn.sp b/plugins/funvotes/voteburn.sp index 438bc3bd..78081f21 100644 --- a/plugins/funvotes/voteburn.sp +++ b/plugins/funvotes/voteburn.sp @@ -39,7 +39,8 @@ void DisplayVoteBurnMenu(int client, int target, char[] name) return; } - g_voteClient[VOTE_CLIENTID] = target; + g_voteTarget = GetClientUserId(target); + GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[])); LogAction(client, target, "\"%L\" initiated a burn vote against \"%L\"", client, target); diff --git a/plugins/funvotes/voteslay.sp b/plugins/funvotes/voteslay.sp index 0ed48c72..530bb2d9 100644 --- a/plugins/funvotes/voteslay.sp +++ b/plugins/funvotes/voteslay.sp @@ -39,7 +39,8 @@ void DisplayVoteSlayMenu(int client, int target, char[] name) return; } - g_voteClient[VOTE_CLIENTID] = target; + g_voteTarget = GetClientUserId(target); + GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[])); LogAction(client, target, "\"%L\" initiated a slay vote against \"%L\"", client, target);