Macro problem
#1

Hey there

I'm trying to make a macro, like this one:

pawn Код:
#define SVR_ERR_MSG(%0,%1) SendClientMessage(%0, COLOR_RED, "(Server) >> " %1);
But with this kind of code:

pawn Код:
new string[128];
format(string, sizeof(string), "(Server) >> %s did this...", pName(playerid));
SendClientMessageToAll(COLOR_RED, string);
But I have no idea how to deal with the variables in maccro, and imagine if I had several variables, like pName(playerid), pName(targetid)...

I tried to make it, and I got this:

pawn Код:
#define SVR_MSG(%0, %1, %2) \
    new string[128]; \
    format(string, sizeof(string), "(Server) >>" %1); \
    SendClientMessage(%0, -1, %1);
Does anyone know how to do that?

Thanks
Reply
#2

pawn Код:
new
    g_szStr[144]
;
#define SendFormatMessage(%0,%1,%2) \
    format(g_szStr,sizeof(g_szStr),%2),SendClientMessage((%0),(%1),g_szStr)
Use a global string.
Reply
#3

Thank you :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)