SHOW:
|
|
- or go back to the newest paste.
1 | // Use this instead of SendClientMessage (or hook it) | |
2 | // The function automatically seeks for a space after the character number 100 and splits the message into a new line. | |
3 | // 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. | |
4 | // Colors are also transfered to the lines that are splitted as the Last color used is detected and put infront of the new line. | |
5 | // It's not that fast if you're planning on rendering 1M colors at once. | |
6 | ||
7 | stock RenderMessage(top, color, const text[]) | |
8 | { | |
9 | new temp[156], tosearch = 0, colorint, posscolor, lastcol[12]; | |
10 | new mess[356], colors, tempc; format(mess, 356, "%s",text); | |
11 | ||
12 | while(strlen(mess) > 0) | |
13 | { | |
14 | if(strlen(mess) < 140) | |
15 | { | |
16 | SendClientMessage(top, color, mess); | |
17 | break; | |
18 | } | |
19 | ||
20 | strmid(temp, mess, 0, 128); | |
21 | while(strfind(temp, "{", true) != -1) | |
22 | { | |
23 | tempc = strfind(temp, "{", true); | |
24 | if(temp[tempc+7] == '}') | |
25 | { | |
26 | colors ++; | |
27 | strdel(temp, tempc, tempc+7); | |
28 | } | |
29 | else | |
30 | { | |
31 | temp[tempc] = '0'; | |
32 | continue; | |
33 | } | |
34 | } | |
35 | temp = ""; | |
36 | ||
37 | if(strfind(mess," ",true,100+colors*8) != -1) | |
38 | { | |
39 | tosearch = strfind(mess," ",true,100+colors*8)+1; | |
40 | while(tosearch > 140) | |
41 | { | |
42 | colors --; | |
43 | tosearch = strfind(mess," ",true,100+colors*8)+1; | |
44 | } | |
45 | } | |
46 | ||
47 | if(strfind(mess,"{",true) != -1) //color codes detection , YAY | |
48 | { | |
49 | posscolor = strfind(mess,"{",true); | |
50 | ||
51 | if(mess[posscolor+7] == '}') //detected one color | |
52 | colorint = posscolor; | |
53 | ||
54 | while(strfind(mess,"{",true,colorint+1) != -1) //repeat until none are found | |
55 | { | |
56 | posscolor = strfind(mess,"{",true,colorint+1); | |
57 | if(posscolor > tosearch) //if next color will be on the other line, use last color found to render on the next line | |
58 | { | |
59 | posscolor = colorint; | |
60 | break; | |
61 | } | |
62 | if(mess[posscolor+7] == '}') //if found, then assign the color | |
63 | { | |
64 | colorint = posscolor; | |
65 | } | |
66 | else | |
67 | { | |
68 | posscolor = colorint; //else, leave the last color. | |
69 | break; | |
70 | } | |
71 | } | |
72 | ||
73 | if(colorint == posscolor) //if the color position equals the one that was found | |
74 | strmid(lastcol,mess,colorint,colorint+8); //get the last used color string. | |
75 | } | |
76 | ||
77 | strmid(temp, mess, 0, tosearch); | |
78 | SendClientMessage(top, color, temp); | |
79 | strdel(mess, 0, tosearch); | |
80 | strins(mess, lastcol, 0); //insert last used color into the new line to be processed. | |
81 | ||
82 | ||
83 | temp = ""; | |
84 | tosearch = 0; | |
85 | colors = 0; | |
86 | } | |
87 | return 1; | |
88 | } | |
89 | ||
90 | stock RenderMessageToAll(color, const text[]) | |
91 | { | |
92 | new temp[156], tosearch = 0, colorint, posscolor, lastcol[12]; | |
93 | new mess[356], colors, tempc; format(mess, 356, "%s",text); | |
94 | ||
95 | while(strlen(mess) > 0) | |
96 | { | |
97 | strmid(temp, mess, 0, 128); | |
98 | while(strfind(temp, "{", true) != -1) | |
99 | { | |
100 | tempc = strfind(temp, "{", true); | |
101 | if(temp[tempc+7] == '}') | |
102 | { | |
103 | colors ++; | |
104 | strdel(temp, tempc, tempc+7); | |
105 | } | |
106 | else | |
107 | { | |
108 | temp[tempc] = '0'; | |
109 | continue; | |
110 | } | |
111 | } | |
112 | temp = ""; | |
113 | ||
114 | if(strfind(mess," ",true,100+colors*8) != -1) | |
115 | { | |
116 | tosearch = strfind(mess," ",true,100+colors*8)+1; | |
117 | while(tosearch > 140) | |
118 | { | |
119 | colors --; | |
120 | tosearch = strfind(mess," ",true,100+colors*8)+1; | |
121 | } | |
122 | } | |
123 | if(tosearch <= 0) | |
124 | { | |
125 | SendClientMessageToAll(color, mess); | |
126 | break; | |
127 | } | |
128 | ||
129 | if(strfind(mess,"{",true) != -1) //color codes detection , YAY | |
130 | { | |
131 | posscolor = strfind(mess,"{",true); | |
132 | ||
133 | if(mess[posscolor+7] == '}') //detected one color | |
134 | colorint = posscolor; | |
135 | ||
136 | while(strfind(mess,"{",true,colorint+1) != -1) //repeat until none are found | |
137 | { | |
138 | posscolor = strfind(mess,"{",true,colorint+1); | |
139 | if(posscolor > tosearch) //if next color will be on the other line, use last color found to render on the next line | |
140 | { | |
141 | posscolor = colorint; | |
142 | break; | |
143 | } | |
144 | if(mess[posscolor+7] == '}') //if found, then assign the color | |
145 | { | |
146 | colorint = posscolor; | |
147 | } | |
148 | else | |
149 | { | |
150 | posscolor = colorint; //else, leave the last color. | |
151 | break; | |
152 | } | |
153 | } | |
154 | ||
155 | if(colorint == posscolor) //if the color position equals the one that was found | |
156 | strmid(lastcol,mess,colorint,colorint+8); //get the last used color string. | |
157 | } | |
158 | ||
159 | strmid(temp, mess, 0, tosearch); | |
160 | SendClientMessageToAll(color, temp); | |
161 | strdel(mess,0,tosearch); | |
162 | strins(mess, lastcol, 0); | |
163 | ||
164 | temp = ""; | |
165 | tosearch = 0; | |
166 | colors = 0; | |
167 | } | |
168 | return 1; | |
169 | } |