Raised This Month: $ Target: $400
 0% 

VoteMenu - index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 01-09-2015 , 04:28   VoteMenu - index out of bounds
Reply With Quote #1

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 ] );

Last edited by Fuck For Fun; 04-24-2015 at 20:44. Reason: Trash IT
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
yan1255
Senior Member
Join Date: Jul 2011
Old 01-09-2015 , 12:03   Re: VoteMenu - index out of bounds
Reply With Quote #2

Either post the entire code or at least the entire VoteMenu part...
__________________
yan1255 is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 01-09-2015 , 12:36   Re: VoteMenu - index out of bounds
Reply With Quote #3

I added the end of the Public
votedays because I do not think it is related
I wrote the first response to the problem.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
yan1255
Senior Member
Join Date: Jul 2011
Old 01-09-2015 , 12:50   Re: VoteMenu - index out of bounds
Reply With Quote #4

Quote:
Originally Posted by Fuck For Fun View Post
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...
__________________
yan1255 is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 01-09-2015 , 12:59   Re: VoteMenu - index out of bounds
Reply With Quote #5

fixed

Last edited by Fuck For Fun; 04-24-2015 at 20:45.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Shlomi
Junior Member
Join Date: Oct 2013
Old 01-09-2015 , 14:58   Re: VoteMenu - index out of bounds
Reply With Quote #6

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
Shlomi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2015 , 18:30   Re: VoteMenu - index out of bounds
Reply With Quote #7

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).
__________________
fysiks is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 02-13-2015 , 18:39   Re: VoteMenu - index out of bounds
Reply With Quote #8

@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

Last edited by Fuck For Fun; 02-13-2015 at 20:52. Reason: EDIT
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 02-13-2015 , 19:09   Re: VoteMenu - index out of bounds
Reply With Quote #9

Quote:
Originally Posted by Fuck For Fun View Post
@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.
__________________
fysiks is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 02-13-2015 , 20:53   Re: VoteMenu - index out of bounds
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
What??? I have no idea what you just said.
sorry I edited my response
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Reply


Thread Tools
Display Modes

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 15:24.


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