AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   JailBreak VoteDayMenu (https://forums.alliedmods.net/showthread.php?t=154457)

karolek0901 04-08-2011 20:51

JailBreak VoteDayMenu
 
Hello
I need someone to chack this plugin code and fix

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_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 iVoteMenu,
        szVoteMenu[128],
        szI[3];
   
    if(!task_exists(TASK_TIMER))
    {
        g_iTimer = 15;
        set_task(1.0, "TaskTimer", TASK_TIMER, .flags = "b");
    }
   
    formatex(szVoteMenu, charsmax(szVoteMenu), "\y[CT MENU]\w What day do you prefer ? [%i]", g_iTimer);
    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(iVoteMenu, szVoteMenu, szI);
    }
   
    // menu_setprop(iVoteMenu, MPROP_PERPAGE, 0);
    menu_setprop(iVoteMenu, MPROP_NUMBER_COLOR, "\w");
    menu_setprop(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, iVoteMenu);
        g_iCurrentVoters++;
    }
}


public HandleVoteMenu(id, iMenuId, iItem)
{
    if(!is_user_connected(id) || cs_get_user_team(id) != CS_TEAM_CT)
    {   
        // menu_destroy(iMenuId);
        CreateVoteMenu();
       
        return PLUGIN_HANDLED;
    }

    new iAccess, iCallback, szData[3];
    menu_item_getinfo(iMenuId, iItem, iAccess, szData, 2, _, _, iCallback);
    g_iVotes[str_to_num(szData)]++;
   
    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--;
   
    CreateVoteMenu();
}

Thanx for fixing this code because when i complicate and turn on in the serwer is no working and i don't know what is wrong with this cod

Exolent[jNr] 04-08-2011 21:15

Re: JailBreak VoteDayMenu
 
Where did you get this plugin?

karolek0901 04-08-2011 21:19

Re: JailBreak VoteDayMenu
 
i find in google i don't know where Can you help me repair this plugin

tis is logs for the serwer when i turn on this plugin
Code:

L 04/09/2011 - 01:04:59: [AMXX] Run time error 10 (plugin "daysmenu.amxx") (native "menu_display") - debug not enabled!
L 04/09/2011 - 01:04:59: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
L 04/09/2011 - 01:05:00: Plugin called menu_display when item=MENU_EXIT


drekes 04-08-2011 22:18

Re: JailBreak VoteDayMenu
 
It is not a complete plugin, I was having trouble understanding the vote menu handler, and sent it to wrecked. After i understood it, i rewrote the handler.

This doesn't make sense.

karolek0901 04-08-2011 22:48

Re: JailBreak VoteDayMenu
 
can you fix this for me

drekes 04-09-2011 00:50

Re: JailBreak VoteDayMenu
 
No, this is the one i'm selling

karolek0901 04-09-2011 09:28

Re: JailBreak VoteDayMenu
 
so i must ask in different forum to help me

drekes 04-09-2011 14:08

Re: JailBreak VoteDayMenu
 
That piece of code isn't gonna help you, this is about 1/3 of the plugin + it's bugged.

ErrorStereotype 04-15-2011 19:24

Re: JailBreak VoteDayMenu
 
heheh drekes dont be sure its on the sm clan jailbreak :)

drekes 04-15-2011 23:07

Re: JailBreak VoteDayMenu
 
That's not mine, maybe it looks alike.


All times are GMT -4. The time now is 20:02.

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