Mic mutting

I have a script to mute TEAM_PRISONER at the first 30 seconds of the round, but it causes errors and fails to work.



	function JB:RoundStart()
		BroadcastLua([[for k,v in pairs(team.GetPlayers(TEAM_PRISONER)) do
			v:SetMuted(true) 
		end]])
		BroadcastLua([[timer.Simple(30, function() 
			for k,v in pairs(team.GetPlayers(TEAM_PRISONER)) do
				v:SetMuted(false)
			end
		end)]])
		for k,v in pairs(player.GetAll())do
			v:PrintMessage(HUD_PRINTCENTER, "All prisoners have been muted for 30 seconds.")
		end


Also is there a way I can mute dead people until they are respawned?
TEAM_GUARD_DEAD
TEAM_PRISONER_DEAD

You haven’t shown any errors.

Sorry… I will get them and the code is meant to look like this when being used but its commented at the moment so it doesn’t give errors:



	function JB:RoundStart()
		BroadcastLua(for k,v in pairs(team.GetPlayers(TEAM_PRISONER)) do
			v:SetMuted(true) 
		end)
		BroadcastLua(timer.Simple(30, function() 
			for k,v in pairs(team.GetPlayers(TEAM_PRISONER)) do
				v:SetMuted(false)
			end
		end))
		for k,v in pairs(player.GetAll())do
			v:PrintMessage(HUD_PRINTCENTER, "All prisoners have been muted for 30 seconds.")
		end


Just hook PlayerCanHearPlayersVoice.



[ERROR] gamemodes/jailbreak/gamemode/core/sv_player_hooks.lua:76: attempt to call method 'SetMuted' (a nil value)
    1. unknown - gamemodes/jailbreak/gamemode/core/sv_player_hooks.lua:76
	
[ERROR] gamemodes/jailbreak/gamemode/core/sv_player_hooks.lua:76: attempt to call method 'SetMuted' (a nil value)
    1. unknown - gamemodes/jailbreak/gamemode/core/sv_player_hooks.lua:76