From 0dc2173d3af73919847143ac272f48764554d461 Mon Sep 17 00:00:00 2001 From: Histalek <16392835+Histalek@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:31:38 +0100 Subject: [PATCH 1/2] playermodels: Add option to disable resetting player color via `ttt_enforce_playercolor` convar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is mostly done to enhance compatibility with colourable playermodels. Before this change coloured playermodels would be set to `COLOR_WHITE´ or `GAMEMODE.playercolor` on (re)spawn to prevent players from being distinguished by different colours. After this change this behaviour is not changed unless `ttt_enforce_playercolor` is set to 0. In that case we return early in the `GM:TTTPlayerSetColor` hook and do nothing. This does NOT however prevent other addons from hooking into the `TTTPlayerSetColor` hook nor does it prevent other addons from setting the playercolor somewhere else. --- CHANGELOG.md | 2 ++ gamemodes/terrortown/gamemode/server/sv_main.lua | 4 ++++ gamemodes/terrortown/gamemode/server/sv_player.lua | 3 +++ lua/terrortown/lang/en.lua | 8 +++++++- .../menus/gamemode/administration/playermodels.lua | 9 +++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dac903a7b7..2a43a36ef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel ### Added - Added a new font in default_skin.lua to fit the localization (by @Satton2) +- Added `ttt_enforce_playercolor (default: 1)` convar + - can be turned off to stop ttt2 from overriding playermodel colors on (re)spawn ### Changed diff --git a/gamemodes/terrortown/gamemode/server/sv_main.lua b/gamemodes/terrortown/gamemode/server/sv_main.lua index 79cd473f32..517396adfc 100644 --- a/gamemodes/terrortown/gamemode/server/sv_main.lua +++ b/gamemodes/terrortown/gamemode/server/sv_main.lua @@ -196,6 +196,10 @@ CreateConVar("ttt2_confirm_killlist", "1", {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Confi -- @realm server CreateConVar("ttt_enforce_playermodel", "1", {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Whether or not to enforce terrorist playermodels. Set to 0 for compatibility with Enhanced Playermodel Selector") +--- +-- @realm server +CreateConVar("ttt_enforce_playercolor", "1", {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Whether or not to enforce terrorist playercolor. Set to 0 to not reset color on (re)spawn") + --- -- @realm server local ttt_dbgwin = CreateConVar("ttt_debug_preventwin", "0", {FCVAR_NOTIFY, FCVAR_ARCHIVE}) diff --git a/gamemodes/terrortown/gamemode/server/sv_player.lua b/gamemodes/terrortown/gamemode/server/sv_player.lua index 02c7ab5161..28824adac4 100644 --- a/gamemodes/terrortown/gamemode/server/sv_player.lua +++ b/gamemodes/terrortown/gamemode/server/sv_player.lua @@ -268,6 +268,9 @@ end -- @hook -- @realm server function GM:TTTPlayerSetColor(ply) + + if not GetConVar("ttt_enforce_playercolor"):GetBool() then return end + local c = COLOR_WHITE if GAMEMODE.playercolor then diff --git a/lua/terrortown/lang/en.lua b/lua/terrortown/lang/en.lua index 46bbb0ba2d..6076605238 100644 --- a/lua/terrortown/lang/en.lua +++ b/lua/terrortown/lang/en.lua @@ -1859,4 +1859,10 @@ L.sb_rank_tooltip_streamer = "Streamer" L.sb_rank_tooltip_heroes = "TTT2 Heroes" L.sb_rank_tooltip_team = "Team" -L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +L.help_enforce_playercolor = [[ +This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. + +If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/menus/gamemode/administration/playermodels.lua b/lua/terrortown/menus/gamemode/administration/playermodels.lua index d8964877b8..4aecb2447f 100644 --- a/lua/terrortown/menus/gamemode/administration/playermodels.lua +++ b/lua/terrortown/menus/gamemode/administration/playermodels.lua @@ -19,6 +19,15 @@ function CLGAMEMODESUBMENU:Populate(parent) serverConvar = "ttt_enforce_playermodel" }) + form:MakeHelp({ + label = "help_enforce_playercolor" + }) + + form:MakeCheckBox({ + label = "label_enforce_playercolor", + serverConvar = "ttt_enforce_playercolor" + }) + form:MakeHelp({ label = "help_prefer_map_models" }) From 2d9b5c1f642714bce05faae439e914f7fecb9de8 Mon Sep 17 00:00:00 2001 From: Histalek <16392835+Histalek@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:48:42 +0100 Subject: [PATCH 2/2] fixup: Add lang files --- lua/terrortown/lang/de.lua | 7 ++++++- lua/terrortown/lang/es.lua | 7 ++++++- lua/terrortown/lang/fr.lua | 7 ++++++- lua/terrortown/lang/it.lua | 7 ++++++- lua/terrortown/lang/ja.lua | 7 ++++++- lua/terrortown/lang/pl.lua | 7 ++++++- lua/terrortown/lang/pt_br.lua | 7 ++++++- lua/terrortown/lang/ru.lua | 7 ++++++- lua/terrortown/lang/zh_hans.lua | 7 ++++++- lua/terrortown/lang/zh_tw.lua | 7 ++++++- 10 files changed, 60 insertions(+), 10 deletions(-) diff --git a/lua/terrortown/lang/de.lua b/lua/terrortown/lang/de.lua index c44e57dbb6..b1e175c2a4 100644 --- a/lua/terrortown/lang/de.lua +++ b/lua/terrortown/lang/de.lua @@ -1859,4 +1859,9 @@ L.label_roles_credits_kill_award = "Aktiviere Ausrüstungspunktebelohnung für M --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/es.lua b/lua/terrortown/lang/es.lua index 5019a8727b..138bf22c2a 100644 --- a/lua/terrortown/lang/es.lua +++ b/lua/terrortown/lang/es.lua @@ -1859,4 +1859,9 @@ L.desc_event_kill_other_using = "{victim} ({vrole} / {vteam}) fue asesinado por --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/fr.lua b/lua/terrortown/lang/fr.lua index 50530a2fca..3871f800b0 100644 --- a/lua/terrortown/lang/fr.lua +++ b/lua/terrortown/lang/fr.lua @@ -1859,4 +1859,9 @@ L.karma_unknown_tooltip = "Inconnu" --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/it.lua b/lua/terrortown/lang/it.lua index b93f25af11..90ebacb768 100644 --- a/lua/terrortown/lang/it.lua +++ b/lua/terrortown/lang/it.lua @@ -1859,4 +1859,9 @@ L.desc_event_kill_other_using = "{victim} ({vrole} / {vteam}) è stata ucciso da --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/ja.lua b/lua/terrortown/lang/ja.lua index 12c5a952cd..fb16472c4d 100644 --- a/lua/terrortown/lang/ja.lua +++ b/lua/terrortown/lang/ja.lua @@ -1855,4 +1855,9 @@ L.help_falldmg_exponent = [[ --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/pl.lua b/lua/terrortown/lang/pl.lua index 6f8d96e7e2..5f2f1633b8 100644 --- a/lua/terrortown/lang/pl.lua +++ b/lua/terrortown/lang/pl.lua @@ -1859,4 +1859,9 @@ L.none = "Brak Roli" --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/pt_br.lua b/lua/terrortown/lang/pt_br.lua index 4a2d84865c..4b73408983 100644 --- a/lua/terrortown/lang/pt_br.lua +++ b/lua/terrortown/lang/pt_br.lua @@ -1887,4 +1887,9 @@ L.xfer_team_indicator = "Time" --L.sb_rank_tooltip_heroes = "TTT2 Heroes" --L.sb_rank_tooltip_team = "Team" ---L.tbut_adminarea = "ADMIN AREA:" \ No newline at end of file +--L.tbut_adminarea = "ADMIN AREA:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/ru.lua b/lua/terrortown/lang/ru.lua index 677a092501..f11363c347 100644 --- a/lua/terrortown/lang/ru.lua +++ b/lua/terrortown/lang/ru.lua @@ -1862,4 +1862,9 @@ L.sb_rank_tooltip_streamer = "Стример" L.sb_rank_tooltip_heroes = "Герои TTT2" L.sb_rank_tooltip_team = "Команда" -L.tbut_adminarea = "Администраторская зона:" \ No newline at end of file +L.tbut_adminarea = "Администраторская зона:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/zh_hans.lua b/lua/terrortown/lang/zh_hans.lua index 8277af8431..0ab55afb91 100644 --- a/lua/terrortown/lang/zh_hans.lua +++ b/lua/terrortown/lang/zh_hans.lua @@ -1865,4 +1865,9 @@ L.sb_rank_tooltip_streamer = "主播" L.sb_rank_tooltip_heroes = "TTT2 英雄" L.sb_rank_tooltip_team = "阵营" -L.tbut_adminarea = "管理区:" \ No newline at end of file +L.tbut_adminarea = "管理区:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]] diff --git a/lua/terrortown/lang/zh_tw.lua b/lua/terrortown/lang/zh_tw.lua index 62965ce771..feb20be4b1 100644 --- a/lua/terrortown/lang/zh_tw.lua +++ b/lua/terrortown/lang/zh_tw.lua @@ -1864,4 +1864,9 @@ L.sb_rank_tooltip_streamer = "主播" L.sb_rank_tooltip_heroes = "TTT2 英雄" L.sb_rank_tooltip_team = "陣營" -L.tbut_adminarea = "管理區:" \ No newline at end of file +L.tbut_adminarea = "管理區:" + +-- 2023-03-09 +--L.help_enforce_playercolor = [[ +--This sets all players to the same color on (re)spawn to prevent any distinction between playermodels and therefore the respective players. +--If disabled this should allow colors from custom colorable playermodels to stick. Be aware that this might break (with) some appearance changing equipment e.g. make a disguise pretty obvious.]]