Szerző Téma: error 032: array index out of bounds (variable "pInfo") osztmir?  (Megtekintve 975 alkalommal)

Nem elérhető AnthonyGates

  • 546
  • AnthonyGates
    • Profil megtekintése
error 032: array index out of bounds (variable "pInfo") osztmir?
« Dátum: 2015. Október 30. - 16:07:39 »
0
Sziasztok!
Kicsit kijöttem a gyakorlatból?
Ezt mi a zöld nádirépáért csinálja?
 
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\")
« Utoljára szerkesztve: 2015. Október 30. - 17:15:15 írta RusH. »

error 032: array index out of bounds (variable "pInfo") osztmir?
« Válasz #1 Dátum: 2015. Október 30. - 17:30:45 »
+1
Így már nem írt hibát.. ne kérdezd miért.
 
enum e_pInfo {
        bool:pLogged = false,
        pSQLID,
        pName[MAX_PLAYER_NAME+1],
        pPass[65],
        pAdmin,
        pEmail[321],
        pPassFail
}

Nem elérhető AnthonyGates

  • 546
  • AnthonyGates
    • Profil megtekintése
error 032: array index out of bounds (variable "pInfo") osztmir?
« Válasz #2 Dátum: 2015. Október 30. - 17:38:45 »
0

enum playerdata {
pSQLID, //  = 0
pName[MAX_PLAYER_NAME+1], // 1 - 25
pPass[66],  // 26+66 = 92 //
pAdmin, // 93
pEmail[321], // 413
bool:pLogged = false, // 414, de mivel false, 0.
pPassFail // 415, de mivel az előző 0, ez 1.
}

 
Mellesleg hülye voltam, ugye az alap értéke amúgyis false, szopatom itt magam. Megoldva
Szakirodalom: (angol)
 

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
 
[/quote]
« Utoljára szerkesztve: 2015. Október 30. - 17:40:38 írta Anthony Gates »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal