ID:272294
 
How would you make a mute system that is timed, but it saves the time when the client logs out and resumes the time when he logs back in. I've tried making one but it didn't work so I gave up on it. Not sure how to make it work right.
You should save the world.realtime they can be unmuted (if you want to mute them for 1 hour, that's world.realtime + 36000 ticks), then check every so often to see if the current world.realtime is larger than that, and if so unmute them. Check when they login after their savefile is loaded, to see if the time passed while they were offline. Then simply give them a variable to store the unmute time, which should be saved with your mob, however you handle saving.
In response to Xooxer
I've tried the world.realtime, but it was glitched up logging in lol, thats why I wanted some sort of savefile to save them all.
In response to Yash 69
Something like this?

var/list/muted // list hold all muted ckeys and the time they are unmuted

world
New()
..()
var/savefile/S = new("./muted.sav") // load the muted list
S >> muted

spawn()
CheckMute() // start the check loop

Del()
var/savefile/S = new("./muted.sav") // save the muted list
S << muted
..()


proc
CheckMute()
for(var/m in muted)
if(muted[m] < world.realtime)
muted -= m
for(var/mob/M in world)
if(M.ckey == m)
M.mute = 0
M << "You are no longer mute."
spawn(3000)
CheckMute() // check once every 5 minutes

mob
var/mute


Login()
..()
if(mute && !(ckey in mute)) // if they are set to mute, but not in the mute list
mute = 0
src << "You are no longer mute."


verb
Mute(mob/M as mob in world) // admin verb
if(!M || !M.client) return
M.mute = 1
if(!muted) muted = new
muted[M.ckey] = world.realtime+36000 // one hour
M << "You are mute!"

Say(msg as text|null)
if(mute) return
world << "[M.cname]: [msg]"
In response to Xooxer
Yeah, lol thanks for the help, but i'll add a custom time lol if you don't mind :)