array index out of bounds
#1

I have a problem in a piece of code, where dont find the soluction:

PHP код:
#define MAX_TASKS         100
enum CTask
{
    
int:iSleep,             
    
int:iRemainingTime,
    
int:iType,             
    
sParam1[256],       
    
sParam2[256],       
    
bool:bActive false,
};
new 
pTasks[MAX_TASKS][CTask];
forward CreateTask(int:Sleepint:Type, const Param1[], const Param2[]);
public 
CreateTask(int:Sleepint:Type, const Param1[], const Param2[])
{
    
//get a first non active pTasks to overwrite
    
new iEmptySlot = -1;
    for (new 
0MAX_TASKSi++)
    {
        if ( 
pTasks[i][bActive] ) continue;
        
iEmptySlot i;
        break;
    }
    
    if ( 
iEmptySlot == -1) return false;
    
    
pTasks[iEmptySlot][iSleep]             = Sleep
    
pTasks[iEmptySlot][iRemainingTime]     = Sleep//LINE 93
    
pTasks[iEmptySlot][iType]           = Type//LINE 94
    
pTasks[iEmptySlot][bActive]         = 1;
    
format(pTasks[iEmptySlot][sParam1], 256"%s"Param1); //LINE 96
    
format(pTasks[iEmptySlot][sParam2], 256"%s"Param2); //LINE 97
    
    
return true;

In the lines marked, give a "array index out of bounds".
Where is the error?

Код:
C:\Program Files\Rockstar Games\samp03csvr_R2-2_win32\gamemodes\rick.pwn(93) : error 032: array index out of bounds (variable "pTasks")
C:\Program Files\Rockstar Games\samp03csvr_R2-2_win32\gamemodes\rick.pwn(94) : error 032: array index out of bounds (variable "pTasks")
C:\Program Files\Rockstar Games\samp03csvr_R2-2_win32\gamemodes\rick.pwn(96) : error 032: array index out of bounds (variable "pTasks")
C:\Program Files\Rockstar Games\samp03csvr_R2-2_win32\gamemodes\rick.pwn(97) : error 032: array index out of bounds (variable "pTasks")

Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply


Messages In This Thread
array index out of bounds - by Rickye - 28.06.2011, 00:22
AW: array index out of bounds - by Nero_3D - 28.06.2011, 01:46
Re: array index out of bounds - by Rickye - 28.06.2011, 05:11

Forum Jump:


Users browsing this thread: 2 Guest(s)