AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] auto votemenu with time (https://forums.alliedmods.net/showthread.php?t=230135)

Snitch 11-20-2013 13:05

[HELP] auto votemenu with time
 
i tried to make this votemenu with Time can someone help me
every 15min that will show that menu + show [%] at menu + player voted

and i will edit and put my Public events

PHP Code:

#include <amxmodx>

new gVoteMenu;
new 
gVotes[2];
new 
gVoting;

public 
plugin_init()
{
    
register_clcmd"start_vote","StartVote");
    
register_clcmd"say /test","StartVote");
}
public 
StartVote(id)
{
    if( 
gVoting )
    {
        
client_print(idprint_chat"There is already a vote going.");
        return 
PLUGIN_HANDLED;
    }

       
gVoteMenu menu_create("\r[AMXX] Auto Random Event's""menu_handler");
       
menu_additem(gVoteMenu"\yMath \wContest Event #1""0"0);
       
menu_additem(gVoteMenu"\yWrite \wContest Event #2""1"0);
       
gVotes[0] = 0;
       
gVotes[1] = 0;
       new 
players[32], pnumtempid;
       
get_players(playerspnum);
       for( new 
ii<pnumi++ )
       {
           
tempid players[i];
           
menu_display(tempidgVoteMenu0);
           
gVoting++;
       }
       
set_task(10.0"EndVote");
       return 
PLUGIN_HANDLED;
}
public 
menu_handler(idgVoteMenuitem)
{

    if( 
item == MENU_EXIT || !gVoting )
    {
            return 
PLUGIN_HANDLED;
    }
       new 
data[6], iName[64];
       new 
accesscallback;
       
menu_item_getinfo(gVoteMenuitemaccessdata,5iName63callback);
       new 
voteid str_to_num(data);
       
gVotes[voteid]++;
       return 
PLUGIN_HANDLED;
}
public 
EndVote()
{
    if( 
gVotes[0] > gVotes[1] )
    {
            
client_print(0print_chat"First option recieved most votes (%d)"gVotes[0] );
    }
      else if( 
gVotes[0] < gVotes[1] )
    {
            
client_print(0print_chat"Second option recieved most votes (%d)"gVotes[1] );
    }
       else
    {
            
client_print(0print_chat"The vote tied at %d votes each."gVotes[0] );
    }
       
menu_destroy(gVoteMenu);
       
gVoting 0;
       
gVotes[0] = 0;   //set to 0
       
gVotes[1] = 0;   //set to 0



Snitch 11-23-2013 10:43

Re: [HELP] auto votemenu with time
 
bump?

just make that menu start every 15min .

Gasa 11-23-2013 11:02

Re: [HELP] auto votemenu with time
 
public plugin_init()
{
register_clcmd( "start_vote","StartVote");
register_clcmd( "say /test","StartVote");
set_task(900.0, "StartVote")
}

Fuck For Fun 11-23-2013 11:23

Re: [HELP] auto votemenu with time
 
No Tested:
sorry i dont know how to set gVote with colorchat.

PHP Code:

#include <amxmodx>
#include <ColorChat>

new gVoteMenu;
new 
gVotes[2];
new 
gVoting;

public 
plugin_init()
{
    
register_clcmd"say /test","StartVote");
    
set_task(900.0"StartVote",_,_,_"b");
}
public 
StartVote(id)
{

       
gVoteMenu menu_create("\r[AMXX] Auto Random Event's""menu_handler");
       
menu_additem(gVoteMenu"\yMath \wContest Event #1""0"0);
       
menu_additem(gVoteMenu"\yWrite \wContest Event #2""1"0);
       
gVotes[0] = 0;
       
gVotes[1] = 0;
       new 
players[32], pnumtempid;
       
get_players(playerspnum);
       for( new 
ii<pnumi++ )
       {
           
tempid players[i];
           
menu_display(tempidgVoteMenu0);
           
gVoting++;
       }
       
set_task(10.0"EndVote");
       return 
PLUGIN_HANDLED;
}
public 
menu_handler(idgVoteMenuitem)
{

    if( 
item == MENU_EXIT || !gVoting )
    {
            return 
PLUGIN_HANDLED;
    }
       new 
data[6], iName[64];
       new 
accesscallback;
       
menu_item_getinfo(gVoteMenuitemaccessdata,5iName63callback);
       new 
voteid str_to_num(data);
       
gVotes[voteid]++;
       
       
ColorChat0GREEN"%s^x01 has voted."GetUserNameid ) );
       
       return 
1;
}
public 
EndVote()
{
    if( 
gVotes[0] > gVotes[1] )
    {
            
client_print(0print_chat"First option recieved most votes (%d)"gVotes[0] );
    }
      else if( 
gVotes[0] < gVotes[1] )
    {
            
client_print(0print_chat"Second option recieved most votes (%d)"gVotes[1] );
    }
       else
    {
            
client_print(0print_chat"The vote tied at %d votes each."gVotes[0] );
    }
       
menu_destroy(gVoteMenu);
       
gVoting 0;
       
gVotes[0] = 0;   //set to 0
       
gVotes[1] = 0;   //set to 0
}

stock GetUserName( const index )
{
    static 
szName32 ];
    
    
get_user_nameindexszNamecharsmaxszName ) );
    
    return 
szName;




All times are GMT -4. The time now is 23:19.

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