LucasViniciusLV

[CODE] - SendClientMessageFormatted - Y_less

Jun 24th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.41 KB | None | 0 0
  1. //Modo de uso:
  2. SendClientMessageFormatted(playerid, -1, "Olá, %s. Bem-vindo ao @ThunderGamesBR");
  3.  
  4. //Y_less
  5. SendClientMessageFormatted(playerid, color, fstring[], {Float, _}:...)
  6. {
  7.   new n = numargs() * 4;
  8.  
  9.   if (n == 3 * 4)
  10.   {
  11.         return SendClientMessage(playerid, color, fstring);
  12.   }
  13.   else
  14.   {
  15.         new message[128];
  16.         new arg_start;
  17.         new arg_end;
  18.         new i = 0;
  19.  
  20.         #emit CONST.pri  fstring
  21.         #emit ADD.C    0x4
  22.         #emit STOR.S.pri arg_start // first parameters's offset
  23.  
  24.         #emit LOAD.S.pri n
  25.         #emit ADD.C    0x8
  26.         #emit STOR.S.pri arg_end  // last parameters's offset
  27.  
  28.         // pushing variable arguments
  29.         for (i = arg_end; i >= arg_start; i -= 4)
  30.         {
  31.             #emit LCTRL    5
  32.             #emit LOAD.S.alt i
  33.             #emit ADD
  34.             #emit LOAD.I
  35.             #emit PUSH.pri
  36.         }
  37.         // pushing normal arguments
  38.         #emit PUSH.S  fstring // format string
  39.         #emit PUSH.C  128   // sizeof(message)
  40.         #emit PUSH.ADR message // the string which format() will write in
  41.         #emit PUSH.S  n    // number of arguments * 4, always must be passed for natives
  42.         #emit SYSREQ.C format
  43.  
  44.         // clearing the stack
  45.         i = n / 4 + 1;
  46.         while (--i >= 0)
  47.         {
  48.             #emit STACK 0x4
  49.         }
  50.  
  51.         return SendClientMessage(playerid, color, message);
  52.   }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment