05.05.2010, 17:40
I see lots of people making complex defines like
not to write
But why don't just do:
Or
?
This works perfectly and it's very simple. It can take a infinite number of argument, and it's much faster than all the other SendFormattedMessage functions I've seen. At least I'm sure of it, am I wrong?
pawn Код:
#define SendFormat(%0,%1,%2,%3) do{new str[128];format(_str,128,%2,%3);SendClientMessage(%0,%1,_str);}while(FALSE)
pawn Код:
new string[128];
format(string, sizeof(string), "grdgr %d rgsrg", integer);
SendClientMessage(playerid, COLOR, string);
pawn Код:
#define FormatMsg(%0,%1,%2,%3) format(%2, sizeof(%2), %3); \
SendClientMessage(%0, %1, %2)
//%0 = playerid, %1 = color, %2 = string to format then send, %3 = string content
//Example of use:
new string[128];
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
FormatMsg(playerid, COLOR, string, "Message sent to pl %d named %s", playerid, name);
pawn Код:
#define FormatMsgEx(%0,%1,%2) new STRING[128]; \
format(STRING, 128, %2); \
SendClientMessage(%0, %1, %2)
//%0 = playerid, %1 = color, %2 = string content
//Example of use:
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
FormatMsgEx(playerid, COLOR, "Message sent to pl %d named %s", playerid, name);
This works perfectly and it's very simple. It can take a infinite number of argument, and it's much faster than all the other SendFormattedMessage functions I've seen. At least I'm sure of it, am I wrong?