Raised This Month: $ Target: $400
 0% 

Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-18-2014 , 13:48   Run time error 4: index out of bounds
Reply With Quote #1

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

Last edited by Fuck For Fun; 08-23-2014 at 16:13.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-18-2014 , 14:11   Re: Run time error 4: index out of bounds
Reply With Quote #2

1. Don't do a players loop like this. Use get_players.
2. Maybe you shoud check is player is connected/alive.
__________________
HamletEagle is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-18-2014 , 14:30   Re: Run time error 4: index out of bounds
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
1. Don't do a players loop like this. Use get_players.
2. Maybe you shoud check is player is connected/alive.
where check player connected/alive?

Give me another option to loop that I always use that.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-18-2014 , 14:40   Re: Run time error 4: index out of bounds
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
1. Don't do a players loop like this. Use get_players.
2. Maybe you shoud check is player is connected/alive.
In bold, what you asked.
__________________

Last edited by HamletEagle; 08-18-2014 at 14:40.
HamletEagle is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-18-2014 , 14:47   Re: Run time error 4: index out of bounds
Reply With Quote #5

Does not seem to me, to do check alive player's to votedays.

i set Connected and I will check it..

And as for CmdGgDay I have no idea ..
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-18-2014 , 14:51   Re: Run time error 4: index out of bounds
Reply With Quote #6

Code:
public CmdVoteMenu_Handler( client, iMenu, item ) {     if ( item != MENU_EXIT && is_user_connected( id ) )     {         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; }

For 1:
Code:
new iPlayers[ 32 ], iNum get_players( iPlayers, iNum ) for( new i = 0; i < iNum; i++ ) { }
__________________

Last edited by HamletEagle; 08-18-2014 at 14:52.
HamletEagle is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-18-2014 , 20:15   Re: Run time error 4: index out of bounds
Reply With Quote #7

post in thread

Last edited by Fuck For Fun; 08-19-2014 at 15:57.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-19-2014 , 01:23   Re: Run time error 4: index out of bounds
Reply With Quote #8

Did you check the values that are being used to index ALL of the arrays in your function which is causing the errors?
__________________
fysiks is offline
Deathknife
Senior Member
Join Date: Aug 2014
Old 08-19-2014 , 03:49   Re: Run time error 4: index out of bounds
Reply With Quote #9

This won't fix your problem, but shouldn't
Code:
g_iCurrentDay = g_iSelectedDays[ random( sizeof g_iSelectedDays ) ];
be:
Code:
g_iCurrentDay = g_iSelectedDays[ random( charsmax(g_iSelectedDays) ) ];
Deathknife is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-19-2014 , 11:02   Re: Run time error 4: index out of bounds
Reply With Quote #10

Quote:
Originally Posted by Deathknife View Post
This won't fix your problem, but shouldn't
Code:
g_iCurrentDay = g_iSelectedDays[ random( sizeof g_iSelectedDays ) ];
be:
Code:
g_iCurrentDay = g_iSelectedDays[ random( charsmax(g_iSelectedDays) ) ];
No.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Reply



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 13:17.


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