Help with macro?
#4

A macro replaces code by something "easier".

For example, if you take your macro:

pawn Код:
#define GetName(%1) new name[MAX_PLAYER_NAME]; GetPlayerName(%1, name, MAX_PLAYER_NAME); return name
Should you use it for example:

pawn Код:
format(string, sizeof string, "Hey %s", GetName(playerid));
It would compile as:

pawn Код:
format(string, sizeof string, "Hey %s", new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); return name);
Now obviously that'll cause the compiler to error.

So here's what the problem is: A macro replaces a piece of code. You must use a function to retrieve a variable.
Reply


Messages In This Thread
Help with macro? - by [H]265 - 11.11.2010, 15:24
Re: Help with macro? - by The_Moddler - 11.11.2010, 15:28
Re: Help with macro? - by [H]265 - 11.11.2010, 15:30
Re: Help with macro? - by Hiddos - 11.11.2010, 15:30

Forum Jump:


Users browsing this thread: 1 Guest(s)