Posts: 140
Threads: 35
Joined: Jul 2017
Good community, I need help in a command.
Someone can explain to me how to make a command / asay but with the messages in colors, that is, I explain, /asay (blue) Hello (red) as (yellow) are
The colors that are in the parentheses are the colors that will be shown in the chat when it is written, I have the following command:
CMD:asay(playerid, params[])
{
new text[128],string[128];
if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid,-1, "Use: /asay [message]);
format(string, sizeof(string),"Admin %s: %s", Name(playerid), text);
SendClientMessageToAll(-1,string);
return 1;
}
Posts: 186
Threads: 36
Joined: Dec 2017
you can make it like this
PHP код:
CMD:asay(playerid, params[])
{
new text[128],string[128], tmp2[33];
if(sscanf(params, "ss[128]", tmp2, text)) return SendClientMessage(playerid,-1, "Use: /asay [color] [message]");
if(strlen(tmp2) < 3 || strlen(tmp2) > 30) return SendClientMessage(playerid, COLOR_RED, "Error: The color should be between 3 and 30 characters.");
format(string, sizeof(string),"Admin %s: {%s}%s", Name(playerid), tmp2, text);
SendClientMessageToAll(-1,string);
return 1;
}
00FF00 = Light Green
008800 = Dark Green
FF0000 = Red
CBCBCB = Grey
you can check color codes on w3school
/asay 00FF00 [message]
hope it work
Posts: 140
Threads: 35
Joined: Jul 2017
Quote:
Originally Posted by Dayrion
Whaaaaaaaat the fuck. Did you tested your code before posting it? Plus do you know that color are integer?
First, your code can be optimized by using isnull which check if a string is empty or no. If you want to add some color to your text, check that : https://sampwiki.blast.hk/wiki/Colors_List#Color_embedding
PHP код:
CMD:asay(playerid, params[])
{
new string[128];
if(isnull(params)) return SendClientMessage(playerid,-1, "Use: /asay [message]");
format(string, sizeof(string),"Admin %s: %s", Name(playerid), text);
SendClientMessageToAll(-1,string);
return 1;
}
|
HELP ME, I want is to put the colors with just write the name, example: /asay (cyan) Hello community (gray) of samp (red) forum
that one when writing one or with those colors the message appears from the color that I put it.
Posts: 140
Threads: 35
Joined: Jul 2017
29.03.2018, 16:02
(
Последний раз редактировалось SapMan; 29.03.2018 в 16:06.
Причина: Fail
)
Quote:
Originally Posted by Lokii
PHP код:
CMD:asay(playerid, params[])
{
new str[144]; //text max is 144 not 128
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "s[144]", params)) return SendClientMessage(playerid, -1, "/asay [message]"); //we can use params instead of making another str2[144]; //useless
format(string, sizeof(string),"Admin %s: %s", Name(playerid), params);
SendClientMessageToAll(-1, string);
return 1;
}
|
I want it to be like that:
Sin tнtulo.png
And the message would be like that
Sin tнtulo2.png
Posts: 240
Threads: 5
Joined: Nov 2017
Quote:
Originally Posted by Dayrion
Whaaaaaaaat the fuck. Did you tested your code before posting it? Plus do you know that color are integer?
First, your code can be optimized by using isnull which check if a string is empty or no. If you want to add some color to your text, check that : https://sampwiki.blast.hk/wiki/Colors_List#Color_embedding
PHP код:
CMD:asay(playerid, params[])
{
new string[128];
if(isnull(params)) return SendClientMessage(playerid,-1, "Use: /asay [message]");
format(string, sizeof(string),"Admin %s: %s", Name(playerid), text);
SendClientMessageToAll(-1,string);
return 1;
}
|
A hex code consists of letters and numbers therefore it can not be fully a integer