Advertisement
Guest User

Untitled

a guest
Jul 11th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>#include <string.h>
  3. #include "../map/pc.h"
  4. #include "../map/clif.h"
  5. #include "../common/HPMi.h"
  6. #include "../common/socket.h"
  7. #include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)
  8.  
  9. HPExport struct hplugin_info pinfo = {
  10.     "gmimpersonate",    // Plugin name 
  11.     SERVER_TYPE_MAP,    // Which server types this plugin works with?
  12.     "0.1",              // Plugin version
  13.     HPM_VERSION,        // HPM Version (don't change, macro is automatically updated)
  14. };
  15.  
  16. bool clif_process_message_spaces(int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) {
  17.     if (retVal == true) {
  18.         char* message = (char*)RFIFOP(sd->fd, 4) + strnlen(sd->status.name, NAME_LENGTH - 1) + 3;
  19.         int i, l = strlen(message);
  20.         for (i = 0; i <= l; i++)
  21.             if (message[i] == 'xA0')
  22.                 message[i] = 'x20'; // replace Alt+0160 into [space]
  23.         if (stristr(message, "    ")) {
  24.             clif->messagecolor_self(sd->fd, COLOR_RED, "You are only allowed to type maximum of 3 spaces in a dialog.");
  25.             return false;
  26.         }
  27.         if (stristr(message, "x20x3Ax20") || stristr(message, "x20x3Bx20")) { // type " : " OR " ; " will be blocked
  28.             clif->messagecolor_self(sd->fd, COLOR_RED, "You can't impersonate other players !");
  29.             return false;
  30.         }
  31.     }
  32.     return true;
  33. }
  34.  
  35. HPExport void plugin_init(void) {
  36.     clif = GET_SYMBOL("clif");
  37.     session = GET_SYMBOL("session");
  38.     strlib = GET_SYMBOL("strlib");
  39.     addHookPost("clif->process_message", clif_process_message_spaces);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement