AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Trash (https://forums.alliedmods.net/forumdisplay.php?f=22)
-   -   [REQ] JailBreak VoteDayMenu (https://forums.alliedmods.net/showthread.php?t=154964)

ErrorStereotype 04-15-2011 19:42

[REQ] JailBreak VoteDayMenu
 
in any case is it able to finish this plz ?

Code:

/*
*
*        JailBreak VoteDayMenu by Drekes
*       
*
*        Description:
*                Day vote menu for ct's
*                teams see voted options + countdown.
*                Day is displayed in top right corner        (Day Number || "Day Name")
*                Cvar for countdown timer.
*
*                Examples here:
*                        - http://img690.**************/f/jailunforgiven0000.png/
*                        - http://img836.**************/i/jailunforgiven0004.png/
*
*        Cvars:
*       
*       
*        Commands:
*
*
*        Credits:
*
*
*        Changelog:
*                v1.0.0: Created plugin
*
*/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#pragma semicolon        1
#define VERSION                "1.0.0"

#define MAX_DAYS        9
#define TASK_TIMER        54512132



enum
{
        FreeDay,
        CageDay,
        NightCrawlerDay,
        ZombieDay,
        RiotDay,
        PresidentDay,
        UspNinjaDay,
        DodgeballDay,
        OtherDay
};
       
new const g_szDayNames[MAX_DAYS][] =
{
        "Free Day",
        "Cage Day",
        "NightCrawler Day",
        "Zombie Day",
        "Riot Day",
        "President Day",
        "USP Ninja Day",
        "Dodgeball Day",
        "Other Day"
};
/*
new const g_iDayDelays[MAX_DAYS][] =
{
        0,        // Free day
        0,        // Cage Day
        3,        // NightCrawler Day
        2,        // Zombie Day
        5,        // Riot Day
        0,        // President Day
        3,        // USP Ninja Day
        0,        // DodgeBall Day
        0,        // Other Day
};
*/

new g_iTimer,
        g_iCurrentRound,
        g_iVoteMenu,
        g_iCurrentVoters,
        // g_iDelays[MAX_DAYS] = g_iDayDelays[MAX_DAYS],
        g_iVotes[MAX_DAYS],
        g_iCurrentDay;
       
public plugin_init()
{
        register_plugin("Jailbreak Days Votemenu", VERSION, "Drekes");
       
        register_logevent("LogEventRoundStart", 2, "1=Round_Start");
}


public LogEventRoundStart()
{
        g_iCurrentRound++;
        CreateVoteMenu();
}

CreateVoteMenu()
{
        new szVoteMenu[128],
                szI[3];
               
        formatex(szVoteMenu, charsmax(szVoteMenu), "\y[CT MENU]\w What day do you prefer ? [15]");
        g_iVoteMenu = menu_create(szVoteMenu, "HandleVoteMenu");
       
        for(new i = 0; i < MAX_DAYS; i++)
        {
                formatex(szVoteMenu, charsmax(szVoteMenu), "%s [Votes: %i]", g_szDayNames[i], g_iVotes[i]);
                num_to_str(i + 1, szI, charsmax(szI));
                menu_additem(g_iVoteMenu, szVoteMenu, szI);
        }
       
        menu_setprop(g_iVoteMenu, MPROP_PERPAGE, 0);
        menu_setprop(g_iVoteMenu, MPROP_NUMBER_COLOR, "\w");
        menu_setprop(g_iVoteMenu, MPROP_EXIT, MEXIT_NEVER);
       
        new iPlayers[32],
                iNum,
                iPlayer;
               
        get_players(iPlayers, iNum);
        for(new j = 0; j < iNum; j++)
        {
                iPlayer = iPlayers[j];
               
                menu_display(iPlayer, g_iVoteMenu);
                g_iCurrentVoters++;
        }
       
        if(!task_exists(TASK_TIMER))
        {
                g_iTimer = 15;
                set_task(1.0, "TaskTimer");
        }
}


public HandleVoteMenu(id, iMenuId, iItem)
{
        if(is_user_connected(id) && cs_get_user_team(id) != CS_TEAM_CT)
        {       
                // menu_destroy(g_iVoteMenu);
                CreateVoteMenu();
               
                return PLUGIN_HANDLED;
        }
       
        new iVoteId = iItem + 1;
       
        g_iVotes[iVoteId]++;
       
        return PLUGIN_HANDLED;
}


public TaskEndVote()
{
        new iTopVotes[3],
                iVoteIds[3],
                iVotes,
                j;
       
        for(new i = 0; i < MAX_DAYS; i++)
        {       
                if(g_iVotes[i])
                {
                        if(iVotes < 3)
                        {
                                iTopVotes[iVotes] = g_iVotes[i];
                                iVoteIds[iVotes] = i;
                               
                                iVotes++;
                        }
                       
                        else
                        {
                                for(j = 0; j < 3; i++)
                                {
                                        if(g_iVotes[j] < g_iVotes[i])
                                        {
                                                iTopVotes[j] = g_iVotes[i];
                                                iVoteIds[j] = i;
                                       
                                                break;
                                        }
                                }
                        }
                }
        }

        switch(iVotes)
        {
                case 0:
                {       
                        g_iCurrentDay = random(MAX_DAYS);
                        client_print(0, print_chat, "Nobody voted. Today has been randomly selected to %s", g_szDayNames[g_iCurrentDay]);
                }
       
                case 1:
                {
                        g_iCurrentDay = iVoteIds[0];
                        client_print(0, print_chat, "Today is gonna be a %s", g_szDayNames[g_iCurrentDay]);
                }
               
                case 2:
                {
                        if(iTopVotes[0] == iTopVotes[1])
                        {
                                g_iCurrentDay = iTopVotes[random(1)];
                                client_print(0, print_chat, "Vote has tied. Today has been randomly selected to %s", g_szDayNames[g_iCurrentDay]);
                        }
                       
                        else if(iTopVotes[0] > iTopVotes[1])
                        {
                                g_iCurrentDay = iVoteIds[0];
                                client_print(0, print_chat, "Today is gonna be a %s", g_szDayNames[g_iCurrentDay]);
                        }
                       
                        else
                        {
                                g_iCurrentDay = iVoteIds[1];
                                client_print(0, print_chat, "Today is gonna be a %s", g_szDayNames[g_iCurrentDay]);
                        }
                }
               
                case 3:
                {
                        g_iCurrentDay = iTopVotes[random(2)];
                        client_print(0, print_chat, "Vote has tied. Today has randomly selected to %s", g_szDayNames[g_iCurrentDay]);
                }
        }
       
        // menu_destroy(g_iVoteMenu);
        remove_task(TASK_TIMER);

        return PLUGIN_HANDLED;
}

       
public TaskTimer()
{
        g_iTimer--;
       
        // menu_destroy(g_iVoteMenu);
        CreateVoteMenu();
}



All times are GMT -4. The time now is 15:35.

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