enums, arrays halp.
#1

pawn Код:
CMD:open(playerid, params[])
{
    new Float:d[6];
    for(new i = 0; i != 6; ++i) {
        GetObjectPos(PlayerGates[i],d[0],d[1],d[2]); //line 859
        if(IsPlayerInRangeOfPoint(playerid, 5.0, d[0],d[1],d[2]))
        {
            MoveObject(PlayerGates[i],d[0],d[1],0,5.0,d[3],d[4],d[5]); //line 862
            break;
        }
    }
    return 1;
}
pawn Код:
//top of the script
enum pGates
{
    gate1,
    gate2,
    gate3,
    gate4,
    gate5
}

new PlayerGates[pGates];
Errors:
pawn Код:
(859) : warning 213: tag mismatch
(862) : warning 213: tag mismatch
Reply
#2

Do you get the same warnings if you just create a normal 5-cell array? I can't remember any tags related to objects, but it seems that PlayerGates is the variable causing the errors.
Reply
#3

No, however as I said, this is the first time I try using arrays and enums, so I've most likely screwed something up.
Reply
#4

Took me a while to see this, but I just remembered that if you create a named enum, you essentially tag its members with that name. With that knowledge, you can either do:

pawn Код:
PlayerGates[pGates:i]
or
pawn Код:
PlayerGates[_:i]
or
pawn Код:
for(new pGates:i = 0; i != 6; ++i) {
Whichever you prefer.
Reply
#5

Oh, sorry. I'm retarded. You're running a loop from 0 - 5 (6 indexes), while your array is only 5 indexes. You're also using the values 0 - 6 instead of "gate1", "gate2" and so on, so you really don't need the enum.

Just declare it as a normal array ([6] instead of [pGates]) unless you're going to use "gate1" and such to choose index. If you still want to use the enum, you have to put "pGates:" infront of the value, like so:

pawn Код:
PlayerGates[pGates:i]
Although I'm not entirely sure if that even works.

Ninja'd.
Reply
#6

Thank you.
I got it to work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)