Quote:
L 08/19/2014 - 03:07:02: [AMXX] Displaying debug trace (plugin "Days.amxx")
L 08/19/2014 - 03:07:02: [AMXX] Run time error 4: index out of bounds
L 08/19/2014 - 03:07:02: [AMXX] [0] Days.sma::CmdVoteMenu_Handler
|
Code:
public CmdShowVoteMenu()
{
static szMenu[ 100 ], iMenu, iTotalVotes;
iTotalVotes = GetTotalVotes();
formatex( szMenu, charsmax( szMenu ), "\r[%s] \yDays Vote \wMenu^n^n\r// \wTime Left: \y%i Seconds^n\w\r// \wTotal Votes: \y%i Votes", g_szMenuPrefix, g_iCounter, iTotalVotes );
iMenu = menu_create( szMenu, "CmdVoteMenu_Handler" );
for ( new i = 0; i < sizeof g_iSelectedDays; i++ )
{
formatex( szMenu, charsmax( szMenu ), "\w%s \r[\y%i Votes - %i%s\r]", g_szDaysData[ g_iSelectedDays[ i ] ][ m_DayName ], g_iVotes[ i ], (iTotalVotes > 0 ) ? ( floatround( ( float( g_iVotes[ i ] ) / float( iTotalVotes ) ) * 100 ) ) : 0, "%" );
menu_additem( iMenu, szMenu );
}
for ( new i = 0; i < g_iMaxPlayers; i++ )
{
if ( !is_user_connected( i ) )
continue;
menu_display( i, iMenu, 0 );
}
}
public CmdVoteMenu_Handler( client, iMenu, item )
{
if ( item != MENU_EXIT && is_user_connected( client ) )
{
if ( !g_iCounter )
return 1;
if ( g_iPlayersVotes[ client ] != DAY_NONE )
return 1;
g_iPlayersVotes[ client ] = g_iSelectedDays[ item ];
g_iVotes[ item ]++;
ColorChat( 0, RED, "%s^x03 %s^x01 has voted to^x04 %s^x01.", g_szPrefix, GetUserName( client ), g_szDaysData[ g_iSelectedDays[ item ] ][ m_DayName ] );
}
return 1;
}