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

Histalek added 2 commits March 9, 2023 13:31
…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 Histalek temporarily deployed to histalek-dev-env March 9, 2023 13:04 — with GitHub Actions Inactive
@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

@SvveetMavis
Copy link
Contributor

I tested this with the latest version and it works good, had to get enhanced playermodel selector to pick a color but like the color got kept between rounds and stuff, i think if there was a way to open the color selector from like the default ttt2 f1 menu then this would be a cool little overhaul to the color system. One thing I noticed with colors though is they aren't applied to the like playermodel display in the search menu so if you ever work on this again that would be a good addition, would also be neat if like there was a setting to make the colors it selects from without the color selector randomized per player rather than 1 color randomly selected for everyone

@Histalek
Copy link
Member Author

Thanks for testing this!

I originally got stuck on this because i wasn't able to properly test if this was the only reset for the color and how this would interact with different addons. So i appreciate you testing this!

had to get enhanced playermodel selector to pick a color

What happened if you did not do that? Did that break something or was it undesirable in some other way?

@SvveetMavis
Copy link
Contributor

oh without playermodel selector I would be stuck as white but once I used playermodel selector to set a color onto myself it would persist and not get replaced by one of the randomized colors, without enforce playercolor thing the color set would reset every round and have to be reapplied, thats why I was talking about like a built in color selector

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.

2 participants