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

Use PlayerModel colouring for TTT players #939

Merged
merged 2 commits into from
May 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions garrysmod/gamemodes/terrortown/gamemode/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,13 @@ end

function GM:TTTPlayerSetColor(ply)
local clr = COLOR_WHITE
local should_color = hook.Call("TTTShouldColorModel", GAMEMODE, ply:GetModel())
if GAMEMODE.playercolor and should_color then
if GAMEMODE.playercolor then
-- If this player has a colorable model, always use the same color as all
-- other colorable players, so color will never be the factor that lets
-- you tell players apart.
clr = GAMEMODE.playercolor
end
ply:SetColor(clr)
ply:SetPlayerColor( Vector( clr.r/255.0, clr.g/255.0, clr.b/255.0 ) )
end


Expand Down
27 changes: 8 additions & 19 deletions garrysmod/gamemodes/terrortown/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,6 @@ function GetRandomPlayerModel()
return table.Random(ttt_playermodels)
end

function GM:TTTShouldColorModel(mdl)
local colorable = {
"models/player/phoenix.mdl",
"models/player/guerilla.mdl",
"models/player/leet.mdl"
};
return table.HasValue(colorable, mdl)
end

local ttt_playercolors = {
all = {
COLOR_WHITE,
Expand Down Expand Up @@ -147,16 +138,14 @@ local ttt_playercolors = {

CreateConVar("ttt_playercolor_mode", "1")
function GM:TTTPlayerColor(model)
if hook.Call("TTTShouldColorModel", GAMEMODE, model) then
local mode = GetConVarNumber("ttt_playercolor_mode") or 0
if mode == 1 then
return table.Random(ttt_playercolors.serious)
elseif mode == 2 then
return table.Random(ttt_playercolors.all)
elseif mode == 3 then
-- Full randomness
return Color(math.random(0, 255), math.random(0, 255), math.random(0, 255))
end
local mode = GetConVarNumber("ttt_playercolor_mode") or 0
if mode == 1 then
return table.Random(ttt_playercolors.serious)
elseif mode == 2 then
return table.Random(ttt_playercolors.all)
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
Expand Down