05.08.2016, 13:28
Quote:
How are you setting the player's faction to -1?
If it's like this: Код:
enum ENUM_NAME { pFaction = -1 }; If not: Check if it's == to -1 before using fData[pData[playerid][pFaction][fManageRank], or else it'll be fData[-1][fManageRank], and that's invalid. |
Код:
CMD:settest(playerid, params[]) { new type, count; if(sscanf(params, "ii", type, count)) return SendUsageMessage(playerid, "/settest [type] [number] (1:faction,2:factionrank,3:facmanagerank)"); if(type > 3 || type < 1) return SendErrorMessage(playerid, "type cant be more than 3 or less than 1"); switch(type) { case 1: pData[playerid][pFaction] = count; case 2: pData[playerid][pFactionRank] = count; case 3: fData[pData[playerid][pFaction]][fManageRank] = count; } return 1; }
Код:
CMD:factions(playerid, params[]) { new str[200]; format(str, sizeof(str), "List Factions\n"); if(pData[playerid][pFaction] >= 0) { format(str, sizeof(str), "%sList %s's Members\n", str, fData[pData[playerid][pFaction]][fName]); if(pData[playerid][pFactionRank] >= fData[pData[playerid][pFaction]][fManageRank]) { format(str, sizeof(str), "%sManage %s's Members\n", str, fData[pData[playerid][pFaction]][fName]); } } if(pData[playerid][pAdmin] > 1) { format(str, sizeof(str), "%sCreate Faction\nEdit Faction", str, fData[pData[playerid][pFaction]][fName]); } ShowPlayerDialog(playerid, DIALOG_FACTION_MAIN, DIALOG_STYLE_LIST, "Faction Control Panel", str, "Select", "Cancel"); return 1; }
Код:
[08:24:32] [debug] Run time error 4: "Array index out of bounds" [08:24:32] [debug] Accessing element at negative index -1 [08:24:32] [debug] AMX backtrace: [08:24:32] [debug] #0 0006b310 in public cmd_factions (playerid=0, params[]=@02133ff0 "") at <myscript>.pwn:2682 [08:24:32] [debug] #1 native CallLocalFunction () from samp-server.exe [08:24:32] [debug] #2 0000b9dc in public f3_KBROnPlayerCommandText (playerid=0, cmdtext[]=@02133fc8 "/factions") at C:\Users\Administrator\Desktop\Script from scratch new\pawno\include\izcmd.inc:94