chat flood protection?

Posted by aridale
Ive added a (very) simple custom handling of new chat msgs using the gms_script_set_chat_receive function. All it does is accept the 3 required variables and then print a debug message showing the received info.

It works exactly as you would expect it to but if I spam a simple msg over and over after 4-5 times it crashes every connected client with:

gml_Script_handle_new_chat (line 10)
called from - gml_Script_gms_step (line 167) - script_execute(global.__script_chat_recv, gms_action_get_sender(), gms_action_get_argument_string(1), gms_action_get_argument_real(0)); called from - gml_Object_GMS_StepNormalEvent_1 (line 1) - gms_step()

handle_new_chat is my script

Replies (10)

Last message on 10 Mar 2019

aridale (Topicstarter) on 8 Mar 2019, 21:19:32
I tried this again last night, a few times infact, and had 0 crashes with no changes from my preview code. So maybe it was some kind of weird hiccup somewhere in the connections. I'll definitely keep an eye out for it in the future though.

I like the idea jdev said about using an alarm to only be able to send a msg every second or so. That could be an easy to implement way to avoid this whole issue in the future! Thanks guys!
Size43 (Administrator) on 6 Mar 2019, 15:53:40
You might be running into the automatic mutes for users that spam the same message multiple times.

You should use P2P messages for frequent messages that are not sent by users themselves.
aridale (Topicstarter) on 6 Mar 2019, 21:21:39
well its not something that needs to be p2p messages its just I was intentionally spamming the same msg over and over again in chat. The issue is it crashed every connected client not just the one spamming. How would you handle that?
Size43 (Administrator) on 10 Mar 2019, 19:19:50
I'm guessing here that the issue is that 'p' won't contain a valid player ID if the mute-message is sent by the server (which doesn't have a player ID).

If that's not the case, please show the actual error message that you're getting.
jdev on 7 Mar 2019, 16:45:30
The client may crash due to the amount of spam you are sending, so p2p messages would be more efficient in this case, but why would you intentionally want to spam chat?
aridale (Topicstarter) on 7 Mar 2019, 21:28:32
to see what happens lol. You know how players are! One troll is all it takes to ruin a small game for everyone... if a troll spamming the same short msg over and over and crash every connected client why even bother having a chat system?

So instead of asking me _why_ would you want to test for spamming the chat in an online game, why not help me figure out _how_ to avoid the inevitable spam from crashing my clients.

I mean does this not seem like a major flaw in this plugin, that anyone can crash everyone connected just by spamming the chat? It could have been a fluke... but it happened repeatedly every single time I got to the 4th or 5th msg the other night. And its definitely not my simple code cause the crash occurs in one of GMS' scripts.

Like I said maybe its a fluke... maybe it was some slight hiccup in the server but it was happening and it was completely repeatable on my end. What it was I have no idea, but Id still like to know how to avoid it in my games if possible
jdev on 6 Mar 2019, 09:23:52

Can you show me the script you have made please?
aridale (Topicstarter) on 6 Mar 2019, 21:41:04
//set in GMS object to handle incoming chat messages

var p,m,c,sX,sY;
p = argument0
m = argument1
c = argument2

show_debug_message(gms_other_get(p,"charName")+" says: '"+m+"'")
jdev on 8 Mar 2019, 20:50:24
Try making an alarm so you can only send a message once every few seconds or so, and try changing your show_debug_message line to the following:

show_debug_message(string(gms_other_get(p,"charName"))+" says: '"+string(m))
jdev on 8 Mar 2019, 20:53:27
Update, you seemed to have some unnecessary colons causing the issue, try updating your code to the following perhaps:

show_debug_message(string(gms_other_get(p,"charName"))+" says: "+string(m));