Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GetLastEmbColor(string[])
- {
- new color[10];
- for(new i = strlen(string); i != -1; i--)
- {
- if(string[i] == '}' && string[i - 7] == '{')
- {
- strmid(color, string, i - 6, i);
- if(IsValidEmbColor(color))
- return color;
- }
- }
- color[0] = 0;
- return color;
- }
- IsValidEmbColor(string[])
- {
- for(new i, j = strlen(string); i != j; i++)
- {
- if(!IsValidHexChar(string[i]))
- return 0;
- }
- return 1;
- }
- IsValidHexChar(c)
- {
- c = tolower(c);
- static const
- hex_chars[] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
- };
- for(new i; i < sizeof hex_chars; i++)
- if(c == hex_chars[i])
- return 1;
- return 0;
- }
- SendLongMessage(playerid, color, message[], charlimit = 80, prefix[] = "")
- {
- new start,
- len = strlen(message),
- prefixlen = strlen(prefix),
- realcolor[7];
- format(realcolor, sizeof realcolor, "%x", color);
- new idx = -1;
- while(idx++ != len)
- {
- if((idx - start) == (charlimit - prefixlen))
- {
- new send[128 + 1];
- strmid(send, message, start, idx);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessage(playerid, -1, send);
- format(realcolor, sizeof realcolor, "%s", GetLastEmbColor(send));
- start = idx;
- }
- else if(idx == len)
- {
- new send[128 + 1];
- strmid(send, message, start, idx + 1);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessage(playerid, -1, send);
- }
- else
- {
- if(message[idx] == '{')
- {
- if(idx + 7 < len)
- {
- if(message[idx + 7] == '}')
- {
- if((idx + 7 + prefixlen) >= (start + charlimit))
- {
- new buff[9];
- strmid(buff, message, idx + 1, idx + 7);
- if(IsValidEmbColor(buff))
- {
- new send[128 + 1];
- strmid(send, message, start, idx);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessage(playerid, -1, send);
- format(realcolor, sizeof realcolor, "%s", GetLastEmbColor(send));
- start = idx;
- }
- }
- }
- }
- }
- else if(message[idx] == '\n')
- {
- new send[128 + 1];
- strmid(send, message, start, idx);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessage(playerid, -1, send);
- format(realcolor, sizeof realcolor, "%s", GetLastEmbColor(send));
- start = idx;
- }
- }
- }
- return 1;
- }
- SendLongMessageToAll(color, message[], charlimit = 80, prefix[] = "")
- {
- new start,
- len = strlen(message),
- prefixlen = strlen(prefix),
- realcolor[7];
- format(realcolor, sizeof realcolor, "%x", color);
- new idx = -1;
- while(idx++ != len)
- {
- if((idx - start) == (charlimit - prefixlen))
- {
- new send[128 + 1];
- strmid(send, message, start, idx);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessageToAll(-1, send);
- format(realcolor, sizeof realcolor, "%s", GetLastEmbColor(send));
- start = idx;
- }
- else if(idx == len)
- {
- new send[128 + 1];
- strmid(send, message, start, idx + 1);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessageToAll(-1, send);
- }
- else
- {
- if(message[idx] == '{')
- {
- if(idx + 7 < len)
- {
- if(message[idx + 7] == '}')
- {
- if((idx + 7 + prefixlen) >= (start + charlimit))
- {
- new buff[9];
- strmid(buff, message, idx + 1, idx + 7);
- if(IsValidEmbColor(buff))
- {
- new send[128 + 1];
- strmid(send, message, start, idx);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessageToAll(-1, send);
- format(realcolor, sizeof realcolor, "%s", GetLastEmbColor(send));
- start = idx;
- }
- }
- }
- }
- }
- else if(message[idx] == '\n')
- {
- new send[128 + 1];
- strmid(send, message, start, idx);
- format(send, sizeof send, "%s{%s}%s", prefix, realcolor, send);
- SendClientMessageToAll(-1, send);
- format(realcolor, sizeof realcolor, "%s", GetLastEmbColor(send));
- start = idx;
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment