Raised This Month: $ Target: $400
 0% 

bot vote


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
theangleofdoom
Junior Member
Join Date: Mar 2006
Old 04-18-2006 , 09:44   bot vote
Reply With Quote #1

im new to this but i am trying to make a vote but everytime i do there is always something wrong.
i can trying to make a vote, for the public, so that when someone says "/addbot" it starts a vote to add a bot and if the vote wins the server does the the command "wb add". i have gone through many version and now i cant even compile the plugin.

so in simple i want:
some one says "/addbot" a vote starts
if yes add a bot "server_cmd( "wb add" )"
if no nothing...

this is what i have done so far...

can anyone help?

Code:
  #include <amxmodx>

 // type of votes for vote_type
 #define VOTE_BOTADD    1

 // 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    30.0 // time allowed between votes

 new vote_type;
 new vote_data[33];
 new Float:last_vote;

 
 public plugin_init() {
    register_clcmd("say /addbot","start_vote",0,"- start voting session to add a bot") 
    register_menucmd(register_menuid("vote"),1023,"count_vote");
 }

 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 a bot?");
    show_menu(0,keys,menu,floatround(VOTE_TIME),"vote"); 
    set_task(15.0,"end_vote",89);
    return PLUGIN_HANDLED;
 }

 public count_vote(id,key) {

    // make sure vote is still going
    if(vote_type == 0)
        return;

    if(key == 0)
        vote_data[id] = VOTE_YES;
    else
        vote_data[id] = VOTE_NO;

    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() {

    if(vote_type == 0)
        return;

    vote_type = 0;
    last_vote = get_gametime();

    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++;
    }

    if(yes > no) {

        if(vote_type == VOTE_BOTADD) {
           server_cmd( "wb add" ) // add bots
        }
        
        client_print(0,print_chat,"* %s won with %i/%i votes",(vote_type == VOTE_BOTADD) ? "Add a bot",yes,no);
    }
    else {
        client_print(0,print_chat,"* %s won with %i/%i votes",(vote_type == VOTE_BOTADD) ? "Don't add a bot",no,yes);
    }

 }
theangleofdoom 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 05:07.


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