diff --git a/gamemodes/terrortown/gamemode/server/sv_roleselection.lua b/gamemodes/terrortown/gamemode/server/sv_roleselection.lua index 57472dd5fc..a2e034fd7d 100644 --- a/gamemodes/terrortown/gamemode/server/sv_roleselection.lua +++ b/gamemodes/terrortown/gamemode/server/sv_roleselection.lua @@ -652,26 +652,26 @@ local function SetSubRoles(plys, availableRoles, selectableRoles, selectedForced roleCount = roleCount - selectedForcedRoles[subrole] end - local minKarmaCVar = GetConVar("ttt_" .. roleData.name .. "_karma_min") - local minKarma = minKarmaCVar and minKarmaCVar:GetInt() or 0 - - local giveIfWanted = not ply:GetAvoidRole(subrole) -- if the player wants the role - and ply:GetBaseKarma() > minKarma -- and the player has enough karma - local giveIfVariety = plysAmount <= roleCount -- or if there aren't enough players anymore to have a greater role variety - local giveIfRandom = math.random(RANDOMFORCEROLE_CHANCE) == 1 -- or if the randomness decides (to avoid deadlocks) - - if giveIfWanted or giveIfVariety or giveIfRandom then - print("Giving subrole", roleData.name, "to", ply, - giveIfWanted and "" - or giveIfVariety and "because of minimum role variety" - or giveIfRandom and "because of deadlock avoidance" - or "because ?????" - ) - if not giveIfWanted then - ply:ChatPrint("Sorry; your role selection was ignored due to deadlock prevention.") - end - - table.remove(plys, pick) + local minKarmaCVar = GetConVar("ttt_" .. roleData.name .. "_karma_min") + local minKarma = minKarmaCVar and minKarmaCVar:GetInt() or 0 + + local giveIfWanted = not ply:GetAvoidRole(subrole) -- if the player wants the role + and ply:GetBaseKarma() > minKarma -- and the player has enough karma + local giveIfVariety = plysAmount <= roleCount -- or if there aren't enough players anymore to have a greater role variety + local giveIfRandom = math.random(RANDOMFORCEROLE_CHANCE) == 1 -- or if the randomness decides (to avoid deadlocks) + + if giveIfWanted or giveIfVariety or giveIfRandom then + print("Giving subrole", roleData.name, "to", ply, + giveIfWanted and "" + or giveIfVariety and "because of minimum role variety" + or giveIfRandom and "because of deadlock avoidance" + or "because ?????" + ) + if not giveIfWanted then + ply:ChatPrint("Sorry; your role selection was ignored due to deadlock prevention.") + end + + table.remove(plys, pick) roleselection.finalRoles[ply] = subrole @@ -867,12 +867,12 @@ end -- @realm server -- @internal local function SelectBaseRolePlayers(plys, subrole, roleAmount) - local curRoles = 0 - local plysList = {} + local curRoles = 0 + local plysList = {} - local roleData = roles.GetByIndex(subrole) - local minKarmaCVar = GetConVar("ttt_" .. roleData.name .. "_karma_min") - local min_karmas = minKarmaCVar and minKarmaCVar:GetInt() or 0 + local roleData = roles.GetByIndex(subrole) + local minKarmaCVar = GetConVar("ttt_" .. roleData.name .. "_karma_min") + local min_karmas = minKarmaCVar and minKarmaCVar:GetInt() or 0 while curRoles < roleAmount and #plys > 0 do -- select random index in plys table @@ -881,24 +881,24 @@ local function SelectBaseRolePlayers(plys, subrole, roleAmount) -- the player we consider local ply = plys[pick] - local giveIfWanted = not ply:GetAvoidRole(subrole) -- if the player wants the role - and ply:GetBaseKarma() > min_karmas -- and the player has enough karma - local giveIfInnocent = subrole == ROLE_INNOCENT -- or if the role is innocent (players cannot avoid being innocent) - local giveIfVariety = #plys <= curRoles -- or there aren't enough players anymore to have a greater role variety - local giveIfRandom = math.random(RANDOMFORCEROLE_CHANCE) == 1 -- or if the randomness decides (to avoid deadlocks) - - if giveIfWanted or giveIfInnocent or giveIfVariety or giveIfRandom then - print("Giving role", roleData.name, "to", ply, - giveIfWanted and "" - or giveIfInnocent and "" - or giveIfVariety and "because of minimum role variety" - or giveIfRandom and "because of deadlock avoidance" - or "because ?????" - ) - if not giveIfWanted then - ply:ChatPrint("Sorry; your role selection was ignored due to deadlock prevention.") - end - table.remove(plys, pick) + local giveIfWanted = not ply:GetAvoidRole(subrole) -- if the player wants the role + and ply:GetBaseKarma() > min_karmas -- and the player has enough karma + local giveIfInnocent = subrole == ROLE_INNOCENT -- or if the role is innocent (players cannot avoid being innocent) + local giveIfVariety = #plys <= curRoles -- or there aren't enough players anymore to have a greater role variety + local giveIfRandom = math.random(RANDOMFORCEROLE_CHANCE) == 1 -- or if the randomness decides (to avoid deadlocks) + + if giveIfWanted or giveIfInnocent or giveIfVariety or giveIfRandom then + print("Giving role", roleData.name, "to", ply, + giveIfWanted and "" + or giveIfInnocent and "" + or giveIfVariety and "because of minimum role variety" + or giveIfRandom and "because of deadlock avoidance" + or "because ?????" + ) + if not giveIfWanted then + ply:ChatPrint("Sorry; your role selection was ignored due to deadlock prevention.") + end + table.remove(plys, pick) curRoles = curRoles + 1 plysList[curRoles] = ply diff --git a/lua/terrortown/entities/roles/traitor/shared.lua b/lua/terrortown/entities/roles/traitor/shared.lua index 7a0d66ab03..03606ccce7 100644 --- a/lua/terrortown/entities/roles/traitor/shared.lua +++ b/lua/terrortown/entities/roles/traitor/shared.lua @@ -33,7 +33,7 @@ function ROLE:PreInitialize() ragdollPinning = 1, credits = 2, creditsAwardDeadEnable = 1, - creditsAwardKillEnable = 1,, - togglable = true + creditsAwardKillEnable = 1, + togglable = true } end