10.06.2012, 20:58
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
// 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);
}
}
SendSplitMessage(playerid, color, msg);
|
pawn Code:
pawn Code:
|
|
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.
[Repped+]
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;
}
[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?