#1

This chat system is supposed to split the string once the message is 50 characters long, and continue it on the next line. However, it splits the string then repeats the last few charaters. I will change the length to 100, but the line doesn't stop at 100, if you understand what im saying

pawn Код:
new string[150], string1[150], string2[150];
        if(strlen(text) > 50)
        {
            format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
            strmid(string1, string, 53, 100);
            format(string2, sizeof(string2), "... %s", string1);
            ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
            ProxDetector(10, playerid, string2, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
            print(string);
            print(string2);
        }

        else
        {
            format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
            ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
            print(string);
        }
Reply
#2

Anybody?
Reply
#3

can you post to result of that script send out ?
Reply
#4

Quote:

new string[144];//max char in one line
if(strlen(text) > 50)
{
new string1[50], string2[100];
strmid(string1, text, 0, 49);// cut 50 first to string 1(0-49 = 50)
strmid(string2, text, 50, strlen(string));//and more to string 2(50 - real sizeof text)
format(string, sizeof(string), "%s says: %s", GetName(playerid), string1);
ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
format(string, sizeof(string), "...%s", string2);
ProxDetector(10, playerid, string2, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
}
else
{
format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
print(string);
}

you wanna do like this ?
Reply
#5

Quote:
Originally Posted by Kapupc
Посмотреть сообщение
you wanna do like this ?
That's what I was looking for, i'll try it and let you know.
Reply
#6

not surely i'm newbie let try i'm making gamemode too
Reply
#7

sorry my bad edit it to
Quote:

new string[144];//max char in one line
if(strlen(text) > 50)
{
new string1[50], string2[100];
strmid(string1, text, 0, 49);// cut 50 first to string 1(0-49 = 50)
strmid(string2, text, 50, strlen(text));//and more to string 2(50 - real sizeof text)
format(string, sizeof(string), "%s says: %s", GetName(playerid), string1);
ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
format(string, sizeof(string), "...%s", string2);
ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
}
else
{
format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
ProxDetector(10, playerid, string, 0xE6E6E6AA, 0xC8C8C8AA, 0xAAAAAAAA, 0x8C8C8CAA, 0x6E6E6EAA);
print(string);
}

Reply
#8

I wrote this for my GM:

pawn Код:
stock real_SendClientMessage(playerid, COLOR, string[], size = sizeof(string))
{
    new
        szString2[128],
        bool:iSplit;
       
    if(strlen(string) > 128)
    {
        new
            szLastHexColor[9],
            iStartPosition;
           
        while((iStartPosition = strfind(string, "{", true, iStartPosition)) != -1)
        {
            strmid(szLastHexColor, string, iStartPosition, iStartPosition+8);
            iStartPosition += 8;
        }
       
        strmid(szString2, string, 128, 256);
        strdel(string, 128, 256);
        strcat(string, " ..", size);
        strins(szString2, " .. ", 0);
        if(!isnull(szLastHexColor)) strins(szString2, szLastHexColor, 0);
        iSplit = true;
    }
       
    if(iSplit) SendClientMessage(playerid, COLOR, string), SendClientMessage(playerid, COLOR, szString2);
    else SendClientMessage(playerid, COLOR, string);
    return 1;
}
It also tries to take into account the possibility of HEX colors being embedded into the string. I noticed that it would cut the string in bad places (i.e. in the middle of a HEX color code) and would screw it all up. The function works like a charm though!
Reply
#9

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
I wrote this for my GM:

pawn Код:
stock real_SendClientMessage(playerid, COLOR, string[], size = sizeof(string))
{
    new
        szString2[128],
        bool:iSplit;
       
    if(strlen(string) > 128)
    {
        new
            szLastHexColor[9],
            iStartPosition;
           
        while((iStartPosition = strfind(string, "{", true, iStartPosition)) != -1)
        {
            strmid(szLastHexColor, string, iStartPosition, iStartPosition+8);
            iStartPosition += 8;
        }
       
        strmid(szString2, string, 128, 256);
        strdel(string, 128, 256);
        strcat(string, " ..", size);
        strins(szString2, " .. ", 0);
        if(!isnull(szLastHexColor)) strins(szString2, szLastHexColor, 0);
        iSplit = true;
    }
       
    if(iSplit) SendClientMessage(playerid, COLOR, string), SendClientMessage(playerid, COLOR, szString2);
    else SendClientMessage(playerid, COLOR, string);
    return 1;
}
It also tries to take into account the possibility of HEX colors being embedded into the string. I noticed that it would cut the string in bad places (i.e. in the middle of a HEX color code) and would screw it all up. The function works like a charm though!
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)