I am working on a simple plugin for a game emulator in C++.
The purpose of the plugin is to detect if message posted by user contains more than 3 spaces or message with these strings: :
or ;
The code looks like this so far:
#include "common/hercules.h"
#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/socket.h"
#include "common/strlib.h"
#include "map/clif.h"
#include "map/pc.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
HPExport struct hplugin_info pinfo = {
"GM Impersonate", // Plugin name
SERVER_TYPE_MAP, // Which server types this plugin works with?
"1.0", // Plugin version
HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
};
bool my_pc_process_chat_message(bool retVal___, struct map_session_data *sd, const char *message) {
if (retVal___ == true) {
if (stristr(message, " ")) {
clif->messagecolor_self(sd->fd, COLOR_RED, "Possible GM Impersonation Detected - you cannot use more than 3 spaces in chat.");
return false;
}
if (stristr(message, " : ") || stristr(message, " ; ")) {
clif->messagecolor_self(sd->fd, COLOR_RED, "Possible GM Impersonation Detected - you cannot use : or ; in chat.");
return false;
}
}
return true;
}
HPExport void plugin_init(void) {
addHookPost(pc, process_chat_message, my_pc_process_chat_message);
}
I am not a C++ programmer, I used a sample plugin to work this code out, which appears to be working miraculously. I am now trying to improve this little plugin to detect invisible glyphs, as if they were spaces, in the message
char array.
How can I achieve this?
I found this post - https://stackoverflow.com/a/15813530/2332336 but this appears to be for string, not char array. Any ideas?