SA-MP Forums Archive
Array 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: Array out of bounds? (/showthread.php?tid=334489)



Array out of bounds? - Nuke547 - 15.04.2012

Alright, so basically, in my enum, I have this:

pawn Код:
CarModel[3],
    CarID[3],
    Float: CarPos1[3],
    Float: CarPos2[3],
    Float: CarPos3[3],
    Float: CarAngle[3],
Here is my variable:

pawn Код:
new pStats[MAX_PLAYERS][PlayerEnum];
I then tried to do something like this:

pawn Код:
pStats[playerid][CarAngle][1]
It then gave me the error: array index out of bounds (variable "pStats").

Is it possible to do this? Or am I doing something wrong?


Re: Array out of bounds? - Kitten - 15.04.2012

pawn Код:
CarID[5];
Float: CarPos1[1],
Float: CarPos2[2],
Float: CarPos3[3],
Float: CarAngle[4] // try now.



Re: Array out of bounds? - Nuke547 - 15.04.2012

Quote:
Originally Posted by Kitten
Посмотреть сообщение
pawn Код:
CarID[5];
Float: CarPos1[1],
Float: CarPos2[2],
Float: CarPos3[3],
Float: CarAngle[4] // try now.
Most of the errors went away, but I still have one... CarModel[3]. Should I do CarModel[6]?

And I got all the errors here:

pawn Код:
mysql_fetch_field_row(string, "car1x"); pStats[playerid][CarPos1][1] = strval(string);
Here are all the errors

pawn Код:
ERP.pwn(356) : warning 215: expression has no effect
ERP.pwn(356) : error 001: expected token: ";", but found "["
ERP.pwn(356) : error 029: invalid expression, assumed zero
ERP.pwn(356) : warning 215: expression has no effect
ERP.pwn(356) : error 001: expected token: ";", but found "]"
ERP.pwn(356) : fatal error 107: too many error messages on one line



Re: Array out of bounds? - Nuke547 - 15.04.2012

It actually says that for all of them


Re: Array out of bounds? - ScottCFR - 15.04.2012

Код:
CarID[5],Float:CarPos1[1],Float:CarPos2[2],Float:CarPos3[3],Float: CarAngle[4];
Try this.


Re: Array out of bounds? - Nuke547 - 15.04.2012

nope, same errors


Re: Array out of bounds? - Nuke547 - 15.04.2012

So does anybody know whats wrong?


Re: Array out of bounds? - Rachael - 15.04.2012

show the entire enum please.


Re: Array out of bounds? - Nuke547 - 15.04.2012

pawn Код:
enum playerEnum {
    Name[20],
    Password[100],
    AdminName[20],
    ALevel,
    Job,
    Money,
    Bank,
    JustDied,
    Float: Health,
    Float: Armour,
    Skin,
    VIP,
    CarModel[6],
    CarID[5],
    Float: CarPos1[1],
    Float: CarPos2[2],
    Float: CarPos3[3],
    Float: CarAngle[4],
    Float: PosX,
    Float: PosY,
    Float: PosZ,
    Jailed,
    Hours,
    Materials,
    Logged,
    Banned,
    NewbieView,
    OOCView,
}
new pStats[MAX_PLAYERS][playerEnum];



Re: Array out of bounds? - Daniel-92 - 15.04.2012

pawn Код:
enum playerEnum {
    Name[20],
    Password[100],
    AdminName[20],
    ALevel,
    Job,
    Money,
    Bank,
    JustDied,
    Float: Health,
    Float: Armour,
    Skin,
    VIP,
    CarModel[6],
    CarID[5],
    Float: CarPos1,//[1],
    Float: CarPos2,//[2],
    Float: CarPos3,//[3],
    Float: CarAngle,//[4],
    Float: PosX,
    Float: PosY,
    Float: PosZ,
    Jailed,
    Hours,
    Materials,
    Logged,
    Banned,
    NewbieView,
    OOCView,
}
pawn Код:
mysql_fetch_field_row(string, "car1x"); pStats[playerid][CarPos1] = floatstr(string);