AlliedModders

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

Arenmake 04-15-2012 14:15

index out of bounds
 
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
    
}



Bugsy 04-15-2012 14:22

Re: index out of bounds
 
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
    
}



Arenmake 04-15-2012 14:32

Re: index out of bounds
 
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

Bugsy 04-15-2012 14:34

Re: index out of bounds
 
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 



All times are GMT -4. The time now is 13:21.

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