Making the Chat 2 lines
#1

Well.. I Was wondering how to make that once the player type something in the chat and it's too long for one line - the chat continue in the second line - hope to get help
Reply
#2

uz split
Reply
#3

Sorry but i am still learning how to script - An Example would be useful
Reply
#4

pawn Code:
// Define when to split the text into another line!
#define EX_SPLITLENGTH 118

stock SendSplitMessage(playerid, color, final[])
{
    new buffer[EX_SPLITLENGTH+5];
    new len = strlen(final);
    if(len>EX_SPLITLENGTH)
    {
        new times = (len/EX_SPLITLENGTH);
        for(new i = 0; i < times+1; i++)
        {
            strdel(buffer, 0, EX_SPLITLENGTH+5);
            if(len-(i*EX_SPLITLENGTH)>EX_SPLITLENGTH)
            {
                strmid(buffer, final, EX_SPLITLENGTH*i, EX_SPLITLENGTH*(i+1));
                format(buffer, sizeof(buffer), "%s ...", buffer);
            }
            else
            {
                strmid(buffer, final, EX_SPLITLENGTH*i, len);
            }
            SendClientMessage(playerid, color, buffer);
        }
    }
    else
    {
        SendClientMessage(playerid, color, final);
    }
}
Usage:

pawn Code:
SendSplitMessage(playerid, color, msg);
EDIT:

The above code is just more or less an example and may or may not be really fast processing your strings. Your probably better off using split.
Reply
#5

Quote:
Originally Posted by Extremo
View Post
pawn Code:
// Define when to split the text into another line!
#define EX_SPLITLENGTH 118

stock SendSplitMessage(playerid, color, final[])
{
    new buffer[EX_SPLITLENGTH+5];
    new len = strlen(final);
    if(len>EX_SPLITLENGTH)
    {
        new times = (len/EX_SPLITLENGTH);
        for(new i = 0; i < times+1; i++)
        {
            strdel(buffer, 0, EX_SPLITLENGTH+5);
            if(len-(i*EX_SPLITLENGTH)>EX_SPLITLENGTH)
            {
                strmid(buffer, final, EX_SPLITLENGTH*i, EX_SPLITLENGTH*(i+1));
                format(buffer, sizeof(buffer), "%s ...", buffer);
            }
            else
            {
                strmid(buffer, final, EX_SPLITLENGTH*i, len);
            }
            SendClientMessage(playerid, color, buffer);
        }
    }
    else
    {
        SendClientMessage(playerid, color, final);
    }
}
Usage:

pawn Code:
SendSplitMessage(playerid, color, msg);
That would work, I recommend using it.
Reply
#6

Quote:
Originally Posted by Cxnnor
View Post
That would work, I recommend using it.
Of course it works I just coded it! Haha, still, I haven't benchmarked it and have no idea how fast it is. Though on average it should be pretty quick. Depending on how many times it'll have to split it'll increase in time though.
Reply
#7

Quote:
Originally Posted by Extremo
View Post
Of course it works I just coded it! Haha, still, I haven't benchmarked it and have no idea how fast it is. Though on average it should be pretty quick. Depending on how many times it'll have to split it'll increase in time though.
It's a good code, when you benchmark it and get the correct speed it will be great, I will benchmark it later when I get home, and then work out the speed, if you wish me to.
Reply
#8

Well.. Not really - It didn't work , Tested it IG and the chat is still 1 line.. Thanks for helping tho [Repped+]

[And No - I am better than you in using splits xD]
Reply
#9

Damn me - I am such an idiot , I Didn't test it right xD


Edit : Well , I Don't get how to use it - I Want to make that once the player type in a "Long" thing it will split up in the normal chat.. Here is my chat system


PHP Code:
    if(realchat)
    {
        if(
gPlayerLogged[playerid] == 0)
        {
            return 
0;
          }
          else if(
PlayerInfo[playerid][pMask] == 1)
          {
              if(
strcmp(Accent[playerid],"none",true,3))
            {
                
format(stringsizeof(string), "Stranger says: [%s Accent] %s",Accent[playerid],text);
            }
            else
            {
                
format(stringsizeof(string), "Stranger says: %s",text);
            }
          }
          else
          {
              if(
strcmp(Accent[playerid],"none",true,3))
            {
                
format(stringsizeof(string), "%s says: [%s Accent] %s",RemoveUnderScore(playerid),Accent[playerid],text);
            }
            else
            {
                
format(stringsizeof(string), "%s says: %s",RemoveUnderScore(playerid),text);
            }
          }
          
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        return 
0;
    }
    return 
1;

Reply
#10

Quote:
Originally Posted by Black Axe
View Post
Damn me - I am such an idiot , I Didn't test it right xD
Just tested it and it works flawless

Code:
[09:19:54] This is a pretty long test string to see how fast this thing will actually split the string. Let's see how well it wor ...
[09:19:54] ks with this shall we?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)