28.06.2011, 00:22
I have a problem in a piece of code, where dont find the soluction:
In the lines marked, give a "array index out of bounds".
Where is the error?
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:Sleep, int:Type, const Param1[], const Param2[]);
public CreateTask(int:Sleep, int:Type, const Param1[], const Param2[])
{
//get a first non active pTasks to overwrite
new iEmptySlot = -1;
for (new i = 0; i < MAX_TASKS; i++)
{
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;
}
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.