For Loop
#1

Код:
#undef MAX_PLAYERS
#def MAX_PLAYERS 100

new Job1[MAX_PLAYERS][19];

public OnPlayerConnect(playerid)
{
for(new i = 0; i < sizeof(Job1); i++)
{
Job1[playerid][i] = 0; // Line 5094
}
return 1;
}
Now if i do this I get
Код:
[22:40:08] [debug] Run time error 4: "Array index out of bounds"
[22:40:08] [debug]  Accessing element at index 12 past array upper bound 11
[22:40:08] [debug] AMX backtrace:
[22:40:08] [debug] #0 000776f0 in ?? (... <1 argument>) at G:\ZS\gamemodes\gamemodes\gamemodes\bttdmzmapocalypse.pwn:5094
[22:40:08] [debug] #1 0000f11c in public Itter_OnPlayerConnect (playerid=1) at G:\ZS\pawno\include\YSI\y_hooks/impl.inc:618
[22:40:08] [debug] #2 0000888c in public SSCANF_OnPlayerConnect (playerid=1) at G:\ZS\pawno\include\YSI\y_iterate.inc:646
[22:40:08] [debug] #3 00001118 in public OnPlayerConnect (playerid=1) at G:\ZS\pawno\include\sscanf2.inc:236
Reply
#2

You want to loop through the indexes of the second dimension so the correct way is:
Код:
for(new i = 0; i < sizeof Job1[]; i++)
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You want to loop through the indexes of the second dimension so the correct way is:
Код:
for(new i = 0; i < sizeof Job1[]; i++)
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)