Skip to content

Commit

Permalink
fix SubRoleModel reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Alf21 committed Mar 5, 2019
1 parent 15b7ebb commit 96baf4d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions gamemodes/terrortown/gamemode/shared/sh_player_ext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ else
local ply = net.ReadEntity()

if IsValid(ply) then
util.PrecacheModel(mdl)

ply:SetModel(mdl)
end
end)
Expand All @@ -146,9 +144,11 @@ else
local mdl = net.ReadString()
local ply = net.ReadEntity()

if IsValid(ply) then
util.PrecacheModel(mdl)
if mdl == "" then
mdl = nil
end

if IsValid(ply) then
ply:SetSubRoleModel(mdl)
end
end)
Expand Down Expand Up @@ -606,21 +606,24 @@ function plymeta:SetTargetPlayer(ply)
end
end

function plymeta:GetSubRoleModel()
return self.subroleModel
end

local function checkModel(mdl)
return mdl and mdl ~= "" and mdl ~= "models/player.mdl"
end

function plymeta:GetSubRoleModel()
return self.subroleModel
end

function plymeta:SetSubRoleModel(mdl)
if not checkModel(mdl) then return end
if not checkModel(mdl) then
mdl = nil
end

self.subroleModel = mdl

if SERVER then
net.Start("TTT2SyncSubroleModel")
net.WriteString(mdl)
net.WriteString(mdl or "")
net.WriteEntity(self)
net.Broadcast()
end
Expand Down

1 comment on commit 96baf4d

@Alf21
Copy link
Member Author

@Alf21 Alf21 commented on 96baf4d Mar 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix #281

Please sign in to comment.