SendClientMessageF Macro
#1

Hi,
I need macro of SendClientMessageF(playerid, color, message, format{...})

I tried
Код:
new FALSE = false;
#define SendFormattedText(%1,%2,%3, %4) do{new sendfstring[128];format(sendfstring,128,(%3),%4);SendClientMessage((%1), (%2) ,sendfstring);}while(FALSE)
but it don't work.

Have maybe someone fixed macro?

Thx,
un4seen
Reply
#2

pawn Код:
new
    FALSE = 0;
pawn Код:
#define SendClientMessageEx(%0,%1,%2,%3) \
do \
{ \
  new \
      string[128]; \
  if(strlen(%2) > 0) \
  { \
    format(string, sizeof(string), %2, %3); \
    SendClientMessage(%0, %1, string); \
  } \
} \
while(FALSE)
pawn Код:
// example with formatting:
new
    name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
SendClientMessageEx(playerid, 0xFFFFFFAA, "Your name is %s", name)
pawn Код:
// example without formatting:
SendClientMessageEx(playerid, 0xFFFFFFAA, "Hello.", 0)
Reply
#3

Love you.

Works, thx!
Reply
#4

There shouldn't be a space after "%3," in the original code so it should be:
pawn Код:
new FALSE = false;
#define SendFormattedText(%1,%2,%3,%4) do{new sendfstring[128];format(sendfstring,128,(%3),%4);SendClientMessage((%1), (%2) ,sendfstring);}while(FALSE)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)