Chat text parting
#1

Hey, when i writing text on my server like:
"Hello world, how are you? Im fine, but this text is not so good because it parting."

If i post this, it will post only one part like:

"Hello world, how are you? Im fine, but this text is not so"

And next part dissapears..

Do you know how to make that, it will part but next part will post in next new message? automaticaly? Thx
Reply
#2

PHP код:
public OnPlayerText(playeridtext[])
{
    if(
strlen(text) >= 64)
    {
        new 
str[128], n[24], sStr[128];
        
GetPlayerName(playeridnsizeof n);
        
strmid(sStrtext64strlen(text));
        
strdel(text64strlen(text));
        
format(strsizeof str"%s: %s ..."ntext);
        
SendClientMessageToAll(0xFFFFFFFFstr);
        
format(strsizeof str"... %s"sStr);
        
SendClientMessageToAll(0xFFFFFFFFstr);
        return 
0;
    }
    return 
1;

Reply
#3

Under onplayertext i have this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new giver[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new tmp[256];
    new string[256];
    new giveplayerid;
 if(PlayerInfo[playerid][pMuted] == 1)
    {
        SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
        return 0;
    }
so how to add
Reply
#4

So where i must add it
Reply
#5

Post the whole public.
Reply
#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
#7

I really don't know how to do that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)