AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   VoteMenu - index out of bounds (https://forums.alliedmods.net/showthread.php?t=254989)

Fuck For Fun 01-09-2015 04:28

VoteMenu - index out of bounds
 
I'm have a vote days.

And I get in votemenu handler always full error of this:

Code:

L 01/09/2015 - 11:17:12: [AMXX] Displaying debug trace (plugin "test_votedays.amxx")
 L 09/01/2015 - 11:17:12: [AMXX] Run time error 4: index out of bounds
 L 01/09/2015 - 11:17:12: [AMXX] [0] test_votedays.sma :: CmdVoteMenu_Handler ()


code
:
Code:

new g_iSelectedDays[ 4 ], g_iVotes[ 4 ], g_iPlayersVotes[ 33 ];
PHP Code:

public CmdVoteMenu_HandlerclientiMenuitem )
{
    if ( 
item != MENU_EXIT )
    {
        if ( !
g_iCounter )
            return 
1;
    
        if ( 
g_iPlayersVotesclient ] != DAY_NONE )
            return 
1;
            
        
g_iPlayersVotesclient ] = g_iSelectedDaysitem ];
        
        
g_iVotesitem ]++;
        
        
ColorChatclientRED"%s You have Voted to^x04 %s^x01."g_szPrefixg_szDaysDatag_iSelectedDaysitem ] ][ m_DayName ] );
    }
    
    return 
1;
}

public 
CmdEndVote()
{
    
g_iCurrentDay GetHighestVoteg_iVotessizeof g_iVotes );
    
    if ( 
g_iCurrentDay == -)
    {
        
ColorChat0RED"%s The vote has^x03 failed^x01, choosing random day."g_szPrefix );
        
        
g_iCurrentDay g_iSelectedDaysrandomsizeof g_iSelectedDays ) ];
        
        
ColorChat0RED"%s The random day is:^x04 %s^x01."g_szPrefixg_szDaysDatag_iCurrentDay ][ m_DayName ] );
    }
    
    else
    {        
        
ColorChat0RED"%s The winning day is^x04 %s^x01, with^x03 %i votes^x01."g_szPrefixg_szDaysDatag_iSelectedDaysg_iCurrentDay ] ][ m_DayName ], g_iVotesg_iCurrentDay ] );
        
        
g_iCurrentDay g_iSelectedDaysg_iCurrentDay ];
    }    
    
    
StartDayg_iCurrentDay );


Line Error:
Code:

        ColorChat( client, RED, "%s You have Voted to^x04 %s^x01.", g_szPrefix, g_szDaysData[ g_iSelectedDays[ item ] ][ m_DayName ] );

yan1255 01-09-2015 12:03

Re: VoteMenu - index out of bounds
 
Either post the entire code or at least the entire VoteMenu part...

Fuck For Fun 01-09-2015 12:36

Re: VoteMenu - index out of bounds
 
I added the end of the Public
votedays because I do not think it is related
I wrote the first response to the problem.

yan1255 01-09-2015 12:50

Re: VoteMenu - index out of bounds
 
Quote:

Originally Posted by Fuck For Fun (Post 2246978)
I added the end of the Public
votedays because I do not think it is related
I wrote the first response to the problem.

Actually it is related, The problem may be coming of you having too many items on your menu it is most likely to be the problem either way I can't try and help you if I don't see those
1. The public that resets the vote
2. The public that creates the vote menu
3. The new round public that probably have some stuff about the vote

You have nothing to be afraid of I already have Vote Menu of my own and its very easy to script...

Fuck For Fun 01-09-2015 12:59

Re: VoteMenu - index out of bounds
 
fixed

Shlomi 01-09-2015 14:58

Re: VoteMenu - index out of bounds
 
You are trying to get data from an array in a place doesn't exist.
lets say i have an array with four spots ( Array[ 4 ], i have Array[ 0 ], Array[ 1 ], Array[ 2 ] and Array[ 3 ] )
this error would happen if i will try to get data from a place above 3 ( Array[ 6 ] for exmaple )
if you want us to help you, give us the specific line the debug sends you

fysiks 01-09-2015 18:30

Re: VoteMenu - index out of bounds
 
You should check if item is greater than -1 (not just if it equals MENU_EXIT).

You should debug the code to see if you are actually getting a negative number (I recently had this issue which is why my first suggestion is as stated above).

Fuck For Fun 02-13-2015 18:39

Re: VoteMenu - index out of bounds
 
@fysiks
Quote:

(I recently had this issue which is why my first suggestion is as stated above).
Who else had a problem like this?
I did a full test and checked

I have such a menu of this and only this votemenu (days) Gives me this error
I do not know if it's because of the other menus I have a different mode

fysiks 02-13-2015 19:09

Re: VoteMenu - index out of bounds
 
Quote:

Originally Posted by Fuck For Fun (Post 2262022)
@fysiks

Who else had a problem like this
I made full tests and checked with something worth EXIT MENU

And everything is normal menu but still get a lot LOGS
I do not know if it's because of the other menus I have a different mode

What??? I have no idea what you just said.

Fuck For Fun 02-13-2015 20:53

Re: VoteMenu - index out of bounds
 
Quote:

Originally Posted by fysiks (Post 2262035)
What??? I have no idea what you just said.

:lol: sorry I edited my response


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

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