Add Option to mute all players if you are dead #1178

Merged
merged 1 commit into from May 25, 2016

Projects

None yet

7 participants

@markusmarkusz
Contributor

At the moment you have the ability to mute all spectators or all players who are alive when you are a spectator.
But sometimes i think anyone had the moment where you dont't want to hear the spectators and the players who are alive.
This will add an option to mute all players when you are dead.

(I hope you understand this really bad english.)

@robotboy655 robotboy655 added the TTT label May 16, 2016
@Kefta
Contributor
Kefta commented May 16, 2016

Spanish: Cada enmudecido

Also, change the english string to All Muted to be consistent with the other strings.

@Kefta
Contributor
Kefta commented May 16, 2016
@comedinha
Contributor

Portuguese: "Todos mutados"

@comedinha comedinha and 1 other commented on an outdated diff May 16, 2016
garrysmod/gamemodes/terrortown/gamemode/lang/spanish.lua
@@ -614,6 +614,7 @@ L.radar_hud = "El radar estará listo en: {time}"
-- Spectator muting of living/dead
L.mute_living = "Jugadores vivos enmudecidos"
L.mute_specs = "Espectadores enmudecidos"
+L.mute-all = “Cada enmudecido“
@comedinha
comedinha May 16, 2016 Contributor

The "" is correct?

@markusmarkusz
markusmarkusz May 16, 2016 Contributor

I'll correct it tomorrow.

@markusmarkusz
Contributor

I'm going to add the Portuguese translation later/tomorrow. Either the false characters will be corrected later/tomorrow.

@markusmarkusz
Contributor

Added Portuguese translation and fixed the characters in the spanish translation.

@svdm svdm commented on an outdated diff May 17, 2016
garrysmod/gamemodes/terrortown/gamemode/gamemsg.lua
@@ -189,6 +189,10 @@ function GM:PlayerCanHearPlayersVoice(listener, speaker)
if listener:IsSpec() and listener.mute_team == speaker:Team() then
return false, false
end
+
+ if listener:IsSpec() and listener.mute_team == 4 then
@svdm
svdm May 17, 2016 Collaborator

This would be more clear if it was listener.mute_team == MUTE_ALL. You can move the MUTE_* constants defined in cl_voice.lua to shared.lua, so that they can be used here.

Same for the 0, 4, 5 used below.

@markusmarkusz
Contributor

I'll fix the shared.lua later. I want to change something other too and then i'll fix the shared.lua

@markusmarkusz
Contributor
markusmarkusz commented May 17, 2016 edited

Now it should work fine. I didn't find any bugs now.

@bmwalters
Contributor
bmwalters commented May 17, 2016 edited

You should probably squash this into one commit

@bigdogmat bigdogmat and 1 other commented on an outdated diff May 17, 2016
garrysmod/gamemodes/terrortown/gamemode/gamemsg.lua
@@ -245,9 +249,13 @@ local function MuteTeam(ply, cmd, args)
local t = tonumber(args[1])
ply.mute_team = t
-
- local name = (t != 0) and team.GetName(t) or "None"
- ply:ChatPrint(name .. " muted.")
+ if t != MUTE_NONE and t != MUTE_ALL then
+ ply:ChatPrint(team.GetName(t) .. " muted.")
+ elseif t == MUTE_ALL then
+ ply:ChatPrint("All muted.")
+ else
+ ply:ChatPrint("None muted.")
+ end
@bigdogmat
bigdogmat May 17, 2016 edited

This needs indentation. Also couldn't team id <-> mute enum collision happen? I don't know what the team ids are in ttt so I don't know.

Also I think it'd look better like this

if t == MUTE_ALL then
   ply:ChatPrint("All muted.")
elseif t == MUTE_NONE then
   ply:ChatPrint("None muted.")
else
   ply:ChatPrint(team.GetName(t) .. " muted.")
end

More implicit as to what it's doing

@markusmarkusz
markusmarkusz May 18, 2016 Contributor

The team ids in ttt are:
TEAM_TERROR = 1
TEAM_SPECTATOR = 1002
TEAM_COMNECTING = 0
TEAM_UNASSIGNED = 1001

So i think 2 should work.
And yeah your code is a little bit better.
I'll add it later.

@markusmarkusz
Contributor

I will squash them later.
I will do that if everyone is in agreement that everything fits now. Otherwise I have to do it with each change.

@markusmarkusz markusmarkusz and 1 other commented on an outdated diff May 18, 2016
garrysmod/gamemodes/terrortown/gamemode/gamemsg.lua
@@ -245,9 +249,13 @@ local function MuteTeam(ply, cmd, args)
local t = tonumber(args[1])
ply.mute_team = t
-
- local name = (t != 0) and team.GetName(t) or "None"
- ply:ChatPrint(name .. " muted.")
+ if t == MUTE_ALL then
+ ply:ChatPrint("All muted.")
+ elseif t == MUTE_NONE or t == TEAM_UNASSIGNED then
@markusmarkusz
markusmarkusz May 18, 2016 edited Contributor

Is there any way to specify that only this numbers can be used?
For example if you use "ttt_mute_team 60" you will get printed " muted.".
This would work:

if t != MUTE_ALL and t != MUTE_NONE and t != TEAM_UNASSIGNED and t != MUTE_TERROR and t != MUTE_SPEC then
ply.mute_team = -1
ply:ChatPrint("None muted.")
else

But is there anything that look better?

@bigdogmat
bigdogmat May 18, 2016 edited

http://wiki.garrysmod.com/page/team/Valid

Also you still need to indent this

Also, why are you checking TEAM_UNASSIGNED?

@markusmarkusz
markusmarkusz May 18, 2016 edited Contributor

Because if I use ttt_mute_team TEAM_UNASSIGNED the output would be Unassigned muted..
But in TTT TEAM_UNASSIGNED won't be used.

@bigdogmat
bigdogmat May 18, 2016

Afaik TEAM_UNASSIGNED is given to players who haven't been given a team yet. Even though you shouldn't ever have to mute TEAM_UNASSIGNED I don't see why group it with MUTE_NONE.

@markusmarkusz
markusmarkusz May 18, 2016 Contributor

Then I can also omit the query to check if a valid team is given.

@markusmarkusz
Contributor

@bigdogmat I'll add it. If anyone other is agreeing with you, I'll remove it and leave MUTE_NONE there.
I'll squash all commits together if everything works fine and if this will be merged.
Otherwise it would be useless work.

@bigdogmat bigdogmat and 1 other commented on an outdated diff May 18, 2016
garrysmod/gamemodes/terrortown/gamemode/gamemsg.lua
@@ -251,7 +247,7 @@ local function MuteTeam(ply, cmd, args)
ply.mute_team = t
if t == MUTE_ALL then
ply:ChatPrint("All muted.")
- elseif t == MUTE_NONE or t == TEAM_UNASSIGNED then
+ elseif t == MUTE_NONE or t == TEAM_UNASSIGNED or not (team.Valid(t)) then
@bigdogmat
bigdogmat May 18, 2016

Why wrap the team.Valid check in parentheses?

@markusmarkusz
markusmarkusz May 18, 2016 Contributor

Was a mistake ^^.

@bigdogmat bigdogmat commented on an outdated diff May 18, 2016
garrysmod/gamemodes/terrortown/gamemode/gamemsg.lua
@@ -247,7 +247,7 @@ local function MuteTeam(ply, cmd, args)
ply.mute_team = t
if t == MUTE_ALL then
ply:ChatPrint("All muted.")
- elseif t == MUTE_NONE or t == TEAM_UNASSIGNED or not (team.Valid(t)) then
+ elseif t == MUTE_NONE or t == TEAM_UNASSIGNED or not team.Valid(t) then
ply:ChatPrint("None muted.")
else
ply:ChatPrint(team.GetName(t) .. " muted.")
@bigdogmat
bigdogmat May 18, 2016

This whole if block needs indenting. Pretty sure ttt uses 3 space

@markusmarkusz
Contributor

So I squashed all commits together, I'd added intends and i think it has no bugs.
Will this future get added?

@svdm svdm merged commit c503672 into garrynewman:master May 25, 2016
@markusmarkusz markusmarkusz deleted the unknown repository branch Jul 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment