Raised This Month: $ Target: $400
 0% 

Solved Vote menu countdown


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
666
Senior Member
Join Date: Mar 2015
Old 07-02-2019 , 18:54   Vote menu countdown
Reply With Quote #1

good, I'm trying to make a menu with a countdown, until now I have achieved this, but has some problems which I will number:

1- the menu does not update the regressive time
2- players can vote again

until those two moments if you can optimize or improve please do it

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define TASK_VOTE     3032
new RD_iVotes[2],RD_iMenu,RD_iNumPlayer,RD_iCountDown;
new 
iPlayers[32],szName[32];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say .vote","Comand");
}

public 
Comand(id)
{
        if(!
task_exists(TASK_VOTE))
        {
            
RD_iCountDown 15;
            
set_task(1.0,"RD_FinishVote",TASK_VOTE,"",0,"b");
        }
        
        
get_players(iPlayers,RD_iNumPlayer);
        
get_user_name(id,szName,charsmax(szName));
            
        new 
iMenuTitle[512],iMenuSI[512],iMenuNO[512],iMenuTime[512];
        
formatex(iMenuTitle,charsmax(iMenuTitle),"VOTE: RESTART ROUND^nBy: %s",szName);
        
formatex(iMenuSI,charsmax(iMenuSI),"[%d] YES",RD_iVotes[0]);
        
formatex(iMenuNO,charsmax(iMenuNO),"[%d] NO",RD_iVotes[1]);
        
formatex(iMenuTime,charsmax(iMenuTime),"Vote Time %i",RD_iCountDown);
                            
        
RD_iMenu menu_create(iMenuTitle,"RD_VoteHandler");
        
menu_setprop(RD_iMenu,MPROP_NUMBER_COLOR,"\d");
        
menu_additem(RD_iMenu,iMenuSI,"0");
        
menu_additem(RD_iMenu,iMenuNO,"1");
        
menu_setprop(RD_iMenu,MPROP_EXITNAME,iMenuTime);
                       
        for( new 
i;RD_iNumPlayeri++ )
        
menu_display(iPlayers[i],RD_iMenu,0);
}

public 
RD_FinishVote()
{
        
RD_iCountDown--;
        
        for( new 
i;RD_iNumPlayeri++ )
        
menu_display(iPlayers[i],RD_iMenu,0);
        
        if(
RD_iCountDown <= 0)
        {
            
menu_destroy(RD_iMenu);
            
show_menu00"^n");
            
            if(
RD_iVotes[0] > RD_iVotes[1])
            {
                
client_print_color(0,print_team_default,"VOTE RESTART ROUND: accepted");
            }
            else
            {
                
client_print_color(0,print_team_default,"VOTE RESTART ROUND: rejected");
            }
            
            
RD_iCountDown 0;
            
remove_task(TASK_VOTE);
            
RD_iVotes[0] = RD_iVotes[1] = 0;
        }
}

public 
RD_VoteHandlerCallBack(id,iMenu,iKey)
{
    return 
ITEM_DISABLED;
}

public 
RD_VoteHandler(id,iMenu,iItem)
{
    if(
iItem == MENU_EXIT)
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(iMenuiItemaccessdata5iName63callback);
    
    new 
votekey str_to_num(data);
    
RD_iVotes[votekey]++;
    
    switch(
votekey)
    {
        case 
0Comand(id);
        case 
1Comand(id);
    }
    return 
PLUGIN_HANDLED;

__________________

Last edited by 666; 07-05-2019 at 22:33.
666 is offline
 



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 17:22.


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