Guest Aurela Posted September 2, 2014 (edited) Hello, c; I need a limitation for spaces in chat. For example: Name : Hello my name is l l l l You're only allowed to do max 3 spaces in a row. If anyone would be able to help me out I'd be very happy. Also, I will pay for this if needed. Edited September 3, 2014 by Aurela Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 3, 2014 I hope this is final one that will work patch src/map/clif.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..5b3418e 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,22 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ {+ int i, l = strlen(message);+ for ( i = 0; i <= l; i++ )+ if ( message[i] == 'xA0' )+ message[i] = 'x20'; // replace Alt+0160 into [space]+ if ( stristr( message, " " ) ) {+ clif->colormes( sd->fd, COLOR_RED, "You are only allow to type maximum of 3 spaces in a dialog." );+ return false;+ }+ if ( stristr( message, "x20x3Ax20" ) || stristr( message, "x20x3Bx20" ) ) { // type " : " OR " ; " will be blocked+ clif->colormes( sd->fd, COLOR_RED, "You can't impersonate other players !" );+ return false;+ }+ }+ return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../common/HPMi.h"#include "../common/socket.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 = { "GM_impersonate", // 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)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true ) { char* message = (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3; int i, l = strlen(message); for ( i = 0; i <= l; i++ ) if ( message[i] == 'xA0' ) message[i] = 'x20'; // replace Alt+0160 into [space] if ( stristr( message, " " ) ) { clif->colormes( sd->fd, COLOR_RED, "You are only allow to type maximum of 3 spaces in a dialog." ); return false; } if ( stristr( message, "x20x3Ax20" ) || stristr( message, "x20x3Bx20" ) ) { // type " : " OR " ; " will be blocked clif->colormes( sd->fd, COLOR_RED, "You can't impersonate other players !" ); return false; } } return true;}HPExport void plugin_init (void) { clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);}.. as it turns out, I just have to replace Alt+0160 into [space], then just block players from typing " : " is already enough no need some kind of blocklist after all 4 evilpuncker, Nova, Garr and 1 other reacted to this Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 2, 2014 willingly to pay ? omg, I can send this as a birthday gift patch src/map/clif.c | 5 +++++ 1 file changed, 5 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..ede1a52 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,11 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( stristr( message, " " ) != NULL ) {+ clif_displaymessage( fd, "You're only allowed to do max 3 spaces in a row." );+ return false;+ } return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../common/HPMi.h"#include "../common/socket.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 = { "max_3_space", // 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)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true ) { if ( stristr( (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3, " " ) != NULL ) { clif->message( sd->fd, "You're only allowed to do max 3 spaces in a row." ); return false; } } return true;}HPExport void plugin_init (void) { clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);} 2 Angelmelody and vBrenth reacted to this Quote Share this post Link to post Share on other sites
0 Guest Aurela Posted September 2, 2014 Awesome, thank you so much! Will try that as soon as I can and update if something does not work proper! -hugs- ♥ Quote Share this post Link to post Share on other sites
0 vBrenth 39 Posted September 2, 2014 (edited) Its working and i know why you want this because of the people who are trying to scam by using spaces on pub. They can still bypass this by using 2space+alt03232 again and again. Edited September 2, 2014 by Lumina 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 2, 2014 (edited) because of the people who are trying to scam by using spaces on pub.oh ? I thought I write this for fun without knowing what this actually does#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../common/HPMi.h"#include "../common/socket.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 = { "max_3_space", // 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)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true ) { char* message = (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3; if ( stristr( message, " " ) != NULL ) { clif->message( sd->fd, "Alt+03232 ? You must be joking, right ? Don't do that !" ); return false; } if ( stristr( message, " " ) != NULL ) { clif->message( sd->fd, "You're only allowed to do max 3 spaces in a row." ); return false; } } return true;}HPExport void plugin_init (void) { clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);}ok this is trickyif ( stristr( message, " " ) != NULL ) {this is not a spaceI Alt+03232 it and Notepad++ doesn't work has to use Windows Notepad, and manually type in Alt+03232 only works hmm ... I upload the file then max_3_space.c Edited September 2, 2014 by AnnieRuru Quote Share this post Link to post Share on other sites
0 vBrenth 39 Posted September 2, 2014 Weird because i can still use alt+03232 i notepad as u said but its tillworking. Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 2, 2014 (edited) @Lumina like I said, don't use Notepad++, manually type in Microsoft Windows Notepad classic one although, I got a better idea since in a chatroom, to impersonate other has to type long sentence and then [space] then follow by Name : how about we restrict them by not typing like this if ( sscanf( "%s : ", sd->name ) ) so if they type something like "EnnyRuru : " the script will detect it and stop it just for my personal reference ... getwaitingroomlist pc_getwaitingroomlist Edited September 2, 2014 by AnnieRuru 1 evilpuncker reacted to this Quote Share this post Link to post Share on other sites
0 vBrenth 39 Posted September 2, 2014 i did use windows notepad but when u transfer it to linux vps it will not work anymore hehe.. Maybe you can do that. well this 3max space will help alot for sure. Quote Share this post Link to post Share on other sites
0 evilpuncker 504 Posted September 2, 2014 @Lumina like I said, don't use Notepad++, manually type in Microsoft Windows Notepad classic one although, I got a better idea since in a chatroom, to impersonate other has to type long sentence and then [space] then follow by Name : how about we restrict them by not typing like this if ( sscanf( "%s : ", sd->name ) ) so if they type something like "EnnyRuru : " the script will detect it and stop it just for my personal reference ... getwaitingroomlist pc_getwaitingroomlist that idea is nice Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 2, 2014 (edited) try this patch src/map/clif.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..42790b9 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,20 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( sd->chatID ) {+ if ( stristr( message, ":" ) ) {+ struct chat_data *cd = (struct chat_data *)map->id2bl(sd->chatID);+ int i;+ for ( i = 0; i < cd->users; i++ ) {+ if ( stristr( message, cd->usersd[i]->status.name ) ) {+ clif->colormes( fd, COLOR_RED, "You can't impersonate others in a chatroom !" );+ return false; + }+ }+ }+ }+ return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../map/chat.h"#include "../common/HPMi.h"#include "../common/socket.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 = { "chatroom_impersonate", // 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)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true && sd->chatID ) { char* message = (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3; if ( stristr( message, ":" ) ) { struct chat_data *cd = (struct chat_data *)map->id2bl(sd->chatID); int i; for ( i = 0; i < cd->users; i++ ) { if ( stristr( message, cd->usersd[i]->status.name ) ) { clif->colormes( sd->fd, COLOR_RED, "You can't impersonate others in a chatroom !" ); return false; } } } } return true;}HPExport void plugin_init (void) { map = GET_SYMBOL("map"); clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);} Edited September 2, 2014 by AnnieRuru 1 evilpuncker reacted to this Quote Share this post Link to post Share on other sites
0 Jedzkie 58 Posted September 3, 2014 try this patch src/map/clif.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..42790b9 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,20 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( sd->chatID ) {+ if ( stristr( message, ":" ) ) {+ struct chat_data *cd = (struct chat_data *)map->id2bl(sd->chatID);+ int i;+ for ( i = 0; i < cd->users; i++ ) {+ if ( stristr( message, cd->usersd[i]->status.name ) ) {+ clif->colormes( fd, COLOR_RED, "You can't impersonate others in a chatroom !" );+ return false; + }+ }+ }+ }+ return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../map/chat.h"#include "../common/HPMi.h"#include "../common/socket.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 = { "chatroom_impersonate", // 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)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true && sd->chatID ) { char* message = (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3; if ( stristr( message, ":" ) ) { struct chat_data *cd = (struct chat_data *)map->id2bl(sd->chatID); int i; for ( i = 0; i < cd->users; i++ ) { if ( stristr( message, cd->usersd[i]->status.name ) ) { clif->colormes( sd->fd, COLOR_RED, "You can't impersonate others in a chatroom !" ); return false; } } } } return true;}HPExport void plugin_init (void) { map = GET_SYMBOL("map"); clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);} Not working AnnieRuru. Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 3, 2014 Not working AnnieRuru.define the word 'Not working' for me Quote Share this post Link to post Share on other sites
0 Guest Aurela Posted September 3, 2014 (edited) Woah, didn't knew about the '2space+alt03232' bypass. Hope that AnnieRuru's idea will work and that we'll have a fix soon for this (if AnnieRuru's is really "not working"), since that guy does not stop scamming players and also blackmails them. :l Edited September 3, 2014 by Aurela Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 3, 2014 *ahem* ... please test it and tell if it works =/ because I tested it working fine in my test server .... unless you guys found some other way to bypass this Quote Share this post Link to post Share on other sites
0 Guest Aurela Posted September 3, 2014 Apparantly it does not work if no one else is in the chatroom and also for example: If me and Frost are in the chat room and I try impersonate Frost, it won't work. But if AnnieRuru was online but not in the chat room, I could impersonate AnnieRuru.If that makes sense. Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 3, 2014 But if AnnieRuru was online but not in the chat room, I could impersonate AnnieRuru.wait, I thought its common sense that players only try to impersonate other players that are currently in the chat roomif AnnieRuru is not in the chatroom, of course can impersonate, but players should know that she is not in the chatroom so its busted, isn't it ? because at the right hand side of the chatroom, it list the players currently inside are you saying so I should run a loop for all online players instead of just players joined the chat room ? Quote Share this post Link to post Share on other sites
0 Guest Aurela Posted September 3, 2014 (edited) For example: The scammer creates a novice or already scammed another existing char and PM's someone with that char, saying that he's one of the admins and on his legit char. He tells him that the GM team wants to talk to him cause the team thinks that he/she would be a good GM too. The scammer lures them into another town and opens a chatroom with his scammed char. If the person he talked to entered the room he starts doing this on the picture. As you see "a gm is talking" even tho that GM is not in the chatroom. But 90% of the people don't get this trick. I had to look at it a few times too. He does that with serveral names and keeps confusing the player, then he gets the information he wants (account and such) and wants them to add them on skype to pay for their account, if the player wants his account back. Video ExampleTo your question: Most people dun take care of the player on the right side in that situation, it's unbelieveable but true. Edited September 3, 2014 by Aurela Quote Share this post Link to post Share on other sites
0 Jedzkie 58 Posted September 3, 2014 Not working AnnieRuru.define the word 'Not working' for me screenHercules022.jpg Oops, sorry.. my fault.. Quote Share this post Link to post Share on other sites
0 Garr 117 Posted September 3, 2014 Hmm, I remember that one. That's indeed a nice idea. But I'm at loss how to implement such a check for every char name used, unless going through all the chars for each message, and it'll kill the messaging. Btw, such trick also works for normal chat window if you leave it at default size, aka pretend you're getting PMs from GM. 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
0 Guest Aurela Posted September 3, 2014 (edited) I think the best solution would be to make a check (idk if that works) if someone writes "[GM]" and ":" in one sentence or just [GM] that the message don't gets send.There should be an option to set this word at the blacklist or not? And maybe in conjunction with the space limit script it would annoy that scammer dude and make him stop scamming. Best would be if we'd have that Blacklist + Space Limit + 2space+alt03232 Fix :/ Edited September 3, 2014 by Aurela Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 3, 2014 (edited) I got a very quick way of doing this src/map/clif.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..cbb080c 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,27 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( stristr( message, ":" ) || stristr( message, ";" ) ) {+ char* array_names[8] = { // change 8 into total number of elements from the array below+ "AnnieRuru", // change all these to all your GM staff names+ "EnnyRuru",+ "Aurela",+ "Lumina",+ "Evilpunker",+ "Frost",+ "Garr",+ "KinoRuru"+ };+ int i;+ for ( i = 0; i < 8; i++ ) { // change the 8 here too+ if ( stristr( message, array_names[i] ) ) {+ clif->colormes( fd, COLOR_RED, "You can't impersonate as a GM staff !" );+ return false;+ }+ }+ }+ return true; } create a blacklist and detects them when they input ":" or ";" plus any of the names mentioned in the array but this is not an ideal way of how to code it ... ima thinking of using the correct way on how Ind code his manner.c using an external file impersonate.txt along with @reloadimpersonate something like Ind did EDIT: on 2nd thought, maybe you guys can just use Ind's manner.c ... Edited September 3, 2014 by AnnieRuru 1 Jedzkie reacted to this Quote Share this post Link to post Share on other sites
0 Garr 117 Posted September 3, 2014 I always wondered, wouldn't it be easier to convert all types of spaces into normal space, and then replace all following each other spaces into one? That could also prevent such abuse, in theory. Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 3, 2014 before convert it, you have to list them I've tried on post#5 in this topic which has a max_3_space.c download it works on my test server, but said doesn't work on linux machine how about you try it ? is there any way to detect the word Alt+03232 without actually typing it ? maybe @KeyWorld can shred some light on this Quote Share this post Link to post Share on other sites
0 evilpuncker 504 Posted September 3, 2014 (edited) http://herc.ws/board/topic/3977-odin-server-side-manner/ this one have reg exp support =D Edited September 3, 2014 by evilpuncker Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted September 3, 2014 before convert it, you have to list them I've tried on post#5 in this topic which has a max_3_space.c download it works on my test server, but said doesn't work on linux machine how about you try it ? is there any way to detect the word Alt+03232 without actually typing it ? maybe @KeyWorld can shred some light on this AFAIK, Alt+03232 = Alt+160 so just stristr( message, "xA0" ) 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
Hello, c;
I need a limitation for spaces in chat.
For example:
Name : Hello my name is l l l l
You're only allowed to do max 3 spaces in a row.
If anyone would be able to help me out I'd be very happy.
Also, I will pay for this if needed.
Edited by AurelaShare this post
Link to post
Share on other sites