Making the Chat 2 lines -
Black Axe - 10.06.2012
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
Re: Making the Chat 2 lines -
Macluawn - 10.06.2012
uz
split
Re: Making the Chat 2 lines -
Black Axe - 11.06.2012
Sorry but i am still learning how to script - An Example would be useful
AW: Making the Chat 2 lines -
Extremo - 11.06.2012
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.
Re: AW: Making the Chat 2 lines -
Cxnnor - 11.06.2012
Quote:
Originally Posted by Extremo
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.
AW: Re: AW: Making the Chat 2 lines -
Extremo - 11.06.2012
Quote:
Originally Posted by Cxnnor
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.
Re: AW: Re: AW: Making the Chat 2 lines -
Cxnnor - 11.06.2012
Quote:
Originally Posted by Extremo
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.
Re: Making the Chat 2 lines -
Black Axe - 11.06.2012
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]
Re: Making the Chat 2 lines -
Black Axe - 11.06.2012
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(string, sizeof(string), "Stranger says: [%s Accent] %s",Accent[playerid],text);
}
else
{
format(string, sizeof(string), "Stranger says: %s",text);
}
}
else
{
if(strcmp(Accent[playerid],"none",true,3))
{
format(string, sizeof(string), "%s says: [%s Accent] %s",RemoveUnderScore(playerid),Accent[playerid],text);
}
else
{
format(string, sizeof(string), "%s says: %s",RemoveUnderScore(playerid),text);
}
}
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
return 0;
}
return 1;
}
AW: Re: Making the Chat 2 lines -
Extremo - 11.06.2012
Quote:
Originally Posted by Black Axe
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?