Skip to content

Commit

Permalink
Merge pull request #79 from MidnightTokyo/unturnedchat-multi-chat-sup…
Browse files Browse the repository at this point in the history
…port

Added multi-chat support for UnturnedChat methods
  • Loading branch information
SDGNelson authored Nov 19, 2024
2 parents a20b4ab + 4b88055 commit f2e41ac
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions Rocket.Unturned/Chat/UnturnedChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,37 @@ public static void Say(CSteamID CSteamID, string message, Color color)
Say(CSteamID, message, color, false);
}

public static List<string> wrapMessage(string text)
{
if (text.Length == 0) return new List<string>();
string[] words = text.Split(' ');
List<string> lines = new List<string>();
string currentLine = "";
int maxLength = 90;
foreach (var currentWord in words)
{

if ((currentLine.Length > maxLength) ||
((currentLine.Length + currentWord.Length) > maxLength))
{
lines.Add(currentLine);
currentLine = "";
}

if (currentLine.Length > 0)
currentLine += " " + currentWord;
else
currentLine += currentWord;

}

if (currentLine.Length > 0)
lines.Add(currentLine);
return lines;
public static List<string> wrapMessage(string text)
{
if (text.Length == 0)
return new List<string>();

string[] words = text.Split(' ');
List<string> lines = new List<string>();
string currentLine = "";
int maxLength = ChatManager.MAX_MESSAGE_LENGTH;

foreach (var currentWord in words)
{

if ((currentLine.Length > maxLength) ||
((currentLine.Length + currentWord.Length) > maxLength))
{
lines.Add(currentLine);
currentLine = "";
}

if (currentLine.Length > 0)
currentLine += " " + currentWord;
else
currentLine += currentWord;

}

if (currentLine.Length > 0)
lines.Add(currentLine);

return lines;
}
}
}

0 comments on commit f2e41ac

Please sign in to comment.