if(strcmp(cmd, "/write", true) == 0 && PlayerAdminLevel[playerid] >= 1){
if(IsAdminOrRecon[playerid] == 0){
SendClientMessage(playerid,COLOR_ERROR,"Please Login Into Your Mod/Admin Account! Use /adminlog");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /write [Colour] [Text]");
SendClientMessage(playerid, COLOR_WHITE, "Colours: 0=black 1=white 2=red 3=orange 4=yellow 5=green 6=blue 7=purple 8=brown 9=pink");
return 1;
}
new Colour;
Colour = strval(tmp);
if(Colour > 9 || Colour < 0) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /write [Colour] [Text]");
SendClientMessage(playerid, COLOR_WHITE, "Colours: 0=black 1=white 2=red 3=orange 4=yellow 5=green 6=blue 7=purple 8=brown 9=pink");
return 1;
}
tmp = strtok(cmdtext, idx);
if(Colour == 0) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_BLACK,string);
return 1;
}
else if(Colour == 1) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_WHITE,string);
return 1;
}
else if(Colour == 2) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_RED,string);
return 1;
}
else if(Colour == 3) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}
else if(Colour == 4) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_YELLOW,string);
return 1;
}
else if(Colour == 5) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_GREEN,string);
return 1;
}
else if(Colour == 6) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_BLUE,string);
return 1;
}
else if(Colour == 7) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_PURPLE,string);
return 1;
}
else if(Colour == 8) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_BROWN,string);
return 1;
}
else if(Colour == 9) {
format(string,256,"%s",cmdtext[9]); SendClientMessageToAll(COLOR_PINK,string);
return 1;
}
return 1;
}
public OnPlayerText(playerid, text[])
{
return SendPlayerMessageToAll(playerid, ColouredText(text)), 0;
}
//---
stock ColouredText(text[])
{
enum
colorEnum
{
colorName[16],
colorID[7]
}
;
new
colorInfo[][colorEnum] =
{
{ "1", "1B1BE0" }, //Blue
{ "2", "E81CC9" }, //Pink
{ "3", "DBED15" }, //Yellow
{ "4", "8CED15" }, //Lightgreen
{ "5", "15D4ED" }, //Lightblue
{ "6", "FF0000" }, //Red
{ "7", "BABABA" }, //Grey
{ "8", "FFFFFF" }, //White
{ "9", "DB881A" }, //Orange
{ "10", "37DB45" }, //Green
{ "11", "7340DB" } //Purple
},
string[(128 + 32)],
tempString[16],
pos = -1,
x
;
strmid(string, text, 0, 128, sizeof(string));
for( ; x != sizeof(colorInfo); ++x)
{
format(tempString, sizeof(tempString), "#%s", colorInfo[x][colorName]);
while((pos = strfind(string, tempString, true, (pos + 1))) != -1)
{
new
tempLen = strlen(tempString),
tempVar,
i = pos
;
format(tempString, sizeof(tempString), "{%s}", colorInfo[x][colorID]);
if(tempLen < 8)
{
for(new j; j != (8 - tempLen); ++j)
{
strins(string, " ", pos);
}
}
for( ; ((string[i] != 0) && (tempVar != 8)) ; ++i, ++tempVar)
{
string[i] = tempString[tempVar];
}
if(tempLen > 8)
{
strdel(string, i, (i + (tempLen - 8)));
}
x = -1;
}
}
return string;
}
what i mean when i type
/write 0 Hello! 5 how are you the sentence cant be colored 2 colors its stay black only! i want when i type like this /write 0 Hello 5How are you 4 Fine?? like sentence be colors more than 1 color! |
if(strcmp(cmd, "/write", true) == 0 && PlayerAdminLevel[playerid] >= 1)
{
if(IsAdminOrRecon[playerid] == 0)
{
SendClientMessage(playerid,COLOR_ERROR,"Please Login Into Your Mod/Admin Account! Use /adminlog");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; }
new offset = idx, result[128], string[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx], idx++; }
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /write [Colour] [Text]");
SendClientMessage(playerid, COLOR_WHITE, "Colours: #1 = Blue | #2 = Pink | etc.");
//#1Just #2an #3example#4!
return 1;
}
format(string,256,"%s", result), SendClientMessageToAll(COLOR_BLACK, ColouredText(string));
return 1;
}
stock ColouredText(text[]) //Thanks to RyDeR`
{
enum colorEnum { colorName[16], colorID[7] } ;
new
colorInfo[][colorEnum] =
{
{ "1", "1B1BE0" }, //Blue
{ "2", "E81CC9" }, //Pink
{ "3", "DBED15" }, //Yellow
{ "4", "8CED15" }, //Lightgreen
{ "5", "15D4ED" }, //Lightblue
{ "6", "FF0000" }, //Red
{ "7", "BABABA" }, //Grey
{ "8", "FFFFFF" }, //White
{ "9", "DB881A" }, //Orange
{ "10", "37DB45" }, //Green
{ "11", "7340DB" } //Purple
},
string[(128 + 32)], tempString[16], pos = -1, x;
strmid(string, text, 0, 128, sizeof(string));
for( ; x != sizeof(colorInfo); ++x)
{
format(tempString, sizeof(tempString), "#%s", colorInfo[x][colorName]);
while((pos = strfind(string, tempString, true, (pos + 1))) != -1)
{
new tempLen = strlen(tempString), tempVar, i = pos;
format(tempString, sizeof(tempString), "{%s}", colorInfo[x][colorID]);
if(tempLen < 8)
{
for(new j; j != (8 - tempLen); ++j)
{
strins(string, " ", pos);
}
}
for( ; ((string[i] != 0) && (tempVar != 8)) ; ++i, ++tempVar)
{
string[i] = tempString[tempVar];
}
if(tempLen > 8)
{
strdel(string, i, (i + (tempLen - 8)));
}
x = -1;
}
}
return string;
}
if(strcmp(cmd, "/write", true) == 0 && PlayerAdminLevel[playerid] >= 1){
if(IsAdminOrRecon[playerid] == 0){
SendClientMessage(playerid,COLOR_ERROR,"Please Login Into Your Mod/Admin Account! Use /adminlog");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /write [Text]");
SendClientMessage(playerid, COLOR_ERROR, "You can Do Colored Text! Ex. /write #1Hi #2How are you!");
SendClientMessage(playerid, COLOR_ERROR, "#1, #2, #3, #4, #5, #6, #7, #8, #9, #10");
return 1;
}
new output[125];
strmid(output,cmdtext,7,strlen(cmdtext));
format(string,256,"%s",cmdtext[9]);
SendClientMessageToAll(playerid,ColouredText(output));
return 1;
}