local A1 = 0 local A = 0 local B = 0 PlayerTable1 = {} util.AddNetworkString("munspeakchannel") util.AddNetworkString("munspeakmute") util.AddNetworkString("munspeakunmute") MsgAll("UPDATED SCRIPT") function MunSpeak.CreateChannel(ply,msg) local Message = string.Explode(" ",msg) if(Message[1]=="/channel") then ply:PrintMessage(HUD_PRINTTALK,"You left the "..ply.Channel.." Channel") ply.Channel = Message[2] for _,sub in pairs(player.GetAll()) do if(sub.Channel != ply.Channel) then net.Start("munspeakmute") net.WriteEntity(sub) net.Send(ply) else net.Start("munspeakunmute") net.WriteEntity(sub) net.Send(ply) end end ply:PrintMessage(HUD_PRINTTALK,"Please allow up to "..(table.Count(player.GetAll())*0.2).." seconds for channel to kick in.") ply:PrintMessage(HUD_PRINTCENTER,"Please allow up to "..(table.Count(player.GetAll())*0.2).." seconds for channel to kick in.") for k,v in pairs(player.GetAll()) do if(v.Channel == ply.Channel) then v:PrintMessage(HUD_PRINTTALK,ply:Nick().." has joined the channel") end end return "" end if(Message[1]=="/leave") then ply.Channel = "Default" for _,sub in pairs(player.GetAll()) do if(sub.Channel != ply.Channel) then net.Start("munspeakmute") net.WriteEntity(sub) net.Send(ply) else net.Start("munspeakunmute") net.WriteEntity(sub) net.Send(ply) end end end if(Message[1]=="/channels") then for k,v in pairs(player.GetAll()) do PrintMessage(HUD_PRINTTALK,v:Nick().." is in channel "..(v.Channel)) end end end hook.Add("PlayerSay", "munspeakcreate", MunSpeak.CreateChannel) function MunSpeak.PlayerHasConnected(ply) ply.Channel = "Default" end hook.Add("PlayerSpawn","MunTalkPlayerHasConnected",MunSpeak.PlayerHasConnected) function MunTalkTempFunction() PrintMessage(HUD_PRINTTALK,"Updating Player List") A = 0 A1 = 0 PlayerTable1 = {} for k,v in pairs (player.GetAll()) do A1 = A1 + 1 table.insert(PlayerTable1,v) A=A+1 end end timer.Create("MunTalkGetPlayers",10,0,MunTalkTempFunction) timer.Create("MunTalkTick",0.2,0,function() B=B+1 if(B > A) then B = 0 end if(not PlayerTable1[B]) then B = 0 return end B = tonumber(B) if(IsValid(PlayerTable1[B])) then -- if(not IsValid(PlayerTable1[B].Channel)) then PlayerTable1[B].Channel = "Default" end for _,sub in pairs(player.GetAll()) do if(sub.Channel != PlayerTable1[B].Channel) then net.Start("munspeakmute") net.WriteEntity(sub) net.Send(PlayerTable1[B]) else net.Start("munspeakunmute") net.WriteEntity(sub) net.Send(PlayerTable1[B]) end end end end)