Advertisement
AwDod

splitmessage

Oct 28th, 2023
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.86 KB | None | 0 0
  1. #define MAX_CHARS_PER_LINE                          128
  2. #define FINAL_DOTS
  3.  
  4. stock SendSplitMsg(const player, const color, const message[])
  5. {
  6.     if(!IsPlayerConnected(player))
  7.         return INVALID_PLAYER_ID;
  8.  
  9.     new numLines = strlen(message) / MAX_CHARS_PER_LINE;
  10.  
  11.     if(strlen(message) % MAX_CHARS_PER_LINE)
  12.         numLines++;
  13.  
  14.     for(new index = 0; index < numLines; ++index)
  15.     {
  16.         new line[MAX_CHARS_PER_LINE + 5 + 5];
  17.         strmid(line, message, (index * MAX_CHARS_PER_LINE), (index * MAX_CHARS_PER_LINE) + MAX_CHARS_PER_LINE);
  18.  
  19.         #if defined FINAL_DOTS
  20.         if(numLines > 1)
  21.         {
  22.             if(!index)
  23.             {
  24.                 strins(line, " ...", strlen(line));
  25.             }
  26.             else if((index + 1) < numLines)
  27.             {      
  28.                 strins(line, " ...", strlen(line));
  29.                 strins(line, "... ", 0);
  30.             }
  31.             else
  32.             {
  33.                 strins(line, "... ", 0);
  34.             }
  35.         }
  36.         #endif
  37.  
  38.         SendClientMessage(player, color, line);
  39.     }
  40.     return 1;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement