Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Use this instead of SendClientMessage (or hook it)
- // The function automatically seeks for a space after the character number 100 and splits the message into a new line.
- // If colors are used, the limit character (100) increases per color used by 8 characters (amount of character a color takes) to have lines of the same length at all times.
- // Colors are also transfered to the lines that are splitted as the Last color used is detected and put infront of the new line.
- // It's not that fast if you're planning on rendering 1M colors at once.
- 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;
- }
- stock RenderMessageToAll(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)
- {
- 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(tosearch <= 0)
- {
- SendClientMessageToAll(color, mess);
- break;
- }
- 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);
- SendClientMessageToAll(color, temp);
- strdel(mess,0,tosearch);
- strins(mess, lastcol, 0);
- temp = "";
- tosearch = 0;
- colors = 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement