error 032: array index out of bounds (variable "pInfo") :(
#1

Hello!
What's the problem?

Код:
enum e_pInfo {
	pSQLID,
	pName[MAX_PLAYER_NAME+1],
	pPass[65],
	pAdmin,
	pEmail[321],
	bool:pLogged = false,
	pPassFail
}
new pInfo[MAX_PLAYERS][e_pInfo];
Код:
function:loginHandle(playerid){
	new rows = cache_get_row_count();
	if(rows == 0) return ShowPlayerDialog(playerid, d_login, DIALOG_STYLE_PASSWORD, "SDtH - Bejelentkezйs", "Hibбs jelszуt adtбl meg!", "Elkьld", "Kilйpйs");
	pInfo[playerid][pPassFail]++;
	SendClientMessage(playerid, -1, "Sikeres bejelentkezйs!");
	pInfo[playerid][pPassFail] = EOS;
	pInfo[playerid][pSQLID] = cache_get_field_content_int(0, "id");
	pInfo[playerid][pAdmin] = cache_get_field_content_int(0, "pAdmin"); // 282
	cache_get_field_content(0, "pName", pInfo[playerid][pName]);
	cache_get_field_content(0, "pEmail", pInfo[playerid][pEmail]); // 284
	cache_get_field_content(0, "pPass",  pInfo[playerid][pPass]); // 285
	pInfo[playerid][pLogged] = true;
	return 1;
}
Код:
C:(282) : error 032: array index out of bounds (variable "pInfo")
C:(284) : error 032: array index out of bounds (variable "pInfo")
C:(285) : error 032: array index out of bounds (variable "pInfo")
Reply
#2

Solved!

boolLogged = false, -> sets the value ("counter") to 0.
Quote:

The enum variable always saves next unused constant number

Lets start in our enum
Код:
    enum CTask //normal mode (+= 1)
    {
        int:iSleep, // = 0
        int:iRemainingTime, // = 1
        int:iType, // = 2
        sParam1[256], // = 3 - 258
        sParam2[256], // = 259 - 514
        bool:bActive = false, //normally 515 but we set it to 0 again
    }; // => last constant number + 1 step => CTask = 1
     
    new pTasks[MAX_TASKS][CTask];

Now it should be clear why the out of bounds error appeared

Since all variables are by default 0 (false) you dont need to set bActive to false

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)