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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Array index out of bounds (
/showthread.php?tid=246611)
Array index out of bounds -
Snipa - 05.04.2011
pawn Код:
if(mysql_fetch_row(line))
{
new data[3][50];
new data2[5];
sscanf(line, "p|ssdddddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3],data2[4],data[5], data[2]);
PInfo[playerid][Kills] = data2[0];
PInfo[playerid][Deaths] = data2[1];
SetPVarInt(playerid, "Logged", 1);
SetPVarInt(playerid, "Deaths", data2[1]);
SetPlayerScore(playerid, data2[2]);
GivePlayerMoney(playerid,data2[3]);
PInfo[playerid][Level] = data2[4];
PInfo[playerid][VIP] = data2[5];
SendClientMessage(playerid, limegreen, "ACCOUNT: Login Successful!");
mysql_free_result();
if(PInfo[playerid][Level] == 0) SendClientMessage(playerid,limegreen,"You have logged in as a Normal Player");
if(PInfo[playerid][Level] == 1) SendClientMessage(playerid,limegreen,"You have logged in as a Level 1 Admin");
if(PInfo[playerid][Level] == 2) SendClientMessage(playerid,limegreen,"You have logged in as a Level 2 Admin");
if(PInfo[playerid][Level] == 3) SendClientMessage(playerid,limegreen,"You have logged in as a Level 3 Admin");
if(PInfo[playerid][Level] == 4) SendClientMessage(playerid,limegreen,"You have logged in as a Level 4 Admin");
if(PInfo[playerid][Level] == 5) SendClientMessage(playerid,limegreen,"You have logged in as a Level 5 Admin");
if(PInfo[playerid][Level] == 6) SendClientMessage(playerid,limegreen,"You have logged in as a Level 6 Admin (Scripter)");
if(PInfo[playerid][Level] == 7) SendClientMessage(playerid,limegreen,"You have logged in as a Level 7 Admin (Owner)");
format(string,sizeof(string),"[Donor Level %d]",PInfo[playerid][VIP]);
SendClientMessage(playerid,limegreen,string);
}
Код:
C:\Users\Chris\Documents\Serv\Server\gamemodes\MySQL CoS.pwn(3988) : error 032: array index out of bounds (variable "data")
C:\Users\Chris\Documents\Serv\Server\gamemodes\MySQL CoS.pwn(3996) : error 032: array index out of bounds (variable "data2")
Eh, thanks for the help.
Re: Array index out of bounds -
Calgon - 05.04.2011
Array cell numbers start from 0 to the max number -1.
So, the maximum number will be 4 if you define 5 cells, but you'll have 5 cells and the first cell will start at 0.
I assume this will work for your second error: (I don't know the order of the values you're directly wanting to get)
pawn Код:
PInfo[playerid][VIP] = data2[4];
As for the rest of your code, see what I said above and take that in to consideration when updating the rest of the values/variables.