Jump to content
  • 0

Script Command Mes2


M4karov

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   36
  • Joined:  04/01/13
  • Last Seen:  

How to create a color message using the "mes" command?

In case I want to write:

mes2 "Red Color";

And in-game appears:
Red color

Note:
without using "^FF0000 ^000000

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

function	script	mes2	{

	setarray .@color$[0],"red","ff0000","green","00ff00","blue","0000ff";

	.@str$ = strtolower(getarg(0));
	.@mes$ = getarg(1);
	.@color = inarray(.@color$,.@str$);
	mes ((.@color != -1)? "^"+.@color$[.@i + 1] : "") + .@mes$;
	return;

}

	mes2 "red","Hello there.";
	mes2 "green","What's up?";
	close;

Add colors in .@color$

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   36
  • Joined:  04/01/13
  • Last Seen:  

Thanks for replying, but in case it would be by source same. No script.

By script I had already done, wanted to change.

 

function	script	F_Color	{
	if(getarg(1) == "null")
			return "";
	setarray .@cores$[0], "amarelo", "^FFFF00", "azul", "^0000FF",
						"branco", "^EEE9E9", "dourado", "^DAA520",
						"cinza", "^696969", "laranja", "^FF7F00",
						"marrom","^8B4726", "preto", "^000000",
						"roxo", "^4527A0", "vermelho", "^FF0000", 
						"verde", "^1B5E20";
						 
	.@cor$ = strtolower(getarg(1));
	for(.@i = 0; .@i < getarraysize(.@cores$); .@i += 2)
		if(.@cores$[.@i] == getarg(1))
			return .@cores$[.@i + 1]  + getarg(0) + "^000000";
	return getarg(1) + getarg(0) + "^000000";
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

I'm not really good with source but I tried...

BUILDIN_FUNC(mes2)
{
	TBL_PC* sd;
	if( !script_rid2sd(sd) )
		return SCRIPT_CMD_SUCCESS;

	int color_n = script_getnum(st,2);
	char *message;

	size_t len = 0;

	unsigned long color = color_table[color_n];

	char color_string = "^";
	char color_code = (char*)color;

	message = (char*)aMalloc(2);

	len = strlen(color_code);
	memcpy(&message, color_string, 1);
	memcpy(&message, color_code, len);
	temp = script_getstr(st, 3);
	len = strlen(temp);
	memcpy(&message, temp, len);

	clif_scriptmes(sd, st->oid, message));

	st->mes_active = 1; // Invoking character has a NPC dialog box open.
	return SCRIPT_CMD_SUCCESS;
}

BUILDIN_DEF(mes2,"is"),

EDIT: Forgot to say this uses the channel system colors... if it works.

Edited by n0tttt
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...