ID:158909
 
I have this Mute verb that i made but im not sure on how to add Timing. Like say i wanted to mute them for a max of 300 minutes and minimum of 1. How would i make such a verb? Also so if they Relog the Mute is still active

mob/GH
verb
Mute(mob/M in world, Reason as text)
set category = "Admin"
set desc = "Reason"
if(M.client)
Muted = 1
world<<"<font color = #FFFC17>Announcement: </font color>[M] has been Muted by [src] for [Reason]"
else
usr<<"You cant mute him Dumass"
im sure this demo will be helpfull, if you know what your doing it should be easy enough to implement it into your mute verb.

http://www.byond.com/developer/ACWraith/Timer

in this he has start timer, pause , unpause and clear for that matter.

start timer shows how you can start the time on your mute verb. pause and unpause shows how you can make it so that when they log off and in again after a while, still are muted.

using pause where its apropriate for the logout and unpause on login.

if needed i guess you could set clear timer to run when the mute is finished.
There are a couple of methods you can use to go about this, with varying results. Basically, you need to keep either the time the player still has to wait to become unmuted, or the time (timestamp) when the player should become unmuted. And for it to be kept across relogs, save it, and when loading/logging in, check it and start the timer again if needed.
Here's a short illustration of the 2 methods mentioned above:
//keeping time until unmute:
client
var/mute_waiting_time
verb
Say(msg as text)
if(src.mute_waiting_time)
src << "You need to wait [src.mute_waiting_time] before you may speak."
else world << "[src]: [msg]"
proc
Mute(reason,admin,minutes,bla)
src << "You're muted for [reason] by [admin] for [minutes] minutes."
src.mute_waiting_time = minutes
src.MuteTimer()
MuteTimer()
spawn(-1) //run immediately, but don't delay callers
while(src.mute_waiting_time)
sleep(600) //wait a minute (literally =P)
src.mute_waiting_time-- //subtract 1 from the time every iteration

//keeping timestamp to be unmuted at:
client
var/unmuted_time//stamp
verb
Say(msg as text)
if(src.unmuted_time)
src << "You need to wait [(src.mute_waiting_time-world.realtime)*10] seconds before you may speak."
else world << "[src]: [msg]"
proc
Mute(reason,admin,minutes,bla)
src << "You're muted for [reason] by [admin] for [minutes] minutes."
var/mute_ticks = minutes*60*10 //converts mins to ticks (with default world.tick_lag)
src.unmute_time = world.realtime+mute_ticks
src.MuteTimer()
MuteTimer()
spawn(-1) //run immediately, but don't delay callers
while(src.unmute_time > world.realtime)
sleep(600) //wait a minute (literally =P)
src.unmute_time = null //unmuted

Again, to make it persist across relogins, you'd just save & load the mute-var, and after a player relogins, if his var indicates he still has muting time left, restart the mute timer.