[REP++ WHO HELPS] Run time error 4: "Array index out of bounds" - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [REP++ WHO HELPS] Run time error 4: "Array index out of bounds" (
/showthread.php?tid=585471)
[REP++ WHO HELPS] Run time error 4: "Array index out of bounds" -
buburuzu19 - 14.08.2015
Hello , i can't get this work , i have 25 turfs in my mysql database, i want to show an error when a player is not near them , i make this with IsPlayerInRange , don't ask why.
I get SERVER:Unknown command if i am not in a turf , and if i am it's goes SUCCESS!
Error:
pawn Код:
[11:27:42] [debug] Run time error 4: "Array index out of bounds"
[11:27:42] [debug] Accessing element at index 26 past array upper bound 25
I tried to put 25 instead of 26 but gamemode goes to Unknown.
pawn Код:
new TurfInfo[26][ttInfo];
new TurfInfo[26];
CMD:attack(playerid, params[])
{
new turfid;
for(new xf = 0; xf <= sizeof(TurfInfo); xf++)
{
if(IsPlayerInRangeOfPoint(playerid, 4.0, TurfInfo[xf][ttPosX], TurfInfo[xf][ttPosY], TurfInfo[xf][ttPosZ]))
{
turfid = xf;
break;
}
}
if(turfid == 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR!");
if(turfid > 0) return SendClientMessage(playerid, COLOR_WHITE, "SUCCES!");
return 1;
}
Re: [REP++ WHO HELPS] Run time error 4: "Array index out of bounds" -
jlalt - 14.08.2015
try this? o.o
PHP код:
new TurfInfo[26][ttInfo];
new TurfInfo[26];
CMD:attack(playerid, params[])
{
new turfid;
for(new xf = 0; xf <= sizeof(TurfInfo); xf++)
{
if(IsPlayerInRangeOfPoint(playerid, 4.0, TurfInfo[xf][ttPosX], TurfInfo[xf][ttPosY], TurfInfo[xf][ttPosZ]))
{
turfid = xf;
break;
}
}
if(turfid == 0) return SendClientMessage(playerid, -1, "ERROR!");
}
else if(turfid > 0) return SendClientMessage(playerid, -1, "SUCCES!");
}
else { SendClientMessage(playerid, -1, "YOUR MESSAGE IF NOT IN A TURF");
}
return 1;
}
Re: [REP++ WHO HELPS] Run time error 4: "Array index out of bounds" -
DTV - 14.08.2015
Instead of using "<=" try just "<".
Re: [REP++ WHO HELPS] Run time error 4: "Array index out of bounds" -
MarvinPWN - 14.08.2015
PHP код:
for(new xf = 0; xf <= sizeof(TurfInfo); xf++)
to
PHP код:
for(new xf = 0; xf < sizeof(TurfInfo); xf++)