// Oxxy (C) 2015, HPM plugin. #include #include #include #include "../common/HPMi.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/strlib.h" #include "../map/clif.h" #include "../map/script.h" #include "../map/pc.h" #include "../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */ HPExport struct hplugin_info pinfo = { "Chat Color", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated) }; ACMD(setcolor) { unsigned short msg_len = 1; char mout[40]; unsigned char cc = script->add_str("CHAT_COLOR$"); unsigned long color1 = strtoul("0x000000",NULL,0); // DEFAULT: GREEN unsigned long color2; char *tmp = pc_readglobalreg_str(sd, cc); if(tmp != NULL) color2 = strtoul(tmp, NULL, 0); if( !message || !*message ) { clif->message(fd, "Usage: @setcolor "); clif->message(fd, " must be in hex format. Starting with 0x"); clif->message(fd, "Example: @color 0x00FF00"); return 0; } if(message[0] == "0") { pc_setglobalreg_str(sd, cc, "0x000000"); return true; } pc_setglobalreg_str(sd, cc, message); msg_len += sprintf(mout, "Color changed to '%s'", cc); WFIFOHEAD(fd,msg_len + 12); WFIFOW(fd,0) = 0x2C1; WFIFOW(fd,2) = msg_len + 12; WFIFOL(fd,4) = 0; if(color2 != "") // if CHAT_COLOR != "" WFIFOL(fd,8) = (color2&0x0000FF) << 16 | (color2&0x00FF00) | (color2&0xFF0000) >> 16; // RGB -> BGR else // if CHAT_COLOR == "" WFIFOL(fd,8) = (color1&0x0000FF) << 16 | (color1&0x00FF00) | (color1&0xFF0000) >> 16; // RGB -> BGR safestrncpy((char*)WFIFOP(fd,12), mout, msg_len); WFIFOSET(fd, msg_len + 12); return true; } HPExport void plugin_init (void) { /* core vars */ iMalloc = GET_SYMBOL("iMalloc"); script = GET_SYMBOL("script"); clif = GET_SYMBOL("clif"); pc = GET_SYMBOL("pc"); addAtcommand("setcolor", setcolor); //addScriptCommand("color","is",color) } HPExport void server_online (void) { ShowInfo ("'%s' Plugin by Oxxy. Version '%s'\n",pinfo.name,pinfo.version); }