stock RenderMessage(top, color, const text[])
{
new temp[156], tosearch = 0, colorint, posscolor, lastcol[12];
new mess[356], colors, tempc; format(mess, 356, "%s",text);
while(strlen(mess) > 0)
{
if(strlen(mess) < 140)
{
SendClientMessage(top, color, mess);
break;
}
strmid(temp, mess, 0, 128);
while(strfind(temp, "{", true) != -1)
{
tempc = strfind(temp, "{", true);
if(temp[tempc+7] == '}')
{
colors ++;
strdel(temp, tempc, tempc+7);
}
else
{
temp[tempc] = '0';
continue;
}
}
temp = "";
if(strfind(mess," ",true,100+colors*8) != -1)
{
tosearch = strfind(mess," ",true,100+colors*8)+1;
while(tosearch > 140)
{
colors --;
tosearch = strfind(mess," ",true,100+colors*8)+1;
}
}
if(strfind(mess,"{",true) != -1) //color codes detection , YAY
{
posscolor = strfind(mess,"{",true);
if(mess[posscolor+7] == '}') //detected one color
colorint = posscolor;
while(strfind(mess,"{",true,colorint+1) != -1) //repeat until none are found
{
posscolor = strfind(mess,"{",true,colorint+1);
if(posscolor > tosearch) //if next color will be on the other line, use last color found to render on the next line
{
posscolor = colorint;
break;
}
if(mess[posscolor+7] == '}') //if found, then assign the color
{
colorint = posscolor;
}
else
{
posscolor = colorint; //else, leave the last color.
break;
}
}
if(colorint == posscolor) //if the color position equals the one that was found
strmid(lastcol,mess,colorint,colorint+8); //get the last used color string.
}
strmid(temp, mess, 0, tosearch);
SendClientMessage(top, color, temp);
strdel(mess, 0, tosearch);
strins(mess, lastcol, 0); //insert last used color into the new line to be processed.
temp = "";
tosearch = 0;
colors = 0;
}
return 1;
}
RenderMessage(playerid, 0xFFFFFFFF, "{FFFF00}0123456789 0123456789 {FF0000}0123456789 0123456789 {00FF00}0123456789 0123456789 {0000FF}0123456789 0123456789 {FFFF00}0123456789 0123456789 {00FFFF}0123456789 0123456789 {FF6600}0123456789 0123456789 0123456789 {FF66FF}0123456789 {0066FF}0123456789 0123456789");
RenderMessage(playerid, 0xFFFFFFFF, "{FFFF00}0123456789 0123456789 {FF0000}0123456789 0123456789 {00FF00}0123456789 0123456789 {0000FF}0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 {FF6600}0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789");
RenderMessage(playerid, 0xFFFFFFFF, "{FFFF00}0123456789 0123456789 {FF0000}0123456789 0123456789 {00FF00}0123456789 0123456789 0123456789 0123456789 {FFFF00}0123456789 0123456789 0123456789 0123456789 {00FFFF}0123456789 0123456789 {FF0000}0123456789 0123456789 {0066FF}0123456789 0123456789 0123456789 0123456789 {FFFF00}0123456789 0123456789");

Input
RenderMessage(0, 0xFFFFFFFF, "{FFFF00}0123456789 0123456789 {FF0000}0123456789 0123456789 {00FF00}0123456789 0123456789 0123456789 0123456789 {FFFF00}0123456789 0123456789 0123456789 0123456789 {00FFFF}0123456789 0123456789 {FF0000}0123456789 0123456789 {0066FF}0123456789 0123456789 0123456789 0123456789 {FFFF00}0123456789 0123456789");
Outputs
Sent 10 messages in 3 MS
Sent 100 messages in 43 MS
Sent 1000 messages in 297 MS
Sent 10000 messages in 2772 MS
Sent 100000 messages in 27551 MS
|
That's not the point of the function;
Besides the dialogs inputtexts are just as long as the inputted text at the normal chat. EDIT: saw you editted it! :P |
if(strlen(mess) < 140) SendClientMessage(top, color, mess);
else
{
|
It's still not slow enough to really cause any sort of bottle neck I would think it's actually kind of silly to measure it against complete impossibility of 100,0000 iterations when you'll probably have no more than a dozen during any given one second period.
|