Chat text parting
#6

I realize the original poster has some sort of a bigger issue on his hands with OnPlayerText callback, but a tip about the code that Shadoww5 posted...

If you want to split the text into two lines (move one part of the message to the next line) it would be nice if you actually looked for a space to split from!
pawn Код:
new space = -1, nextline[64];
if(strlen(text) > 80)
{
    space = strfind(text, " ", false, 60);
    if(space == -1 || space > 80) space = 70;

    strmid(nextline, text, space, strlen(text));
    strdel(text, space, strlen(text));
}
I suppose the example is a little rough and I might of have messed something up somewhere (hey! it is 2am!) but it makes a good theory.
The next step would be displaying the lines if necessary!
pawn Код:
new str[128], PlayerName[24];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(str, sizeof(str), "%s(%i): %s", PlayerName, playerid, text);
SendClientMessageToAll(COLOR, str);
if(space != -1)
    SendClientMessageToAll(COLOR, nextline);
Of course return false in the end. You could probably add some color formatting like
pawn Код:
format(str, sizeof(str), "%06x%s(%i){FFFFFF}: %s", GetPlayerColor(playerid) >>> 8, PlayerName, playerid, text);
Reply


Messages In This Thread
Chat text parting - by spaty2 - 19.07.2011, 17:43
Re: Chat text parting - by Shadoww5 - 19.07.2011, 20:58
Re: Chat text parting - by spaty2 - 19.07.2011, 21:44
Re: Chat text parting - by spaty2 - 19.07.2011, 22:05
Re: Chat text parting - by Shadoww5 - 19.07.2011, 22:12
Re: Chat text parting - by AndreT - 19.07.2011, 23:14
Re: Chat text parting - by spaty2 - 20.07.2011, 08:38

Forum Jump:


Users browsing this thread: 3 Guest(s)