Grimmjow 1 Posted July 13, 2016 (edited) I want to ask help from experts to adapt code for the latest version of Hercules. I tried to change, but not enough knowledge in src. Please help. Open clif.c Найти void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) After: char *name, *message; int namelen, messagelen; Add: char prefix[255]; // prefix for timestamp [Qwadrat] time_t t = time(NULL); // time var [Qwadrat] Continue to find: // send message to others (using the send buffer for temp. storage) And to prepend: // timestamp feature by Qwadrat strftime(prefix, 10, "[%H:%M] ", localtime(&t)); strcat(prefix,text); textlen = strlen(prefix)+1; Further: // send message to others (using the send buffer for temp. storage) Replace the original piece of code: WFIFOHEAD(fd, 8 + textlen); WFIFOW(fd,0) = 0x8d; WFIFOW(fd,2) = 8 + textlen; WFIFOL(fd,4) = sd->bl.id; safestrncpy((char*)WFIFOP(fd,8), prefix, textlen); clif_send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC); // send back message to the speaker //memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));-original memcpy(WFIFOP(fd,4), prefix, textlen); // [Qwadrat] WFIFOW(fd,0) = 0x8e; WFIFOW(fd,2) = RFIFOW(fd,2) + 8; // 8 - textlen [Qwadrat] WFIFOSET(fd, WFIFOW(fd,2)); Edited July 13, 2016 by Jeagerjaques Quote Share this post Link to post Share on other sites
0 Samuel 83 Posted July 14, 2016 I think this is the plugin you need to use for this.. https://github.com/dastgir/HPM-Plugins/blob/master/src/plugins/chat_timestamp.c Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted July 14, 2016 I think this is the plugin you need to use for this.. https://github.com/dastgir/HPM-Plugins/blob/master/src/plugins/chat_timestamp.c I assumed the same, but he wants it everywhere and this plugin works only in guild/party channels Quote Share this post Link to post Share on other sites
0 Samuel 83 Posted July 14, 2016 yeah, just saw the code and found out that it works with guild and party chat only for now.. hmm, will try to do a plugin for normal chat. Quote Share this post Link to post Share on other sites
0 Habilis 119 Posted July 14, 2016 (edited) And you probably already got why the plugin is done that way... getting a timestamp for every single ramble in common chat would load the the server. Hence, all the spamming / flooding happens in common chat. Edited July 14, 2016 by Habilis Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted July 15, 2016 dastgir updated the plugin, try it! Quote Share this post Link to post Share on other sites
0 Samuel 83 Posted July 16, 2016 (edited) dastgir updated the plugin, try it! tried it but it's not working.. well he said in his commit that it's in trial.. try this: #include "common/hercules.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "common/HPMi.h" #include "common/memmgr.h" #include "common/mmo.h" #include "common/nullpo.h" #include "common/strlib.h" #include "common/socket.h" #include "map/clif.h" #include "map/map.h" #include "map/pc.h" #include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" HPExport struct hplugin_info pinfo = { "Chat TimeStamp", SERVER_TYPE_MAP, "1.0", HPM_VERSION, }; const char *clif_process_chat_message_post(const char *retVal___, struct map_session_data *sd, const struct packet_chat_message *packet, char *out_buf, int out_buflen) { char prefix[CHAT_SIZE_MAX + NAME_LENGTH + 3 + 1]; time_t t; int textlen = 0, namelen = 0; nullpo_ret(sd); if (retVal___ == NULL) return NULL; #if PACKETVER >= 20151001 // Packet doesn't include a NUL terminator textlen = packet->packet_len - 4; #else // PACKETVER < 20151001 // Packet includes a NUL terminator textlen = packet->packet_len - 4 - 1; #endif // PACKETVER > 20151001 safestrncpy(out_buf,packet->message,textlen+1); t = time(NULL); strftime(prefix, 10, "[%H:%M] ", localtime(&t)); strcat(prefix, out_buf); safestrncpy(out_buf,prefix,textlen+10); retVal___ = out_buf; return retVal___; } HPExport void plugin_init (void) { addHookPost(clif, process_chat_message, clif_process_chat_message_post); } Edit: It's working as I have tested it, the only thing that bothers me is this warning I get when I compile with Visual Studio 2011 warning C4090: 'function' : different 'const' qualifiers Edit2: how to use code with code select? Edited July 16, 2016 by Samuel Quote Share this post Link to post Share on other sites
0 ucell_uz 1 Posted November 24, 2017 (edited) hello guys need your help i used Hercules-master_2015-12-17--15-58.zip old libconfig 1.4.9 this plugins for my version not working but only edited On 13.07.2016 at 11:47 PM, Grimmjow said: Open clif.c please help! need normal working plugins for libconfig 1.4.9 Edited November 24, 2017 by ucell_uz Quote Share this post Link to post Share on other sites
0 Dastgir 1246 Posted November 26, 2017 On 24/11/2017 at 6:04 AM, ucell_uz said: hello guys need your help i used Hercules-master_2015-12-17--15-58.zip old libconfig 1.4.9 this plugins for my version not working but only edited please help! need normal working plugins for libconfig 1.4.9 Hide contents That's because you have other plugin enabled (Sample plugin) Quote Share this post Link to post Share on other sites
I want to ask help from experts to adapt code for the latest version of Hercules.
I tried to change, but not enough knowledge in src.
Please help.
Share this post
Link to post
Share on other sites