ID:777007
 
(See the best response by Keeth.)
Code:
    ooc(t as text)
set name="OOC"
set category="Communicate"
if(usr.muted)
usr<<"<b><font color=red>WARNING WARNING:</font><font color=white> You Are Muted</font></b>"
return 0
overlays += 'Talk.dmi'
world<<"<font color=gold><b>[src]</b> Says</font><font color=silver>:</font><font color=gold> [t]</font>"
overlays -= 'Talk.dmi'


Problem description: I want to make a spawn delay for the people wont spam i would like a example or atleast a locater of when the users are really actually speaking instead of [usr] says: [ space ]

This Should Work
    ooc(t as text)
mob/var/Delay=0
set name="OOC"
set category="Communicate"
if(usr.Delay)
usr<<"Please Wait 5 Seconds Before You Chat Again"
spawn(50)
usr.Delay=0
return
if(usr.muted)
usr<<"<b><font color=red>WARNING WARNING:</font><font color=white> You Are Muted</font></b>"
return 0
overlays += 'Talk.dmi'
world<<"<font color=gold><b>[src]</b> Says</font><font color=silver>:</font><font color=gold> [t]</font>"
overlays -= 'Talk.dmi'
usr.Delay=1
spawn(50)
usr.Delay=0
Works thanks
No Problem
In response to The Motto
Best response
The Motto wrote:
This Should Work
>     ooc(t as text)
> mob/var/Delay=0
> set name="OOC"
> set category="Communicate"
> if(usr.Delay)
> usr<<"Please Wait 5 Seconds Before You Chat Again"
> spawn(50)
> usr.Delay=0
> return
> if(usr.muted)
> usr<<"<b><font color=red>WARNING WARNING:</font><font color=white> You Are Muted</font></b>"
> return 0
> overlays += 'Talk.dmi'
> world<<"<font color=gold><b>[src]</b> Says</font><font color=silver>:</font><font color=gold> [t]</font>"
> overlays -= 'Talk.dmi'
> usr.Delay=1
> spawn(50)
> usr.Delay=0
>


Not only does this not work, even if you did happen to format the code properly, all it would do is stop you from spamming for a time... that is, until they realize that every time you try to speak while you are being delayed, it spawns a thread that waits 5 seconds and then sets your delay to 0. Upon which they can just start spamming a button that uses the OOC verb, and expect that the threads they spawned 5 seconds ago will all set your delay to 0 right after your delay is set to 1 now.

So ultimately it will stop you from spamming for a 5 second period, and then you can spam to your heart's content.

I'd probably just suggest using a timestamp, probably based on world.time, to indicate the last time we spoke publicly. Probably base it on the client instead of the mob. Then, if enough ticks have passed, let them speak using the OOC channel again. You can do it on the mob if you'd like, but I don't personally see the significance of it. Clients are the ones doing the talking, not mobs. And it's not particularly important for the mob to know when we last spoke.

var
const
publicMessageTickInterval = 10 // 10 ticks between messages

client
var
lastPublicMessage = 0 // timestamp based on world.time!

proc
getTicksSinceLastPublicMessage()
return world.time - lastPublicMessage

getTicksUntilNextPublicMessage()
return publicMessageTickInterval - getTicksSinceLastPublicMessage()

canSpeakInPublic()
return getTicksUntilNextPublicMessage() < 1 // are there any ticks left until we can speak again?


Implementing something like this should be relatively easy.
In response to Keeth
You Cannot Spam To Your Hearts Content Because every time the verb is called the Delay var is being called, SO u sud really read every line of the code before you try to criticize someone.
In response to The Motto
The Motto wrote:
You Cannot Spam To Your Hearts Content Because every time the verb is called the Delay var is being called, SO u sud really read every line of the code before you try to criticize someone.

Not only did I read it, I ran it. I made a macro to use the OOC channel, and I spammed it. And the results turned out exactly as I just described earlier.

Every single time someone uses the OOC verb in your example, if delayed is non-null, it gives you a message telling you to wait 5 seconds and spawns another thread. If I called OOC 1 million times in that 5 second period, I'd have 1 million threads waiting to execute 5 seconds from when I originally used the verb.

I'll do a little play by play for you.

/**
Tick 1: call OOC successfully
Tick 1: spawn thread A to execute in 50 ticks to set delay to 0
Tick 2: call OOC, but get rejected
Tick 2: spawn thread B to execute in 50 ticks to set delay to 0
...
Tick 51: thread A: set Delay to 0
Tick 51: call OOC successflly
Tick 51: spawn thread C to execute in 50 ticks to set delay to 0
Tick 52: thread B: set Delay to 0
Tick 52: call OOC successfully
Tick 52: spawn thread D to execute in 50 ticks to set delay to 0
...
**/


And so on.
Dude, It works idk what you did to It but i helped the person who needed help and i know it works so, you can go some where?
In response to The Motto
The Motto wrote:
Dude, It works idk what you did to It but i helped the person who needed help and i know it works so, you can go some where?

"It works, so it must be right!"
In response to The Motto
The Motto wrote:
Dude, It works idk what you did to It but i helped the person who needed help and i know it works so, you can go some where?

He didn't do anything to it other than correct your indentation errors. When Keeth bothers to post on the forums, he more often than not knows what he is talking about. He is explaining to you why your code is flawed, and even gave a much better example explaining what you (and the OP) should do instead. It would be advisable to listen to him.
In response to Keeth
Keeth wrote:
The Motto wrote:
This Should Work
> >     ooc(t as text)
> > mob/var/Delay=0
> > set name="OOC"
> > set category="Communicate"
> > if(usr.Delay)
> > usr<<"Please Wait 5 Seconds Before You Chat Again"
> > spawn(50)
> > usr.Delay=0
> > return
> > if(usr.muted)
> > usr<<"<b><font color=red>WARNING WARNING:</font><font color=white> You Are Muted</font></b>"
> > return 0
> > overlays += 'Talk.dmi'
> > world<<"<font color=gold><b>[src]</b> Says</font><font color=silver>:</font><font color=gold> [t]</font>"
> > overlays -= 'Talk.dmi'
> > usr.Delay=1
> > spawn(50)
> > usr.Delay=0
> >

Not only does this not work, even if you did happen to format the code properly, all it would do is stop you from spamming for a time... that is, until they realize that every time you try to speak while you are being delayed, it spawns a thread that waits 5 seconds and then sets your delay to 0. Upon which they can just start spamming a button that uses the OOC verb, and expect that the threads they spawned 5 seconds ago will all set your delay to 0 right after your delay is set to 1 now.

So ultimately it will stop you from spamming for a 5 second period, and then you can spam to your heart's content.

I'd probably just suggest using a timestamp, probably based on world.time, to indicate the last time we spoke publicly. Probably base it on the client instead of the mob. Then, if enough ticks have passed, let them speak using the OOC channel again. You can do it on the mob if you'd like, but I don't personally see the significance of it. Clients are the ones doing the talking, not mobs. And it's not particularly important for the mob to know when we last spoke.

> var
> const
> publicMessageTickInterval = 10 // 10 ticks between messages
>
> client
> var
> lastPublicMessage = 0 // timestamp based on world.time!
>
> proc
> getTicksSinceLastPublicMessage()
> return world.time - lastPublicMessage
>
> getTicksUntilNextPublicMessage()
> return publicMessageTickInterval - getTicksSinceLastPublicMessage()
>
> canSpeakInPublic()
> return getTicksUntilNextPublicMessage() < 1 // are there any ticks left until we can speak again?
>

Implementing something like this should be relatively easy.


i dont get what you said keeth can you make it more simple like in a example

In response to Dr.Penguin
Dr.Penguin wrote:
i dont get what you said keeth can you make it more simple like in a example

He gave an example. He also went into detail about The Motto's response in his last reply.