Jump to content

Looking for a way to turn off a button in case of spam


DylanD
 Share

Recommended Posts

Hello everyone, 

I was wondering if you could help me figure out a way to turn a button of for say 3 seconds that way if someone tried spamming(very quick repeated clicking) my button it would only hit one time/time them out.

Here is my attempt, I use the boolean as a switch, when the button is hit it check if the switch is on if it is I does the button stuff then it turns the switch to false and then wait 300 ms then turns the switch back on, except in the example the switch doesn't turn back on for some reason and when I try to do this if I click fast enough I sometimes get and extra click or two, any ideas?

 

 

So I had a variable in the wrong place in my code and it works now... but it still doesn't work in the playground so not sure why, so I guess solved? I don't know.

Should work in the playground... 

Edited by DylanD
It works?
Link to comment
Share on other sites

1 minute ago, Pryme8 said:

add a flag that turns 'off' the button and on your callback skip the buttons behavior if the flag is there.  Then set a timeout that resets the flag after a set time so that the callback behavior turns back on.

this is what I have.  at least I think, it doesn't work in the playground but does in my code 😛

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...