Array out of bounds?
#1

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?
Reply
#2

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

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
Reply
#4

It actually says that for all of them
Reply
#5

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

nope, same errors
Reply
#7

So does anybody know whats wrong?
Reply
#8

show the entire enum please.
Reply
#9

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];
Reply
#10

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)