Adding a Chat spam counter?

I would like it to wait 3 seconds before you can enter another chat message, but I am not very skilled with javascript and was wondering if I can have someone do this. This is a very big exploit cause if you spam chat it’ll crash the server, any server your on. Thank you.

Guessing it’d be something with this code

send(e) {
      if(this.message !== '') {
        post('http://chat/chatResult', JSON.stringify({
          message: this.message,
        }));
        this.oldMessages.unshift(this.message);
        this.oldMessagesIndex = -1;
        this.hideInput();
      } else {
        this.hideInput(true);
      }
    },

then maybe a warn message added when the timer isn’t all the way up

Just prevent the input box from showing, so things you would need todo:

  1. Keep track of the cooldown (via a boolean value)
  2. Prevent input from showing when enter is pressed (i.e if not onCooldown then)
  3. Set the timeout when user enters an input ( use setTimeout: https://www.w3schools.com/jsref/met_win_settimeout.asp)
    (Use this to reset the cooldown value/state)
  4. Send warning message if on cooldown.

Those are the main steps you need to perform, the task for you is to figure out how todo this and putting the puzzle together.

Google before asking any questions, if you do have question you can ask! :slight_smile:

I know the steps I have to take to accomplish this, I just don’t have long enough legs to reach each step and asking for a gentle boost.

Then I can’t be of any service, I expected you to be willing to put in some efford.

https://forum.cfx.re/u/Syntasu/activity

you basically just reword people’s issues dude, i’m asking for help. how am I suppose to put effort in when I have no idea where to start with this?.

Not really, im willing to help people who are actually trying to develop something and not piggyback off of someone.
My first step is litterally something you can directly translate to a piece of code, making a variable called cooldown.

cooldown = false

if cooldown then
	sendmessage()
	cooldown = true
else
	doTimer()
	cooldown = false
end
count = 1
max = 3
function doTimer()

while count == 1 do
	count = count + 1
	if count == max then
		count = count
	end
end

What I am stuck at is the function SendMessage()

but what I don’t know how to do is call the message in the middle of all that.

Does anyone know how to make the /textchat script to stop text chat?