ID:146601
 
Code:
mob/verb/say(msg as text)
//set src in view(1)
usr << "[usr] says: [msg]"
var/tmp/my_count = 10
my_count++
for(var/M in cuwords)
if(findtext(msg,M))
usr << ""
usr << "You just cussed. Don't do it again."
count++
if(count == 5)
usr << "You are trying to cuss way to much. Auto-muted"
usr.verbs -= new /mob/verb/say()
sleep(500)
usr.verbs += new /mob/verb/say()
while(my_count >= world.time)
usr << "You are talking way to much and are spamming."
usr.verbs -= new /mob/verb/say()
sleep(500)
usr.verbs += new /mob/verb/say()
my_count = 1


Problem description:Yea now the problem here is that every time you say something, the var/my_count is supposed to go up, and if it goes up to the point that the var/my_count is greater then the worlds time, then the person is muted for spamming. It refuses to work. Please help. By the way, this is my first time trying to construct a spam protection, disregard the for loop, that works, it's the while you have to worry about.
Muted for attempting to cuss more than 5 times. Stupid.

You need to set the variable as a client or mob variable.

mob/var/tmp/my_count = 10
mob/verb/say(txt as text)
src.my_count++
// get the idea?


Many other problems to deal with but that's all I'm going to talk about, I have to go...

-Ryan
In response to Ryne Rekab
Actually, it still refuses to work the way I want it too. What I want is if somebody says something within this amount of time, then mute, not if they say this "this" many times, then mute.
First of all, you shouldn't be defining my_count within the scope of the proc. It should belong to the mob. Also, "my_count" isn't a good variable name. The name of a variable or proc should be a comment in itself: you should know its function by its name.

Second, when adding and subtracting verbs from atom.verbs, you don't need to initialize the verb. For example, the following would be correct:

usr.verbs += /mob/verb/say()


Third, my_count never goes down. It needs to.

Finally, world.time is probably a bad meausre to use in this fashion. Once the game has been running for a while, my_countwill never go higher than world.time, but when the world first starts up, it won't take much for even the quietest player to get muted.

It would probably make more sense to save world.time, and then, using the saved value, check how long it's been since the player last spoke.

Lummox JR has a BYONDscape article on spam protection that I suggest reading.
In response to Wizkidd0123
Ehehe thanks wizkid, your advice is pretty blunt but it does come in handy eheh. Actually I managed to fix this one myself.
In response to Wizkidd0123
Ehh, I don't know how to save the world.time .. so help me out with that one then. You have good advice, now help me apply it.
In response to DragonMasterGod
DragonMasterGod wrote:
Ehh, I don't know how to save the world.time .. so help me out with that one then. You have good advice, now help me apply it.

mob/var/last_speech_time = 0


Then, within the verb

src.last_speed_time = world.time

In response to Wizkidd0123
Ok, thats kinda like the same exact thing I did with the var worldstime, but thanks. I guess the whole var with a comment within itself changed it up a bit to work better for me.