Skip to content
Draft
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
58 changes: 5 additions & 53 deletions gamemodes/terrortown/gamemode/server/sv_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ttt_include("sh_armor")
ttt_include("sh_player_ext")

ttt_include("sv_player_ext")
ttt_include("sv_player_custom")
ttt_include("sv_player")

ttt_include("sv_addonchecker")
Expand All @@ -66,21 +67,6 @@ local util = util
local hook = hook
local playerGetAll = player.GetAll

---
-- @realm server
local cvPreferMapModels =
CreateConVar("ttt2_prefer_map_models", "1", { FCVAR_NOTIFY, FCVAR_ARCHIVE })

---
-- @realm server
local cvSelectModelPerRound =
CreateConVar("ttt2_select_model_per_round", "1", { FCVAR_NOTIFY, FCVAR_ARCHIVE })

---
-- @realm server
local cvSelectUniqueModelPerPlayer =
CreateConVar("ttt2_select_unique_model_per_player", "0", { FCVAR_NOTIFY, FCVAR_ARCHIVE })

---
-- @realm server
CreateConVar("ttt_haste_minutes_per_death", "0.5", { FCVAR_NOTIFY, FCVAR_ARCHIVE })
Expand Down Expand Up @@ -130,15 +116,6 @@ local map_switch_delay = CreateConVar(
0
)

---
-- @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_newroles_enabled", "1", { FCVAR_NOTIFY, FCVAR_ARCHIVE })
Expand Down Expand Up @@ -427,9 +404,7 @@ function GM:InitPostEntity()
-- initialize playermodel database
playermodels.Initialize()

-- set the default random playermodel
self.playermodel = playermodels.GetRandomPlayerModel()
self.playercolor = COLOR_WHITE
self.playermodel, self.playercolor = hook.Run("TTT2GetDefaultPlayerDisplay")

timer.Simple(0, function()
addonChecker.Check()
Expand Down Expand Up @@ -700,9 +675,7 @@ function GM:OnReloaded()

button.SetUp()

-- set the default random playermodel
self.playermodel = playermodels.GetRandomPlayerModel()
self.playercolor = COLOR_WHITE
self.playermodel, self.playercolor = hook.Run("TTT2GetDefaultPlayerDisplay")

-- register synced player variables
player.RegisterSettingOnServer("enable_dynamic_fov", "bool")
Expand Down Expand Up @@ -922,29 +895,8 @@ function GM:TTT2PrePrepareRound(duration)
MuteForRestart(false)
end)

-- sets the player model
-- supports map models or random player models
if cvPreferMapModels:GetBool() and self.force_plymodel and self.force_plymodel ~= "" then
self.playermodel = self.force_plymodel
elseif cvSelectModelPerRound:GetBool() then
if cvSelectUniqueModelPerPlayer:GetBool() then
local plys = player.GetAll()
for i = 1, #plys do
plys[i].defaultModel = playermodels.GetRandomPlayerModel()
end
else
local plys = player.GetAll()
for i = 1, #plys do
plys[i].defaultModel = nil
end

self.playermodel = playermodels.GetRandomPlayerModel()
end
end

---
-- @realm server
self.playercolor = hook.Run("TTTPlayerColor", self.playermodel)
-- select new default playermodels for the round
self.playermodel, self.playercolor = hook.Run("TTT2GetDefaultPlayerDisplayForRound")
end

---
Expand Down
64 changes: 0 additions & 64 deletions gamemodes/terrortown/gamemode/server/sv_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,6 @@ function GM:PlayerSpawn(ply)
end
end

---
-- Called whenever view model hands needs setting a model.
-- By default this calls @{Player:GetHandsModel} and if that fails,
-- sets the hands model according to his @{Player} model.
-- @param Player ply The @{Player} whose hands needs a model set
-- @param Entity ent The hands to set model of
-- @hook
-- @realm server
-- @ref https://wiki.facepunch.com/gmod/GM:PlayerSetHandsModel
-- @local
function GM:PlayerSetHandsModel(ply, ent)
local simplemodel = player_manager.TranslateToPlayerModelName(ply:GetModel())
local info = player_manager.TranslatePlayerHands(simplemodel)

if info then
ent:SetModel(info.model)
ent:SetSkin(info.skin)
ent:SetBodyGroups(info.body)
end
end

---
-- Check if a @{Player} can spawn at a certain spawnpoint.
-- @param Player ply The @{Player} who is spawned
Expand Down Expand Up @@ -240,49 +219,6 @@ function GM:PlayerSelectSpawn(ply, transition)
-- "[PlayerSelectSpawn] Error! No spawn points!"
end

---
-- Called whenever a @{Player} spawns and must choose a model.
-- A good place to assign a model to a @{Player}.
-- @note This function may not work in your custom gamemode if you have overridden
-- your @{GM:PlayerSpawn} and you do not use self.BaseClass.PlayerSpawn or @{hook.Run}.
-- @param Player ply The @{Player} being chosen
-- @hook
-- @realm server
-- @ref https://wiki.facepunch.com/gmod/GM:PlayerSetModel
-- @local
function GM:PlayerSetModel(ply)
-- The player modes has to be applied here since some player model selectors overwrite
-- this hook to suppress the TTT2 player models. If the model is assigned elsewhere, it
-- breaks with external model selectors.
if not IsValid(ply) then
return
end

-- this will call the overwritten internal function to modify the model
ply:SetModel(ply.defaultModel or GAMEMODE.playermodel)

-- Always clear color state, may later be changed in TTTPlayerSetColor
ply:SetColor(COLOR_WHITE)
end

---
-- Called when a @{Player} spawns and updates the @{Color}
-- @param Player ply
-- @hook
-- @realm server
function GM:TTTPlayerSetColor(ply)
local c = COLOR_WHITE

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.
c = GAMEMODE.playercolor
end

ply:SetPlayerColor(Vector(c.r / 255.0, c.g / 255.0, c.b / 255.0))
end

---
-- Determines if the @{Player} can kill themselves using the concommands "kill" or "explode".
-- Only active players can use kill cmd
Expand Down
Loading
Loading