| 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], pnum, tempid; get_players(players, pnum); for( new i; i<pnum; i++ ) { tempid = players[i]; menu_display(tempid, gVoteMenu, 0); gVoting++; } set_task(10.0, "EndVote"); return PLUGIN_HANDLED; } public menu_handler(id, gVoteMenu, item) {
if( item == MENU_EXIT || !gVoting ) { return PLUGIN_HANDLED; } new data[6], iName[64]; new access, callback; menu_item_getinfo(gVoteMenu, item, access, data,5, iName, 63, callback); new voteid = str_to_num(data); gVotes[voteid]++; ColorChat( 0, GREEN, "%s^x01 has voted.", GetUserName( id ) ); return 1; } public EndVote() { if( gVotes[0] > gVotes[1] ) { client_print(0, print_chat, "First option recieved most votes (%d)", gVotes[0] ); } else if( gVotes[0] < gVotes[1] ) { client_print(0, print_chat, "Second option recieved most votes (%d)", gVotes[1] ); } else { client_print(0, print_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 szName[ 32 ]; get_user_name( index, szName, charsmax( szName ) ); return szName; }
|