Monthly Target: $400 Donations: $9
 2% 

index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arenmake
Junior Member
Join Date: Apr 2012
Old 04-15-2012 , 14:15   index out of bounds
Reply With Quote #1

hi

I get this error in this code:

PHP Code:
extra_timer[id][EXTRA_CLIP] = 40 // secs
check_timer(idEXTRA_CLIP)

// ....

public check_timer(iditem)
{
    
extra_timer[id][item]--;

    if (
extra_timer[id][item] > 0)
    {
        new 
args[1]
        
args[0] = item
        
        set_task
(1.0"check_timer"idargssizeof args)
    }
    else
    {
        
extra_timer[id][item] = 0
    
}


Last edited by Arenmake; 04-15-2012 at 14:15.
Arenmake is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-15-2012 , 14:22   Re: index out of bounds
Reply With Quote #2

Show definition of extra_timer and what is the value of EXTRA_CLIP. You are also using set_task incorrectly.

Something like this (untested)
PHP Code:
new Data] = { EXTRA_CLIP };
extra_timer[id][EXTRA_CLIP] = 40 // secs
check_timerData id 

public 
check_timerData] , id )
{
    new 
item Data];
    
    if ( --
extra_timerid ][ item ] > )
    {
        
set_task1.0 "check_timer" id Data sizeofData ) )
    }
    else
    {
        
extra_timerid ][ item ] = 0
    
}

__________________

Last edited by Bugsy; 04-15-2012 at 14:28.
Bugsy is offline
Arenmake
Junior Member
Join Date: Apr 2012
Old 04-15-2012 , 14:32   Re: index out of bounds
Reply With Quote #3

sry

PHP Code:
// Hard coded extra items
enum
{
    
EXTRA_NVISION 0,
    
EXTRA_ANTIDOTE,
    
EXTRA_MADNESS,
    
EXTRA_INFBOMB,
    
EXTRA_CLIP,
    
EXTRA_WEAPONS_STARTID
}

new 
extra_timer[33][EXTRA_WEAPONS_STARTID]

// [ ... ]

// Buy item
        
case EXTRA_CLIP:
        {
            
// Increase clip purchase count for this round
            
g_clipcounter++
            
            
extra_timer[id][EXTRA_CLIP] = 40
            check_timer
(idEXTRA_CLIP)
        } 
I'll try your code now, thanks
Arenmake is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-15-2012 , 14:34   Re: index out of bounds
Reply With Quote #4

Do you use EXTRA_WEAPONS_STARTID or is it just there to declare the array? If not used, it should be:

PHP Code:
enum EXTRA_WEAPONS
{
    
EXTRA_NVISION 0,
    
EXTRA_ANTIDOTE,
    
EXTRA_MADNESS,
    
EXTRA_INFBOMB,
    
EXTRA_CLIP
}

new 
extra_timer[33][ EXTRA_WEAPONS 
__________________

Last edited by Bugsy; 04-15-2012 at 14:35.
Bugsy is offline
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 11:12.


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