• Gmod TTT Custom player models Sometimes unequips on round start
    9 replies, posted
It happens frequently, but sometimes the player model actually stays. It'll fix itself after a map change sometimes but it is quite annoying. Is there a fix for this? My current code is this: [CODE]ITEM.Name = 'Jeff' ITEM.Price = 30000 ITEM.Model = 'models/newinfec/newhun.mdl' function ITEM:OnEquip(ply, modifications) if not ply._OldModel then ply._OldModel = ply:GetModel() end timer.Simple(2, function() ply:SetModel(self.Model) ply:SetupHands() end) end function ITEM:OnHolster(ply) if ply._OldModel then ply:SetModel(ply._OldModel) end end function ITEM:PlayerSetModel(ply) ply:SetModel(self.Model) end [/CODE]
You can try this [url]https://facepunch.com/showthread.php?t=1250362&p=41323661&viewfull=1#post41323661[/url] Or [QUOTE][IMG]https://vgy.me/ptFMjR.png[/IMG][/QUOTE]
[QUOTE=iJohnny;51530040]You can try this [url]https://facepunch.com/showthread.php?t=1250362&p=41323661&viewfull=1#post41323661[/url] Or[/QUOTE] I have googled it, the main answer is to comment out line 271 (which was a fix a few years back. The line 271 fix is already fixed when you get pointshop.) Also, most of the results are from 2013-2014 and is outdated.
Any idea at all? If I can't figure it out I'll purchase point shop 2 (or I could wait for pointshop pro) which will hopefully fix it. Edit: It seems to be doing this to the default Kleiner model as well
TTT resets the playermodel on TTTBeginRound. You all should know that. Just hook into TTTBeginRound and set the playermodel there.
[QUOTE=Moat;51534077]Try running a simple timer before setting the model in the PlayerSetModel hook. If that fails, try doing it in the PlayerSpawn hook.[/QUOTE] Alright thanks for the reply, I'll give that a try. I'm trying to recreate the issue but I'm having no success so far. I'll add the timer whenever it happens again. (It seems to happen when there are other players on the server, currently I'm testing with bots) [QUOTE=mcNuggets1;51534200]TTT resets the playermodel on TTTBeginRound. You all should know that. Just hook into TTTBeginRound and set the playermodel there.[/QUOTE] Like so? (I'm new to lua, forgive me If I messed up lol) [CODE]ITEM.Name = 'Kleiner' ITEM.Price = 250 ITEM.Model = 'models/player/kleiner.mdl' function ITEM:OnEquip(ply, modifications) if not ply._OldModel then ply._OldModel = ply:GetModel() end timer.Simple(1, function() ply:SetModel(self.Model) end) end function ITEM:OnHolster(ply) if ply._OldModel then ply:SetModel(ply._OldModel) end end function ITEM:PlayerSetModel(ply) ply:SetModel(self.Model) end hook.Add("TTTBeginRound","resetModel",PlayerSetModel)[/CODE]
[code] local function SetPlayerModel(ply, model, modifications) if IsValid(ply) and ply:Alive() and !ply:IsSpec() then if ply.IsGhost and ply:IsGhost() then return end ply.PS_OldModel = ply:GetModel() ply:SetModel(model) if modifications then if modifications.skin then ply:SetSkin(modifications.skin) end if modifications.bodygroups then for k,v in pairs(modifications.bodygroups) do if string.find(model, "dod") then ply:SetBodygroup(k-1, v) else ply:SetBodygroup(k, v) end end end end ply:SetupHands() end end function PS_GivePlayerModel(ply, model, modifications) timer.Simple(0.01, function() SetPlayerModel(ply, model, modifications) end) hook.Add("TTTBeginRound", ply:SteamID().."_playermodel", function() timer.Simple(0.01, function() SetPlayerModel(ply, model, modifications) end) end) end function PS_RemovePlayerModel(ply) timer.Simple(0.01, function() if IsValid(ply) and ply:Alive() and !ply:IsSpec() then if ply.IsGhost and ply:IsGhost() then return end if ply.PS_OldModel then ply:SetModel(ply.PS_OldModel) ply:SetupHands() end end end) hook.Remove("TTTBeginRound", ply:SteamID().."_playermodel") end [/code] Use PS_GivePlayerModel on Equip function. Use PS_RemovePlayerModel on Holster function.
[QUOTE=mcNuggets1;51534341][code] local function SetPlayerModel(ply, model, modifications) if IsValid(ply) and ply:Alive() and !ply:IsSpec() then if ply.IsGhost and ply:IsGhost() then return end ply.PS_OldModel = ply:GetModel() ply:SetModel(model) if modifications then if modifications.skin then ply:SetSkin(modifications.skin) end if modifications.bodygroups then for k,v in pairs(modifications.bodygroups) do if string.find(model, "dod") then ply:SetBodygroup(k-1, v) else ply:SetBodygroup(k, v) end end end end ply:SetupHands() end end function PS_GivePlayerModel(ply, model, modifications) timer.Simple(0.01, function() SetPlayerModel(ply, model, modifications) end) hook.Add("TTTBeginRound", ply:SteamID().."_playermodel", function() timer.Simple(0.01, function() SetPlayerModel(ply, model, modifications) end) end) end function PS_RemovePlayerModel(ply) timer.Simple(0.01, function() if IsValid(ply) and ply:Alive() and !ply:IsSpec() then if ply.IsGhost and ply:IsGhost() then return end if ply.PS_OldModel then ply:SetModel(ply.PS_OldModel) ply:SetupHands() end end end) hook.Remove("TTTBeginRound", ply:SteamID().."_playermodel") end [/code] Use PS_GivePlayerModel on Equip function. Use PS_RemovePlayerModel on Holster function.[/QUOTE] Thanks! I'll test it out tonight whenever no one is online. How would I go about incorporating that into Equip and Holster in the playershop.lua? Would I just simply make a Hook and call on those functions? Or literally use the provided code in equip/holster [editline]15th December 2016[/editline] Edit: I did as moat said and the models seem to be working now! I added this to the PlayerSetModel [CODE]timer.Simple(1, function() ply:SetModel(self.Model) end)[/CODE] If the issue persists I will update the thread, for now it seems to be working. I appreciate everyone who participated in helping me! I wouldn't of been able to figure it out without you.
Sorry, you need to Log In to post a reply to this thread.