ID:266531
 
For my game,I want a Spam Protecter code to stop people from spamming.If you know how to do this,please tell me!Thanks!

-Kappa the Imp
Here is a way.

mob/verb/Say()
if(src.nosay==1)
return
else
var/T=input("") as null|text
if(length(T)>=300) return
else
world<<"[src]: [html_encode(T)]"
src.nosay=1
sleep(20)
src.nosay=0
mob/var/nosay=0

Test it out by setting a macro to say and hold for 5 seconds and see how many text boxs pop up:)
There are a couple different ways to do this. Here are a few steps I'd recommend to prevent spamming, though I hear there's an article on BYONDscape, if you're subscribed, that talks more about securing your game from this type of problem.

1. Make sure all html is disabled in your game by using html_encode() on all user-defined messages. Look the proc up in the reference if you need to know more. This prevents spammers from using large fonts and other annoying html features.

2. Make a limit to the length of text that someone can write. I recommend just trimming the end off after around 300-500 characters, since there is no built in character limit when inputting text. Use copytext() to trim the text off. Alternatively, you could simply deny any messages that are past a certain length(), but that can be annoying to players.

3. To prevent people from writing the same thing over, you might try giving each player a "last_message" variable, and whenever a player says or shouts something, the message gets copied to their last message variable. If what they say or shout is equal to their last message, make another variable called "warning", and add one to that. Then once the "warning" variable reaches a certain point, boot them. Example:

mob/var
last_message = ""
warning = 0

mob/verb/Say(msg as text)
if(msg == last_message)
warning++
if(WarningCheck()) // if check returns positive
del(src)
last_message = msg
world << "[usr]: [msg]"

mob/proc/WarningCheck()
if(warning >= 5) return 1 // return positive
else return 0 // return negative
That will cause their character to be deleted after they repeat the same message 5 times.
Kappa the Imp wrote:
For my game,I want a Spam Protecter code to stop people from spamming.If you know how to do this,please tell me!Thanks!

My most recent Dream Tutor column in BYONDscape shows how to build an anti-spam system from the ground up, and includes lots of working code--including a language filter, shouting protection, and a few other goodies.

Lummox JR
In response to Super16
Darkness made a nice spam protecter, go to Search and look it up!
- RaeKwon