AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Make A Vote Of This (https://forums.alliedmods.net/showthread.php?t=19951)

broertje 10-29-2005 10:07

Make A Vote Of This
 
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Cz Bot Voter" #define VERSION "1.0" #define AUTHOR "Broertje" new const g_BotsOn[45] = "bot_add" new const g_BotsOff[45] = "bot_kick" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)           register_clcmd("say /votebots", "sayBots", 0, "- Show Menu To Activate Bots ...")           register_menucmd(register_menuid("menu_ChooseType"),1023,"ChooseType"); } public sayBots(id) {     new menu[192]     new keys = (1<<0)|(1<<1)           format(menu, 191, "^n1. Vote: Kick All Bots^n2. Vote: Join Bots")     show_menu(id, keys, menu, -1, "giveStuff")       return PLUGIN_HANDLED } public giveStuff(id, key)     {           if (key==0)         {         server_cmd(g_BotsOff)     }     if (key==1) {         server_cmd(g_BotsOn)         server_cmd(g_BotsOn)         server_cmd(g_BotsOn)         server_cmd(g_BotsOn)         server_cmd(g_BotsOn)         server_cmd(g_BotsOn)     } }
I Want If You Press In The Menu On One Of The Options A Vote Will Start And If They Voted No Nothing Happens(Duh) And if They Vote Yes The Bots Will Be Added Or Kicked,I Cant Get This To Work,Someone Request This...

XxAvalanchexX 10-29-2005 13:32

Try this baby on for size:

Code:
 #include <amxmodx>  // type of votes for vote_type  #define VOTE_BOTADD    1  #define VOTE_BOTKICK   2  // value of votes for vote_data  #define VOTE_YES   1  #define VOTE_NO    0  #define VOTE_NONE  -1  // time variables  #define VOTE_TIME  15.0 // max time of vote  #define VOTE_FLOOD 120.0 // time allowed between votes  new vote_type;  new vote_data[33];  new Float:last_vote;  public plugin_init() {     register_menucmd(register_menuid("vote"),1023,"count_vote");  }  // call this from wherever  public start_vote(id,type) {     if(vote_type > 0) {         client_print(id,print_chat,"* Sorry, a vote is already in progress.");         return PLUGIN_HANDLED;     }     if(get_gametime() - VOTE_FLOOD <= last_vote) {         client_print(id,print_chat,"* Sorry, a vote has occurred recently.");         return PLUGIN_HANDLED;     }     new i;     vote_type = type;     // clear votes     for(i=0;i<33;i++)         vote_data[i] = VOTE_NONE;     new menu[192];     new keys = MENU_KEY_1|MENU_KEY_2;     format(menu,191,"%s^n^n1. Yes^n2. No",(vote_type == VOTE_BOTADD) ? "Add more bots?" : "Kick all bots?");     show_menu(0,keys,menu,floatround(VOTE_TIME),"vote"); // not sure if you can use 0 for this command     set_task(VOTE_TIME,"end_vote",89);     return PLUGIN_HANDLED;  }  public count_vote(id,key) {     // make sure vote is still going     if(vote_type == 0)         return;     // add votes     if(key == 0)         vote_data[id] = VOTE_YES;     else         vote_data[id] = VOTE_NO;     // see if all voting has finished     new i, bool:done = true;     for(i=0;i<33;i++) {         if(vote_data[i] == VOTE_NONE && is_user_connected(i)) {             done = false;             break;         }     }     if(done) {         remove_task(89);         end_vote();     }     client_print(id,print_chat,"* You voted %s",(key == 0) ? "Yes" : "No");  }  public end_vote() {     // make sure vote is still going     if(vote_type == 0)         return;     vote_type = 0;     last_vote = get_gametime();     // tally the results!!     new i, yes, no;     for(i=0;i<33;i++) {         if(vote_data[i] == VOTE_YES)             yes++;         else if(vote_data[i] == VOTE_NO)             no++;     }     // YES     if(yes > no) {         if(vote_type == VOTE_BOTADD) {             // add bots         }         else {             // remove bots         }         client_print(0,print_chat,"* %s won with %i/%i votes",(vote_type == VOTE_BOTADD) ? "Add more bots" : "Kick all bots",yes,no);     }     else {         client_print(0,print_chat,"* %s won with %i/%i votes",(vote_type == VOTE_BOTADD) ? "Don't add more bots" : "Don't kick all bots",no,yes);     }  }


All times are GMT -4. The time now is 00:05.

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