Macros (?) for enums/arrays -
MP2 - 17.01.2012
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
}
Re: Macros (?) for enums/arrays -
SuperViper - 17.01.2012
pawn Код:
enum E_PDATA
{
pLoginStatus,
pName[MAX_PLAYER_NAME] // Line 32
}
should be
pawn Код:
enum E_PDATA
{
pLoginStatus,
pName[MAX_PLAYER_NAME] // Line 32
};
Re: Macros (?) for enums/arrays - T0pAz - 17.01.2012
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?
Re: Macros (?) for enums/arrays -
MP2 - 17.01.2012
@SuperViper: Tried it, makes one more error.
@Topaz: It's easier.
Re: Macros (?) for enums/arrays - T0pAz - 17.01.2012
Just comment or remove the macro because you are not using the macro properly.
Re: Macros (?) for enums/arrays -
MP2 - 17.01.2012
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?
Re: Macros (?) for enums/arrays -
MP2 - 17.01.2012
I read that entire topic, found nothing relevant. Is there no way to do this? I've done similar things before...
Re: Macros (?) for enums/arrays - T0pAz - 17.01.2012
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?
Re: Macros (?) for enums/arrays -
MP2 - 17.01.2012
EDIT: Worked it out. The macro was 'pName[]' and so was the array in the enum. They were conflicting

Works!
Re: Macros (?) for enums/arrays -
thimo - 17.01.2012
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