Loop issue - crashdetect
#1

So the problem is simple, crashdetect is outputing large ammount of messages (well they are all the same ones)
PHP код:
[15:12:23] [debugRun time error 4"Array index out of bounds"
[15:12:23] [debug]  Accessing element at index 20 past array upper bound 19
[15:12:23] [debugAMX backtrace:
[
15:12:23] [debug#0 00089b4c in ?? (0, 1995808, 0) from RPV2.amx
[15:12:23] [debug#1 00043718 in ?? (0, 1995760, 0) from RPV2.amx
[15:12:23] [debug#2 000455d4 in ?? (0, 1995760, 0, 0, 0, 8, 0, 1995760, 0, 0, ... <1073741813 arguments>) from RPV2.amx
[15:12:23] [debug#3 00008388 in public OnPlayerCommandText (0, 1995760) from RPV2.amx 
I believe the issue is inside the loop
PHP код:
CMD:viewdeposit(playerid,params[]) {
    new 
string[256];
    for(new 
0<= MAX_FACTIONSx++) {
        if(
IsPlayerInRangeOfPoint(playerid,50.0,FactionInfo[x][FactionExitX],FactionInfo[x][FactionExitY],FactionInfo[x][FactionExitZ])) {
            if(
FactionInfo[x][FactionID] == AccInfo[playerid][PlayerFaction]) {
                if(
AccInfo[playerid][PlayerLeader] == 0) return SendClientMessage(playerid,COLOR_RED,"You are not a faction leader!");
                
format(string,sizeof(string),"FactionDeposit -- Faction Name: %s ",FactionInfo[x][FactionName]);
                
SendClientMessage(playerid,COLOR_GREEN,string);
                print(string);
            }
        }
    }
    return 
true;

Because the simple fact the only thing thats supposted to be 20 is #define MAX_FACTIONS 20
Reply
#2

Change
pawn Код:
for(new x = 0; x <= MAX_FACTIONS; x++)
to
pawn Код:
for(new x = 0; x < MAX_FACTIONS; x++)
Reply
#3

Overlooked that.... thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)