Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playermodels: Add option to disable resetting player color via ttt_enforce_playercolor convar #1027

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Histalek
Copy link
Member

@Histalek Histalek commented Mar 9, 2023

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.

NOTE: This is also not tested yet, hence draft status

…nforce_playercolor` convar

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.
@Histalek Histalek added type/enhancement Enhancement or simple change to existing functionality accepted labels Mar 9, 2023
@Histalek Histalek self-assigned this Mar 9, 2023
@Histalek
Copy link
Member Author

ttt_playercolor_mode = 0 seems to be unused [1]. Which looks like a better approach to this.

[1]

---
-- @realm shared
-- stylua: ignore
local colormode = CreateConVar("ttt_playercolor_mode", "1", {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED})
---
-- @param string model The selected (default) playermodel
-- @hook
-- @realm shared
function GM:TTTPlayerColor(model)
local mode = colormode:GetInt()
if mode == 1 then
return ttt_playercolors.serious[math.random(ttt_playercolors_serious_count)]
elseif mode == 2 then
return ttt_playercolors.all[math.random(ttt_playercolors_all_count)]
elseif mode == 3 then
-- Full randomness
return Color(math.random(0, 255), math.random(0, 255), math.random(0, 255))
end
-- No coloring
return COLOR_WHITE
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement or simple change to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant