ID:269838
 
Ok, here is what i want, i want a time system, for example if i mute someone for 2 mins and they log out leaving 1 min behind. And when they log in back they still have to do that 1 min to mute left. Please and thanks you
this is [b] Developer how-to [/b] not [b] GIVE ME UR DARN CODE SO I MAK PWN GAMR [/b]
anyways try this
sleep(10)
usr.second + 1
if(usr.second == 60)
TAB> usr.minute += 1
TAB> usr.second = 0
TAB> if(usr.minute == 60)
TAB> >TAB> usr.hour += 1
TAB> >TAB> usr.minute = 0
mob/var/MuteTime=0  //Set a variable for the Mute time
var/list/Muted=list() //Make a list that has the muted people in it.

mob/proc/Mute_Check() //Make a proc to check the mute
/*Edited after Kalzars post*/
if(!MuteTime||Muted.Find(client.address)) //If they don't serve time or their IP is on the list...
return //...stop the proc
Muted+=client.address //If their IP isn't on the list, add them.
while(MuteTime>0) //Make a loop
sleep(10) //Sleep for 1 second
MuteTime-- //Subtract "1" from the player's MuteTime
if(!MuteTime) //An extra check to see if their MuteTime equals 0
Muted-=client.address //Remove their IP from the list.
world<<"[src] has been unmuted." //Debug message


I'll have you figure out the rest, and how to execute the proc. ;)
In response to Mega fart cannon
You should do it by key and IP.
In response to Rky_nick
Show code in DM tags:

<DM>
*code*
</DM>

And do html such as bold and italics using actual html.
In response to DeathAwaitsU
var
list
muted_keys = list()
muted_ips = list()
muted_timer = list()
proc
get_mute_id(mob/player/player_to_find)
if(player_to_find.client.key in muted_keys)
return muted_keys.Find(player_to_find.client.key,1,0)
else if(player_to_find.client.address in muted_ips)
return muted_ips.Find(player_to_find.client.address,1,0)
else
return 0 // not muted

remove_mute()
var/unmute_key = input("who do you want to unmute?","Select a key") in muted_keys+"Exit"
if(unmute_key != "Exit")
var/mute_id = muted_keys.Find(unmute_key,1,0)
muted_keys.Remove(muted_keys[mute_id])
muted_ips.Remove(muted_ips[mute_id])
muted_timer.Remove(muted_timer[mute_id])
src << "if this player is ingame please ask them to save and relog to remove the mute!"


add_mute(mob/player/player_to_be_muted)
var/player_key = player_to_be_muted.client.key
var/player_ip = player_to_be_muted.client.address
var/player_timer = input(src,"how long do you want [player_to_be_muted.name] to be muted for? - 0 = inf (never unmute)","Mute [player_to_be_muted.name]") as num
player_timer = round(player_timer,1)
player_to_be_muted.muted = 1
if(player_ip == null)
player_ip = md5(player_key)
if(player_key in muted_keys)
src << "this players key is allready in the mute list adding more to they muted time!"
var/mute_id = get_mute_id(player_to_be_muted)
if(muted_timer[mute_id] == 0)
src << "they have a inf mute!"
else
src << "adding to there mute!"
muted_timer[mute_id] += player_timer
player_to_be_muted << "[player_timer] more mins have been added to your mute!"
else
muted_keys.add(player_key)
muted_ips.add(player_ip)
muted_timer.add(player_timer)
if(player_timer > 0)
player_to_be_muted << "you have been muted for [player_timer]mins!"
else
player_to_be_muted << "you have been muted untill the you are removed from the muted list!"



mob
player
var
muted = 0
player_mute_id = 0 // finds them in the mute list (so there counter goes down)
proc
count_down_mute()
spawn(600)
[muted_timer[player_mute_id]]--
if([muted_timer[player_mute_id]] == 0)
muted = 0
muted_keys.Remove(muted_keys[player_mute_id])
muted_ips.Remove(muted_ips[player_mute_id])
muted_timer.Remove(muted_timer[player_mute_id])
player_mute_id = 0
else
spawn(1) count_down_mute()
Login()
..()
player_mute_id = get_mute_id(src)
if(player_mute_id != 0)
muted = 1
if(muted_timer[player_mute_id] == 0)
src << "you are muted!"
else
src << "you are muted for [muted_timer[player_mute_id]]mins!"
spawn(1) count_down_mute()

notes
on all say and wsay verbs ect add a check
if(!muted)
// say stuff here

you will also want to save and load these vars
muted_keys
muted_ips
muted_timer

this is unchecked and untested ^_^ have fun.
In response to Zmadpeter
I don't know but, your way just seems too extensive... It'd be much easier to use a single list utilizing the associative properties.

#define SECOND              10 //one second
#define MINUTE 600 //one minute
#define HOUR 36000 //one hour
var
Muted[0]

mob
verb
Mute(mob/M in world,Duration as num|null)
if(M)
if(M.client)
Muted[M.ckey]=world.realtime+(MINUTE*max(Duration,1))
Unmute()
for(var/M in Muted)
var/Duration=Muted[M]
if(world.realtime>=Duration)
Muted.Remove(M,null)
var/M=input(src,"Who do you wish to unmute?","Unmute") as null|anything in Muted
if((M in Muted))
Muted.Remove(M,null)
Say(txt as text|null)
if((src.ckey in Muted))
if(Muted[src.ckey]>world.realtime)
return
Muted.Remove(src.ckey,null)
world<<"[src.name]: [txt]"