NPC Chat length ?

10/05/2010 06:29 Donyboi#1
iam some what confused why some NPC's chats that are long show and wen i made this script i seem to only get so much of my chat text the last bit to be displayed is red is there a limit to chat lenght or size of chatbubble :confused:


thanx in advance
}
if (Control == 1)
{
GC.AddSend(Packets.NPCSay("Every week there's a LastMan Standing Tournament with 1 winner emerging to claim a Handsome prize. You'll see a broadcast 10 minite's before start come see me to sign up and i'll teleport you to the waiting area. Its a 1 v 1 match randomly selected.Loser leaves,winner goes to next stage.Match's continue untill 1 player left standing.NO healing of any kind. "));
GC.AddSend(Packets.NPCLink("Can i have more details?", 11));
GC.AddSend(Packets.NPCLink("Sounds cool...", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
10/05/2010 09:09 Korvacs#2
You have to send 2 NPCSay packets, because each packet has a character limit.
10/05/2010 22:09 killersub#3
Quote:
Originally Posted by Korvacs View Post
You have to send 2 NPCSay packets, because each packet has a character limit.
:handsdown:
10/06/2010 03:59 pro4never#4
Note: the string length is using a byte so therefor the max chars you can use for the string packet msg is 255. If I were you in your send chat function I'd check the length of what you want to submit and split it into individual packets and send them all.

Sec... I feel like writing it up.

<edit>

Fully working afaik. Check incoming string for length. If it's short enough for one packet send as one. If not split into as many as needed.

Code:
public static void LongChat(string text, Client Client)
        {
            if (text.Length < 255)
            {
                Text(text, Client);
                return;
            }            
            string[] Words = text.Split(' ');
            string Final = "";
            foreach (string Word in Words)
            {
                if (Final.Length + Word.Length + 1 < 255)
                    Final += Word + " ";
                else
                {
                    Text(Final, Client);
                    Final = Word + " ";
                }
            }
            Text(Final, Client);
        }