cleaned up menu vote code a bit
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401600
This commit is contained in:
parent
f0dc4e996f
commit
54febbbc48
@ -53,7 +53,7 @@ public AdminMenu_VoteAllTalk(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public AdminMenu_VoteBurn(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public AdminMenu_VoteFF(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public AdminMenu_VoteGravity(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public AdminMenu_VoteSlay(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public AdminMenu_VoteBan(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public AdminMenu_VoteKick(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,11 @@ public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2)
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
g_VoteMapInUse = false;
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
g_VoteMapInUse = false;
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
@ -144,7 +146,7 @@ public AdminMenu_VoteMap(Handle:topmenu,
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running, theres no maps listed or someone else has already acessed this menu */
|
||||
buffer[0] = (IsVoteInProgress() || g_mapCount < 1 || g_VoteMapInUse) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT;
|
||||
buffer[0] = (!IsNewVoteAllowed() || g_mapCount < 1 || g_VoteMapInUse) ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -731,3 +731,21 @@ stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
|
||||
winningVotes = param2 & 0xFFFF;
|
||||
totalVotes = param2 >> 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick stock to determine whether voting is allowed. This doesn't let you
|
||||
* fine-tune a reason for not voting, so it's not recommended for lazily
|
||||
* telling clients that voting isn't allowed.
|
||||
*
|
||||
* @return True if voting is allowed, false if voting is in progress
|
||||
* or the cooldown is active.
|
||||
*/
|
||||
stock bool:IsNewVoteAllowed()
|
||||
{
|
||||
if (IsVoteInProgress() || CheckVoteDelay() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user