Jump to content
  • 0

Accessing element at negative index -1


Question

Salut, am vazut in logurile serverului urmatoarele erori:

[16:41:50] [debug] Run time error 4: "Array index out of bounds"
[16:41:50] [debug]  Accessing element at negative index -1
[16:41:50] [debug] AMX backtrace:
[16:41:50] [debug] #0 0020bb6c in ?? (... <5 arguments>) at C:\Users\crist\Desktop\HPQ123 samp gamemode actual cu tot ce trebuie\gamemodes\B-HOOD.pwn:12113
[16:41:50] [debug] #1 0003321c in public OnDialogResponse (playerid=2, dialogid=86, response=1, listitem=-1, inputtext[][email protected] "#. Name") at C:\Users\crist\Desktop\HPQ123 samp gamemode actual cu tot ce trebuie\pawno\include\YSI\y_hooks/impl.inc:2273
Linia 12113 este aceasta: format(sName[playerid], 256, Selected[playerid][listitem]); si face parte din acest dialog de mai jos.

case DIALOG_MEMBERS: {
            if(!response) return true;
            if(PlayerInfo[playerid][pRank] < 6) return SCM(playerid, COLOR_LGREEN, "Eroare: Ai nevoie de rank 6+ pentru a putea merge mai departe!");
            new szQuery[256];
            format(sName[playerid], 256, Selected[playerid][listitem]);    
            format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `name`='%s'", sName[playerid]);
            new Cache: result = mysql_query(SQL, szQuery);
            cache_get_field_content(0, "Rank", string);
            new rank = strval(string);
            if(rank == 7)  return SCM(playerid, COLOR_LGREEN, "Eroare: Nu se poate modifica ceva unui lider!");
            cache_delete(result);                        
            format(string, sizeof(string), "Member: %s", sName[playerid]);
            ShowPlayerDialog(playerid, DIALOG_MEMBERS+1, DIALOG_STYLE_LIST, string, "Raport\nRank\nFaction warn\nUn faction warn\nUninvite", "Ok", "Back");
        }

Linia 9286 este aceasta: new Float:vehx, Float:vehy, Float:vehz, idd = PlayerInfo[playerid][pCarKey][listitem]; si face parte din dialogul de mai jos.

case DIALOG_FINDCAR: {
            if(!response)
                return true;

            new Float:vehx, Float:vehy, Float:vehz, idd = PlayerInfo[playerid][pCarKey][listitem];
            GetVehiclePos(CarInfo[idd][Spawned], vehx, vehy, vehz);
            SetPlayerCheckpointEx(playerid, vehx, vehy, vehz, 3.0);
            CP[playerid] = 53;
        }

[18:01:54] [debug] Run time error 4: "Array index out of bounds"
[18:01:54] [debug]  Accessing element at negative index -1
[18:01:54] [debug] AMX backtrace:
[18:01:54] [debug] #0 001d7830 in ?? (... <5 arguments>) at C:\Users\crist\Desktop\HPQ123 samp gamemode actual cu tot ce trebuie\gamemodes\B-HOOD.pwn:9286
[18:01:54] [debug] #1 0003321c in public OnDialogResponse (playerid=2, dialogid=748, response=1, listitem=-1, inputtext[][email protected] "(Occupied) Monster") at C:\Users\crist\Desktop\HPQ123 samp gamemode actual cu tot ce trebuie\pawno\include\YSI\y_hooks/impl.inc:2273

Linia 12360 este aceasta: new stringg[2000], idd = PlayerInfo[playerid][pCarKey][listitem]; si face parte din dialogul de mai jos.

case DIALOG_GARAGE: {
            if(!response) return true;
            new stringg[2000], idd = PlayerInfo[playerid][pCarKey][listitem];
            listitemm[playerid] = idd;
            strcat(stringg,"Option\tMore details.\n");
            strcat(stringg,"Vehicle Info\tSee vehicle details.\n");
            strcat(stringg,"Find Vehicle\tLocate your vehicle.\n"); 
            strcat(stringg,"Tow vehicle\tRespawn your vehicle.\n");
            if(CarInfo[idd][Spawned] != 0) strcat(stringg,"Despawn\tDestroy your vehicle.\n");
            else strcat(stringg,"Spawn\tSpawn your vehicle.\n");
            strcat(stringg,"Debug\tSpawn your vehicle in another locations.\n"); 
            strcat(stringg,"Sell vehicle\tSell vehicle to Dealership.\n");
            strcat(stringg,"Buy insurance\tBuy insurance points.\n");
            strcat(stringg, strlen(CarInfo[idd][cText]) < 3 ? "Upgrade To VIP Vehicle\t{51dd32}300 premium points.\n" : "Upgrade To VIP Vehicle\t{cf2424}300 premium points.\n");
            strcat(stringg, CarInfo[idd][cVip] != 1 ? "Upgrade To VIP PLUS\t{51dd32}500 premium points.\n" : "Teleport Vehicle\t{32e4ea}Get vehicle to you.\n");
            strcat(stringg, !CarInfo[idd][cRainBow] ? "Upgrade To rainbow vehicle\t{51dd32}300 premium points.\n" : "Upgrade to rainbow vehicle\t{cf2424}300 premium points.\n");
            strcat(stringg,"{FF0000}Remove tuning\t{FFFFFF}Remove tuning from your vehicle.");
            if(CarInfo[idd][Confiscated] == 1) strcat(stringg, "\n{FFFFFF}Pay fine to TTC.");
            ShowPlayerDialog(playerid, DIALOG_GARAGE1, DIALOG_STYLE_TABLIST_HEADERS, "Options", stringg, "Select", "Cancel");
        }

[19:14:12] [debug]  Accessing element at negative index -1
[19:14:12] [debug] AMX backtrace:
[19:14:12] [debug] #0 00210f00 in ?? (... <5 arguments>) at C:\Users\crist\Desktop\HPQ123 samp gamemode actual cu tot ce trebuie\gamemodes\B-HOOD.pwn:12360
[19:14:12] [debug] #1 0003321c in public OnDialogResponse (playerid=1, dialogid=82, response=1, listitem=-1, inputtext[][email protected] "Vehicul") at C:\Users\crist\Desktop\HPQ123 samp gamemode actual cu tot ce trebuie\pawno\include\YSI\y_hooks/impl.inc:2273
 

Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0
listitem	The ID of the list item selected by the player (starts at 0) (only if using a list style dialog, otherwise will be -1).

De pe wiki. Cel mai bine in aceste dialoguri poti face o verificare de genul dupa ce verifici response si inainte sa folosesti listeitem in array

if (listitem == -1)
	return 0; // Eventual un mesaj ca selectarea a esuat

 

Link to post
Share on other sites
  • 0
Acum 10 ore, iSkull a spus:

Comanda pentru DIALOG_MEMBERS?

YCMD:members(playerid, params[], help) return ShowFactionMembers(playerid);
stock ShowFactionMembers(playerid) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", aspam[playerid]);
    if(PlayerInfo[playerid][pMember] == 0) return true;
    new szQuery[256], string[180], MemberString[1024], szResult[180], days[180];
    new name[180], lastl[180], rank[180], fw[180], TitleString[180], tmembers, onmembers;
    format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `users`.`Member` = '%d' ORDER BY `users`.`Rank` DESC LIMIT 20", PlayerInfo[playerid][pMember]);
    new Cache: result = mysql_query(SQL, szQuery);
    strcat(MemberString, "#. Name\tRank - FW\tStatus\tDays\n");
    for(new i, j = cache_num_rows(); i != j; ++i)
    {
        cache_get_field_content(i, "name", szResult); format(name, 256, szResult);
        cache_get_field_content(i, "lastOn", szResult); format(lastl, 256, szResult);
        cache_get_field_content(i, "Rank", szResult); format(rank, 256, szResult);
        cache_get_field_content(i, "FWarn", szResult);  format(fw, 256, szResult);
        cache_get_field_content(i, "Days", szResult);  format(days, 256, szResult);
        
        format(Selected[playerid][tmembers], MAX_PLAYER_NAME, name);
        new userID = GetPlayerID(name);    
        
        if(userID != INVALID_PLAYER_ID) {
            onmembers++;
            format(string, sizeof(string), "%d. %s (%d)\t%d - %s/3\tOnline\t%s\n", tmembers+1, name, userID, PlayerInfo[userID][pRank], fw, days);
            strcat(MemberString, string, sizeof(MemberString));
        }
        else {
            format(string, sizeof(string), "%d. %s\t%s - %s/3\t%s\t%s\n", tmembers+1, name, rank, fw, lastl, days);
            strcat(MemberString, string, sizeof(MemberString));
        }
        tmembers++;
    }
    cache_delete(result);
    format(TitleString, sizeof(TitleString), "Members (%d/%d)", onmembers, tmembers);
    ShowPlayerDialog(playerid, DIALOG_MEMBERS, DIALOG_STYLE_TABLIST_HEADERS, TitleString, MemberString, "Ok", "Exit");
    return true;
}

Link to post
Share on other sites
  • 0
Acum 5 ore, Banditul a spus:
listitem	The ID of the list item selected by the player (starts at 0) (only if using a list style dialog, otherwise will be -1).

De pe wiki. Cel mai bine in aceste dialoguri poti face o verificare de genul dupa ce verifici response si inainte sa folosesti listeitem in array

if (listitem == -1)
	return 0; // Eventual un mesaj ca selectarea a esuat

 

Ok, multumesc. Voi incerca acum

Link to post
Share on other sites
  • 0
Acum 20 ore, Banditul a spus:
listitem	The ID of the list item selected by the player (starts at 0) (only if using a list style dialog, otherwise will be -1).

De pe wiki. Cel mai bine in aceste dialoguri poti face o verificare de genul dupa ce verifici response si inainte sa folosesti listeitem in array

if (listitem == -1)
	return 0; // Eventual un mesaj ca selectarea a esuat

 

Niciodata in OnDialogResponse nu o sa ai listitem pe -1, el pleaca mereu de la 0, problema e din variabila

 

Acum 15 ore, TheGodfather a spus:

Ok, multumesc. Voi incerca acum

Arata cum ai definit Selected

Link to post
Share on other sites
  • 0
Acum 15 minute, iSkull a spus:

Niciodata in OnDialogResponse nu o sa ai listitem pe -1, el pleaca mereu de la 0, problema e din variabila

 

Arata cum ai definit Selected

new Selected[MAX_PLAYERS][50][180];

La asta te referi? E sus de tot in gamemode.

Link to post
Share on other sites
  • 0

Fa enum

 

enum selected_info

{

sName[MAX_PLAYER_NAME], sID

}

new Selected[MAX_PLAYERS][99][selected_info];

 

in loc de  format(Selected[playerid][tmembers], MAX_PLAYER_NAME, name); pui format(Selected[playerid][tmembers][sName], MAX_PLAYER_NAME, name);

 

Link to post
Share on other sites
  • 0
Acum 6 minute, iSkull a spus:

Fa enum

 

enum selected_info

{

sName[MAX_PLAYER_NAME], sID

}

new Selected[MAX_PLAYERS][99][selected_info];

 

in loc de  format(Selected[playerid][tmembers], MAX_PLAYER_NAME, name); pui format(Selected[playerid][tmembers][sName], MAX_PLAYER_NAME, name);

 

Momentan am pus verificari cum mi-a spus Banditul, daca tot o sa apara eroarea voi incerca cum ai spus tu, iSkull.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.