Raised This Month: $12 Target: $400
 3% 

Solved Exception reported: A vote is already in progress


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-12-2017 , 00:05   Exception reported: A vote is already in progress
Reply With Quote #1

Hey guys, I'm getting the following errors whenever I use a command to open a vote menu while another vote menu is already open.

Error:

Code:
L 12/11/2017 - 20:50:36: [SM] Exception reported: A vote is already in progress
L 12/11/2017 - 20:50:36: [SM] Blaming: l4d_anti-speedrunner.smx
L 12/11/2017 - 20:50:36: [SM] Call stack trace:
L 12/11/2017 - 20:50:36: [SM]   [0] VoteMenu
L 12/11/2017 - 20:50:36: [SM]   [1] Line 584, C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d_anti-speedrunner.sp::Command_Chase
L 12/11/2017 - 20:51:20: [SM] Exception reported: A vote is already in progress
L 12/11/2017 - 20:51:20: [SM] Blaming: l4d_anti-speedrunner.smx
L 12/11/2017 - 20:51:20: [SM] Call stack trace:
L 12/11/2017 - 20:51:20: [SM]   [0] VoteMenu
L 12/11/2017 - 20:51:20: [SM]   [1] Line 639, C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d_anti-speedrunner.sp::Command_Warp
My menu code:

PHP Code:
char GlobalBuffer[512];

public 
Action Command_Chase(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_punish_enable.BoolValue || !l4d_ass_punish_vote.BoolValue || l4d_ass_punish_auto.BoolValue || NumTanks2)
        return 
Plugin_Handled;
    if(!
l4d_ass_punish_tank.BoolValue)
        
CountTanks();
    
tmenuStarted false;
    if(
l4d_ass_punish_vote.BoolValue)
    {
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsValidClient(i))
                continue;
            
humanPlayers[totalHumans++] = i;
        }

        for(
int i 1<= MaxClientsi++)
        {
            if(!
pmenuStarted && IsValidClient(i))
            {
                
pmenuStarted true;
                
Menu chooseMenu CreateMenu(chooseMenuHandler);
                
SetVoteResultCallback(chooseMenuchooseMenuResults);
                
Format(GlobalBuffersizeof(GlobalBuffer), "%T""PunishSpeedrunners"i);
                
chooseMenu.SetTitle(GlobalBuffer); 
                
Format(GlobalBuffersizeof(GlobalBuffer), "%T""YesOption"i);
                
chooseMenu.AddItem("Yes"GlobalBuffer);
                
Format(GlobalBuffersizeof(GlobalBuffer), "%T""NoOption"i);
                
chooseMenu.AddItem("No"GlobalBuffer); 
                
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
                
VoteMenu(chooseMenuhumanPlayerstotalHumans30);
            }

            else
            {
                if(
tmenuStarted)
                {
                    if(
IsValidClient(i))
                        
ReplyToCommand(i"\x04[ASS]\x01 %T""TeleportMenuOn"i);
                    return 
Plugin_Handled;
                }

                else if(
pmenuStarted)
                {
                    if(
IsValidClient(i))
                        
ReplyToCommand(i"\x04[ASS]\x01 %T""PunishMenuOn"i);
                    return 
Plugin_Handled;
                }
            }
        }
    }

    return 
Plugin_Continue;
}

public 
Action Command_Warp(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return 
Plugin_Handled;
    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    
pmenuStarted false;
    if(
l4d_ass_teleport_vote.BoolValue)
    {
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsValidClient(i))
                continue;
            
humanPlayers[totalHumans++] = i;
        }

        for(
int i 1<= MaxClientsi++)
        {
            if(!
tmenuStarted && IsValidClient(i))
            {
                
tmenuStarted true;
                
Menu chooseMenu2 CreateMenu(chooseMenuHandler2);
                
SetVoteResultCallback(chooseMenu2chooseMenuResults2);
                
Format(GlobalBuffersizeof(GlobalBuffer), "%T""TeleportSpeedrunners"i);
                
chooseMenu2.SetTitle(GlobalBuffer); 
                
Format(GlobalBuffersizeof(GlobalBuffer), "%T""YesOption"i);
                
chooseMenu2.AddItem("Yes"GlobalBuffer);
                
Format(GlobalBuffersizeof(GlobalBuffer), "%T""NoOption"i);
                
chooseMenu2.AddItem("No"GlobalBuffer); 
                
SetMenuPagination(chooseMenu2MENU_NO_PAGINATION);
                
VoteMenu(chooseMenu2humanPlayerstotalHumans30);
            }

            else
            {
                if(
pmenuStarted)
                {
                    if(
IsValidClient(i))
                        
ReplyToCommand(i"\x04[ASS]\x01 %T""PunishMenuOn"i);
                    return 
Plugin_Handled;
                }

                else if(
tmenuStarted)
                {
                    if(
IsValidClient(i))
                        
ReplyToCommand(i"\x04[ASS]\x01 %T""TeleportMenuOn"i);
                    return 
Plugin_Handled;
                }
            }
        }
    }

    return 
Plugin_Handled;
}

public 
int chooseMenuHandler(Menu menuMenuAction actionint param1int param2)
{
    if(
l4d_ass_punish_vote.BoolValue && !l4d_ass_punish_auto.BoolValue)
    {
        switch(
action)
        {
            case 
MenuAction_Select:
            {
                
GetMenuItem(menuparam2GlobalBuffersizeof(GlobalBuffer));
                switch(
StringToInt(GlobalBuffer))
                {
                    case 
0pvotedYes += 1;
                    case 
1pvotedNo += 1;
                }
            }

            case 
MenuAction_End:
                
delete menu;
        }
    }
}

public 
int chooseMenuHandler2(Menu menuMenuAction actionint param1int param2)
{
    if(
l4d_ass_teleport_vote.BoolValue && !l4d_ass_teleport_auto.BoolValue)
    {
        switch(
action)
        {
            case 
MenuAction_Select:
            {
                
GetMenuItem(menuparam2GlobalBuffersizeof(GlobalBuffer));
                switch(
StringToInt(GlobalBuffer))
                {
                    case 
0tvotedYes += 1;
                    case 
1tvotedNo += 1;
                }
            }

            case 
MenuAction_End:
                
delete menu;
        }
    }
}

public 
void chooseMenuResults(Handle menuint pnum_votesint num_clients, const int[][] client_infoint num_items, const int[][] item_info)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_punish_enable.BoolValue || !l4d_ass_punish_vote.BoolValue || l4d_ass_punish_auto.BoolValue || NumTanks2)
        return;
    if(!
l4d_ass_punish_tank.BoolValue)
        
CountTanks();
    
pnum_votes pvotedYes pvotedNo;
    if(
pnum_votes GetHumanCount())
        
pvotedUnknown GetHumanCount() - pnum_votes;
    if(
pvotedUnknown pnum_votes)
    {
        for(
int i 1<= MaxClientsi++)
            if(
IsValidClient(i))
                
PrintToChatAll("\x04[ASS]\x01 %T""NoVotes"i);
    }

    else
    {
        if(
pvotedYes pvotedNo)
        {
            
int add GetConVarInt(l4d_ass_punish_timer);
            
CreateTimer(0.1TimerUpdatePlayerGetEngineTime() + addTIMER_REPEAT);
            for(
int i 1<= MaxClientsi++)
                if(
IsValidClient(i))
                    
PrintToChatAll("\x04[ASS]\x01 %T""VotedYes"i);
        }

        else if(
pvotedNo pvotedYes)
            for(
int i 1<= MaxClientsi++)
                if(
IsValidClient(i))
                    
PrintToChatAll("\x04[ASS]\x01 %T""VotedNo"i);
    }

    
pmenuStarted false;
    
pvotedYes 0;
    
pvotedNo 0;
    return;
}

public 
void chooseMenuResults2(Handle menuint tnum_votesint num_clients, const int[][] client_infoint num_items, const int[][] item_info)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return;
    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    
tnum_votes tvotedYes tvotedNo;
    if(
tnum_votes GetHumanCount())
        
tvotedUnknown GetHumanCount() - tnum_votes;
    if(
tvotedUnknown tnum_votes)
    {
        for(
int i 1<= MaxClientsi++)
            if(
IsValidClient(i))
                
PrintToChatAll("\x04[ASS]\x01 %T""NoVotes"i);
    }

    else
    {
        if(
tvotedYes tvotedNo)
        {
            
int add GetConVarInt(l4d_ass_teleport_timer);
            
CreateTimer(0.1TimerCheckForSpeedrunnersGetEngineTime() + addTIMER_REPEAT);
            for(
int i 1<= MaxClientsi++)
                if(
IsValidClient(i))
                    
PrintToChatAll("\x04[ASS]\x01 %T""VotedYes"i);
        }

        else if(
tvotedNo tvotedYes)
            for(
int i 1<= MaxClientsi++)
                if(
IsValidClient(i))
                    
PrintToChatAll("\x04[ASS]\x01 %T""VotedNo"i);
    }

    
tmenuStarted false;
    
tvotedYes 0;
    
tvotedNo 0;
    return;

__________________

Last edited by Psyk0tik; 12-12-2017 at 06:47. Reason: Marked as [Solved]
Psyk0tik is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-12-2017 , 00:41   Re: Exception reported: A vote is already in progress
Reply With Quote #2

Well... yeah, you can't have two votes running at the same time.

You can use IsVoteInProgress() or IsNewVoteAllowed() to check if you can start a new vote.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-12-2017 , 01:06   Re: Exception reported: A vote is already in progress
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
Well... yeah, you can't have two votes running at the same time.

You can use IsVoteInProgress() or IsNewVoteAllowed() to check if you can start a new vote.
How would I implement IsVoteInProgress()? I don't know exactly what to put in it since this page doesn't give any examples.

EDIT: Figured it out. Thanks!

EDIT2: Will post the code here when I get the chance.
__________________

Last edited by Psyk0tik; 12-12-2017 at 08:40.
Psyk0tik is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-12-2017 , 21:07   Re: Exception reported: A vote is already in progress
Reply With Quote #4

Solution

PHP Code:
public Action Command_Votechase(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_punish_vote.BoolValue || l4d_ass_punish_auto.BoolValue || NumTanks2)
        return 
Plugin_Handled;
    if(!
l4d_ass_punish_enable.BoolValue)
    {
        if(
IsValidClient(client))
            
ReplyToCommand(client"\x04[ASS]\x01 %T""WelcomeOff3"client);
        return 
Plugin_Handled;
    }

    if(!
l4d_ass_punish_tank.BoolValue)
        
CountTanks();
    if(
IsVoteInProgress())
    {
        
ReplyToCommand(client"\x04[ASS]\x01 %t""Vote in Progress");
        return 
Plugin_Handled;
    }

    
humanPlayers[totalHumans++] = client;
    if(
IsValidClient(client))
    {
        
Menu chooseMenu CreateMenu(chooseMenuHandler);
        
SetVoteResultCallback(chooseMenuchooseMenuResults);
        
Format(GlobalBuffersizeof(GlobalBuffer), "%T""PunishSpeedrunners"client);
        
chooseMenu.SetTitle(GlobalBuffer); 
        
Format(GlobalBuffersizeof(GlobalBuffer), "%T""Yes"client);
        
chooseMenu.AddItem("Yes"GlobalBuffer);
        
Format(GlobalBuffersizeof(GlobalBuffer), "%T""No"client);
        
chooseMenu.AddItem("No"GlobalBuffer); 
        
SetMenuPagination(chooseMenuMENU_NO_PAGINATION);
        
chooseMenu.ExitButton false;
        
VoteMenu(chooseMenuhumanPlayerstotalHumans30);
    }

    return 
Plugin_Handled;
}

public 
Action Command_Votewarp(int clientint args)
{
    if(!
l4d_ass_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3)
        return 
Plugin_Handled;
    if(!
l4d_ass_teleport_enable.BoolValue)
    {
        if(
IsValidClient(client))
            
ReplyToCommand(client"\x04[ASS]\x01 %T""WelcomeOff2"client);
        return 
Plugin_Handled;
    }

    if(!
l4d_ass_teleport_tank.BoolValue)
        
CountTanks();
    if(
IsVoteInProgress())
    {
        
ReplyToCommand(client"\x04[ASS]\x01 %t""Vote in Progress");
        return 
Plugin_Handled;
    }

    
humanPlayers[totalHumans++] = client;
    if(
IsValidClient(client))
    {
        
Menu chooseMenu2 CreateMenu(chooseMenuHandler2);
        
SetVoteResultCallback(chooseMenu2chooseMenuResults2);
        
Format(GlobalBuffersizeof(GlobalBuffer), "%T""TeleportSpeedrunners"client);
        
chooseMenu2.SetTitle(GlobalBuffer); 
        
Format(GlobalBuffersizeof(GlobalBuffer), "%T""Yes"client);
        
chooseMenu2.AddItem("Yes"GlobalBuffer);
        
Format(GlobalBuffersizeof(GlobalBuffer), "%T""No"client);
        
chooseMenu2.AddItem("No"GlobalBuffer); 
        
SetMenuPagination(chooseMenu2MENU_NO_PAGINATION);
        
chooseMenu2.ExitButton false;
        
VoteMenu(chooseMenu2humanPlayerstotalHumans30);
    }

    return 
Plugin_Handled;

__________________

Last edited by Psyk0tik; 12-13-2017 at 03:36.
Psyk0tik is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode