Ignore vote actions if target is no longer available (#649)
This commit is contained in:
parent
68c00b8ae7
commit
ea6cf26929
@ -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
|
// 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.
|
// choice, so some globals are used to hold stuff.
|
||||||
//
|
//
|
||||||
#define VOTE_CLIENTID 0
|
int g_voteTarget; /* Holds the target's user id */
|
||||||
#define VOTE_USERID 1
|
|
||||||
int g_voteClient[2]; /* Holds the target's client id and user id */
|
|
||||||
|
|
||||||
#define VOTE_NAME 0
|
#define VOTE_NAME 0
|
||||||
#define VOTE_AUTHID 1
|
#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;
|
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.
|
// 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))
|
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.");
|
LogAction(-1, -1, "Vote failed.");
|
||||||
PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
|
PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
|
||||||
@ -326,6 +322,13 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
case (kick):
|
case (kick):
|
||||||
|
{
|
||||||
|
int voteTarget;
|
||||||
|
if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0)
|
||||||
|
{
|
||||||
|
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')
|
if (g_voteArg[0] == '\0')
|
||||||
{
|
{
|
||||||
@ -333,12 +336,20 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrintToChatAll("[SM] %t", "Kicked target", "_s", g_voteInfo[VOTE_NAME]);
|
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);
|
LogAction(-1, voteTarget, "Vote kick successful, kicked \"%L\" (reason \"%s\")", voteTarget, g_voteArg);
|
||||||
|
|
||||||
ServerCommand("kickid %d \"%s\"", g_voteClient[VOTE_USERID], g_voteArg);
|
ServerCommand("kickid %d \"%s\"", g_voteTarget, g_voteArg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case (ban):
|
case (ban):
|
||||||
|
{
|
||||||
|
int voteTarget;
|
||||||
|
if((voteTarget = GetClientOfUserId(g_voteTarget)) == 0)
|
||||||
|
{
|
||||||
|
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')
|
if (g_voteArg[0] == '\0')
|
||||||
{
|
{
|
||||||
@ -346,9 +357,9 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30);
|
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);
|
LogAction(-1, voteTarget, "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", voteTarget, g_voteArg);
|
||||||
|
|
||||||
BanClient(g_voteClient[VOTE_CLIENTID],
|
BanClient(voteTarget,
|
||||||
30,
|
30,
|
||||||
BANFLAG_AUTO,
|
BANFLAG_AUTO,
|
||||||
g_voteArg,
|
g_voteArg,
|
||||||
@ -358,6 +369,7 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,7 @@
|
|||||||
|
|
||||||
void DisplayVoteBanMenu(int client, int target)
|
void DisplayVoteBanMenu(int client, int target)
|
||||||
{
|
{
|
||||||
g_voteClient[VOTE_CLIENTID] = target;
|
g_voteTarget = GetClientUserId(target);
|
||||||
g_voteClient[VOTE_USERID] = GetClientUserId(target);
|
|
||||||
|
|
||||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||||
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
|
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
|
||||||
|
@ -33,8 +33,7 @@
|
|||||||
|
|
||||||
void DisplayVoteKickMenu(int client, int target)
|
void DisplayVoteKickMenu(int client, int target)
|
||||||
{
|
{
|
||||||
g_voteClient[VOTE_CLIENTID] = target;
|
g_voteTarget = GetClientUserId(target);
|
||||||
g_voteClient[VOTE_USERID] = GetClientUserId(target);
|
|
||||||
|
|
||||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||||
|
|
||||||
|
@ -76,9 +76,7 @@ voteType g_voteType = gravity;
|
|||||||
// Menu API does not provide us with a way to pass multiple peices of data with a single
|
// 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.
|
// choice, so some globals are used to hold stuff.
|
||||||
//
|
//
|
||||||
#define VOTE_CLIENTID 0
|
int g_voteTarget; /* Holds the target's user id */
|
||||||
#define VOTE_USERID 1
|
|
||||||
int g_voteClient[2]; /* Holds the target's client id and user id */
|
|
||||||
|
|
||||||
#define VOTE_NAME 0
|
#define VOTE_NAME 0
|
||||||
#define VOTE_AUTHID 1
|
#define VOTE_AUTHID 1
|
||||||
@ -221,13 +219,10 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
|
|
||||||
limit = g_Cvar_Limits[g_voteType].FloatValue;
|
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.
|
// 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))
|
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.");
|
LogAction(-1, -1, "Vote failed.");
|
||||||
PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
|
PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
|
||||||
@ -246,20 +241,36 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
case (burn):
|
case (burn):
|
||||||
|
{
|
||||||
|
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]);
|
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]);
|
LogAction(-1, voteTarget, "Vote burn successful, igniting \"%L\"", voteTarget);
|
||||||
|
|
||||||
IgniteEntity(g_voteClient[VOTE_CLIENTID], 19.8);
|
IgniteEntity(voteTarget, 19.8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case (slay):
|
case (slay):
|
||||||
|
{
|
||||||
|
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]);
|
PrintToChatAll("[SM] %t", "Slayed player", g_voteInfo[VOTE_NAME]);
|
||||||
LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote slay successful, slaying \"%L\"", g_voteClient[VOTE_CLIENTID]);
|
LogAction(-1, voteTarget, "Vote slay successful, slaying \"%L\"", voteTarget);
|
||||||
|
|
||||||
ExtinguishEntity(g_voteClient[VOTE_CLIENTID]);
|
ExtinguishEntity(voteTarget);
|
||||||
ForcePlayerSuicide(g_voteClient[VOTE_CLIENTID]);
|
ForcePlayerSuicide(voteTarget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case (alltalk):
|
case (alltalk):
|
||||||
|
@ -39,7 +39,8 @@ void DisplayVoteBurnMenu(int client, int target, char[] name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_voteClient[VOTE_CLIENTID] = target;
|
g_voteTarget = GetClientUserId(target);
|
||||||
|
|
||||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||||
|
|
||||||
LogAction(client, target, "\"%L\" initiated a burn vote against \"%L\"", client, target);
|
LogAction(client, target, "\"%L\" initiated a burn vote against \"%L\"", client, target);
|
||||||
|
@ -39,7 +39,8 @@ void DisplayVoteSlayMenu(int client, int target, char[] name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_voteClient[VOTE_CLIENTID] = target;
|
g_voteTarget = GetClientUserId(target);
|
||||||
|
|
||||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||||
|
|
||||||
LogAction(client, target, "\"%L\" initiated a slay vote against \"%L\"", client, target);
|
LogAction(client, target, "\"%L\" initiated a slay vote against \"%L\"", client, target);
|
||||||
|
Loading…
Reference in New Issue
Block a user