Chat text parting -
spaty2 - 19.07.2011
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
Re: Chat text parting -
Shadoww5 - 19.07.2011
PHP код:
public OnPlayerText(playerid, text[])
{
if(strlen(text) >= 64)
{
new str[128], n[24], sStr[128];
GetPlayerName(playerid, n, sizeof n);
strmid(sStr, text, 64, strlen(text));
strdel(text, 64, strlen(text));
format(str, sizeof str, "%s: %s ...", n, text);
SendClientMessageToAll(0xFFFFFFFF, str);
format(str, sizeof str, "... %s", sStr);
SendClientMessageToAll(0xFFFFFFFF, str);
return 0;
}
return 1;
}
Re: Chat text parting -
spaty2 - 19.07.2011
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
Re: Chat text parting -
spaty2 - 19.07.2011
So where i must add it
Re: Chat text parting -
Shadoww5 - 19.07.2011
Post the whole public.
Re: Chat text parting -
AndreT - 19.07.2011
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);
Re: Chat text parting -
spaty2 - 20.07.2011
I really don't know how to do that