Macros (?) for enums/arrays
#1

I have an enum/array for player data, but instead of having to put

pData[playerid][pName]

I tried this:

#define pName[%1] pData[%1][pName]

to allow me to just put

pName[playerid]

but I got a bunch of errors:

Quote:

(32) : error 001: expected token: "}", but found "["
(35) : error 021: symbol already defined: "pData"
(71) : error 028: invalid subscript (not an array or too many subscripts): "pData"
(71) : warning 215: expression has no effect
(71) : error 001: expected token: ";", but found "]"
(71) : error 029: invalid expression, assumed zero
(71) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.

:/

Here's all the stuff:

pawn Код:
#define pName[%1] pData[%1][pName]

enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
}

new pData[MAX_PLAY][E_PDATA]; // Line 35

public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME); // Line 71
}
Reply
#2

pawn Код:
enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
}
should be

pawn Код:
enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
};
Reply
#3

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
}
should be

pawn Код:
enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
};
That's not a problem.

Why are you using macros for arrays?
Reply
#4

@SuperViper: Tried it, makes one more error.

@Topaz: It's easier.
Reply
#5

Just comment or remove the macro because you are not using the macro properly.
Reply
#6

Erm, the reason I made this topic was to request some assistance in getting it to work, not to remove it. Do you know how to do it properly?
Reply
#7

I read that entire topic, found nothing relevant. Is there no way to do this? I've done similar things before...
Reply
#8

Quote:
Originally Posted by MP2
Посмотреть сообщение
Erm, the reason I made this topic was to request some assistance in getting it to work, not to remove it. Do you know how to do it properly?
Can you specify the reason behind that?
Reply
#9

EDIT: Worked it out. The macro was 'pName[]' and so was the array in the enum. They were conflicting
Works!
Reply
#10

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
}
should be

pawn Код:
enum E_PDATA
{
    pLoginStatus,
    pName[MAX_PLAYER_NAME] // Line 32
};
This doesnt matter lol
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)