04.08.2011, 18:13
Quote:
SA-MP scripters have so much code bound to enum style structs. I doubt this would be an easy transition. I do like what it has been replaced with. There is a much cleaner way of defining structs now and accessing member variables.
|
Quote:
- Previous versions of pawn used enumerations and tags to simulate a light-weight variant of structures. This has been replaced by a more direct way to declare "symbolic indices" in arrays. An array can now be declared as: new rect[.left, .top, .right, .bottom] The array can then only be indexed with one of the declared symbolic fields, such as in: rect[.bottom] = rect[.top] + 15 Since the only valid index is a symbolic field, the brackets may be omitted, giving the shorter equivalent: rect.bottom = rect.top + 15 Symbolic indices may specify a tag for the field, and may also indicate a (pseudo-)array. Please see the "Language Guide" for details. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ - To make the new way to specify symbolic indices more practical, the "#define" preprocessor directive now also supports definitions that are delimited with square brackets. This means that definitions do not have to fit on a single line. An example of such a declaration: #define PRODUCT[ .code, .description{20}, Float: .price ] Later, this definition can be used to declare an array, for example: new product[PRODUCT] |
pawn Code:
enum ePlayerInfo
{
Skin,
Money
}
new PlayerInfo[MAX_PLAYERS][ePlayerInfo];
pawn Code:
#define PLAYERINFO[
.Skin,
.Money
]
new PlayerInfo[MAX_PLAYERS][PLAYERINFO];