Jump to content
  • 0

npctalk color in script


Question

10 answers to this question

Recommended Posts

  • 0
Posted

I vaguely remember we discuss about *dispbottom2 and *message2 custom script command during my stay on hercules
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?do=findComment&comment=25468


answer is yes, it just not implemented
look at the npctalk inside script.cpp, it default to color_table[COLOR_WHITE], this value is hard-coded

BUILDIN_FUNC(npctalk)
{
	struct npc_data* nd = NULL;
	const char* str = script_getstr(st,2);

	if (script_hasdata(st, 3) && strlen(script_getstr(st,3)) > 0)
		nd = npc_name2id(script_getstr(st, 3));
	else
		nd = (struct npc_data *)map_id2bl(st->oid);

	if (nd != NULL) {
		send_target target = AREA;
		char message[CHAT_SIZE_MAX];

		if (script_hasdata(st, 4)) {
			switch(script_getnum(st, 4)) {
				case BC_ALL:	target = ALL_CLIENT;	break;
				case BC_MAP:	target = ALL_SAMEMAP;	break;
				case BC_SELF:	target = SELF;			break;
				case BC_AREA:
				default:		target = AREA;			break;
			}
		}
		safesnprintf(message, sizeof(message), "%s", str);
		if (target != SELF)
			clif_messagecolor(&nd->bl, color_table[COLOR_WHITE], message, false, target);
		else {
			TBL_PC *sd = map_id2sd(st->rid);
			if (sd == NULL)
				return SCRIPT_CMD_FAILURE;
			clif_messagecolor_target(&nd->bl, color_table[COLOR_WHITE], message, false, target, sd);
		}
	}
	return SCRIPT_CMD_SUCCESS;
}

 

so I play around again with it, Hercules plugin of course,

#include "common/hercules.h"
#include "map/clif.h"
#include "map/script.h"
#include "common/HPMDataCheck.h"

HPExport struct hplugin_info pinfo = {
	"messagecolor",
	SERVER_TYPE_MAP,
	"0.1",
	HPM_VERSION,
};

BUILDIN(messagecolor) {
	struct block_list *bl = map->id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return false;
	}
	clif->messagecolor( bl, script_getnum(st,4), script_getstr(st,3) );
	return true;
}

HPExport void plugin_init (void) {
	addScriptCommand( "messagecolor", "isi", messagecolor );
}
prontera,155,185,5	script	kjsdhfksjf	1_F_MARIA,{
//	messagecolor getcharid(3), "asdfasdf", C_BLUE; <-- doesn't work
	messagecolor getnpcid(), "asdfasdf", C_BLUE;
	messagecolor getnpcid(), "asdfasdf", C_RED;
	messagecolor getnpcid(), "asdfasdf", C_YELLOW;
	messagecolor getnpcid(), "asdfasdf", C_PINK;
	messagecolor getnpcid(), "asdfasdf", C_PURPLE;
	messagecolor getnpcid(), "asdfasdf", C_ORANGE;
	end;
}

screen2019Hercules027.jpg

 

 

2. forget the whisper feature, that thing is from the past
everyone use *bindatcmd now

https://github.com/rathena/rathena/blob/master/doc/whisper_sys.txt

  • 0
Posted
9 minutes ago, AnnieRuru said:

I vaguely remember we discuss about *dispbottom2 and *message2 custom script command during my stay on hercules
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?do=findComment&amp;comment=25468


answer is yes, it just not implemented
look at the npctalk inside script.cpp, it default to color_table[COLOR_WHITE], this value is hard-coded


BUILDIN_FUNC(npctalk)
{
	struct npc_data* nd = NULL;
	const char* str = script_getstr(st,2);

	if (script_hasdata(st, 3) && strlen(script_getstr(st,3)) > 0)
		nd = npc_name2id(script_getstr(st, 3));
	else
		nd = (struct npc_data *)map_id2bl(st->oid);

	if (nd != NULL) {
		send_target target = AREA;
		char message[CHAT_SIZE_MAX];

		if (script_hasdata(st, 4)) {
			switch(script_getnum(st, 4)) {
				case BC_ALL:	target = ALL_CLIENT;	break;
				case BC_MAP:	target = ALL_SAMEMAP;	break;
				case BC_SELF:	target = SELF;			break;
				case BC_AREA:
				default:		target = AREA;			break;
			}
		}
		safesnprintf(message, sizeof(message), "%s", str);
		if (target != SELF)
			clif_messagecolor(&nd->bl, color_table[COLOR_WHITE], message, false, target);
		else {
			TBL_PC *sd = map_id2sd(st->rid);
			if (sd == NULL)
				return SCRIPT_CMD_FAILURE;
			clif_messagecolor_target(&nd->bl, color_table[COLOR_WHITE], message, false, target, sd);
		}
	}
	return SCRIPT_CMD_SUCCESS;
}

 

so I play around again with it, Hercules plugin of course,


#include "common/hercules.h"
#include "map/clif.h"
#include "map/script.h"
#include "common/HPMDataCheck.h"

HPExport struct hplugin_info pinfo = {
	"messagecolor",
	SERVER_TYPE_MAP,
	"0.1",
	HPM_VERSION,
};

BUILDIN(messagecolor) {
	struct block_list *bl = map->id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return false;
	}
	clif->messagecolor( bl, script_getnum(st,4), script_getstr(st,3) );
	return true;
}

HPExport void plugin_init (void) {
	addScriptCommand( "messagecolor", "isi", messagecolor );
}

prontera,155,185,5	script	kjsdhfksjf	1_F_MARIA,{
//	messagecolor getcharid(3), "asdfasdf", C_BLUE; <-- doesn't work
	messagecolor getnpcid(), "asdfasdf", C_BLUE;
	messagecolor getnpcid(), "asdfasdf", C_RED;
	messagecolor getnpcid(), "asdfasdf", C_YELLOW;
	messagecolor getnpcid(), "asdfasdf", C_PINK;
	messagecolor getnpcid(), "asdfasdf", C_PURPLE;
	messagecolor getnpcid(), "asdfasdf", C_ORANGE;
	end;
}

screen2019Hercules027.jpg

 

 

2. forget the whisper feature, that thing is from the past
everyone use *bindatcmd now

https://github.com/rathena/rathena/blob/master/doc/whisper_sys.txt

Could you convert this plugin to rAthena please? instead of Hercules.

  • 0
Posted (edited)
46 minutes ago, Elysium said:

Could you convert this plugin to rAthena please? instead of Hercules.

BUILDIN_FUNC(messagecolor) {
	struct block_list *bl = map_id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return SCRIPT_CMD_FAILURE;
	}
	clif_messagecolor( bl, script_getnum(st,4), script_getstr(st,3), true, AREA);
	return SCRIPT_CMD_SUCCESS;
}
BUILDIN_DEF(messagecolor,"isi"),

 

Remember the reason why it doesn't work on players, because "@fontcolor" uses a trick to disguise player as monster
https://github.com/HerculesWS/Hercules/issues/1217
https://github.com/HerculesWS/Hercules/issues/1930

apparently rAthena "@fontcolor" is broken

Edited by AnnieRuru
  • 0
Posted
2 minutes ago, AnnieRuru said:

BUILDIN_FUNC(messagecolor) {
	struct block_list *bl = map_id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return SCRIPT_CMD_FAILURE;
	}
	clif_messagecolor( bl, script_getnum(st,4), script_getstr(st,3), true, AREA);
	return SCRIPT_CMD_SUCCESS;
}

BUILDIN_DEF(messagecolor,"isi"),

 

Remember the reason why it doesn't work on players, because "@fontcolor" uses a trick to disguise player as monster
https://github.com/HerculesWS/Hercules/issues/1217
https://github.com/HerculesWS/Hercules/issues/1930

Thank you Ma'dam! i'll test it

  • 0
Posted (edited)
52 minutes ago, AnnieRuru said:

1.

look at the npctalk inside script.cpp, it default to color_table[COLOR_WHITE], this value is hard-coded

 

2

so I play around again with it, Hercules plugin of course,

 

 

3. forget the whisper feature, that thing is from the past
everyone use *bindatcmd now

1. nice npctalk white is messy and bad.  now can change it...

2. thanks for that.

 

3. at the time it was still hot/ popular thing, I can barely get the concept of it ... that's why I am asking though.

4. wait a second what is "isi" ???

as in "Malay" language??? for content??? or it means???

Edited by utofaery
  • 0
Posted
9 minutes ago, utofaery said:

4. wait a second what is "isi" ???

as in "Malay" language??? for content??? or it means???

/*==========================================
 * Added built-in functions
 *------------------------------------------*/
static void add_buildin_func(void)
{
	int i;
	for( i = 0; buildin_func[i].func; i++ )
	{
		// arg must follow the pattern: (v|s|i|r|l)*\?*\*?
		// 'v' - value (either string or int or reference)
		// 's' - string
		// 'i' - int
		// 'r' - reference (of a variable)
		// 'l' - label
		// '?' - one optional parameter
		// '*' - unknown number of optional parameters

 

no idea what to say, its part of source modification

  • 0
Posted
4 hours ago, utofaery said:

1. nice npctalk white is messy and bad.  now can change it...

2. thanks for that.

 

3. at the time it was still hot/ popular thing, I can barely get the concept of it ... that's why I am asking though.

4. wait a second what is "isi" ???

as in "Malay" language??? for content??? or it means???

isi = integer, string, integer

  • 0
Posted

image.png.a2fa656f4f295d9f9ce28b8f13e671ad.png 

Quote

1@tnm3,176,172,5    script    kjsdhfksjf    1_F_MARIA,{
    messagecolor getcharid(3), "asdfasdf", C_BLUE;
    messagecolor getnpcid(0), "asdfasdf", C_BLUE;
    messagecolor getnpcid(0), "asdfasdf", C_RED;
    messagecolor getnpcid(0), "asdfasdf", C_YELLOW;
    messagecolor getnpcid(0), "asdfasdf", C_PINK;
    messagecolor getnpcid(0), "asdfasdf", C_PURPLE;
    messagecolor getnpcid(0), "asdfasdf", C_ORANGE;
    end;
}

Added the diff. for rathena recompiled & restarted server with the above script tested but apparently it is still showing white font instead of the specific color.

Anyone mind to share the solution to this?

Thanking you in advance for sharing.

Cheers.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...