AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bot vote (https://forums.alliedmods.net/showthread.php?t=27250)

theangleofdoom 04-18-2006 09:44

bot vote
 
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);
    }

 }


Brad 04-18-2006 10:14

1) You posted in the wrong forum. You're looking for scripting help.
2) Look for "Custom Votes". It'd be simple enough to add your bot vote to it rather than creating a new plugin.

Moved from "Support/Help".

theangleofdoom 04-18-2006 11:42

sry for posting in the wrong fourm and i got no idea for what i am looking, "custom votes" means nothing. if you mean find a vote which has already been made and change it to "wb add" well i have tried that and failed.
if there is anyone who can help me or make one for me, plz and thanks for all help.

Brad 04-18-2006 15:04

What I meant was search for the custom votes plugin and use that for your bot vote.


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

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