Luea Error with TF2 Hats
Last read Never
Hello, I recently opened my old gmod roleplay server.
and something broke up (probably some updates broke it)...
I got a Hat Mod in my roleplay gamemode and when i look at someone who wearing a hat i get Clientside console errors, it was working few years ago. any idea what do i need to fix here?
[ERROR] gamemodes/girp/entities/entities/hat/cl_init.lua:52: Tried to use a NULL entity!
1. LookupBone - [C]:-1
2. unknown - gamemodes/girp/entities/entities/hat/cl_init.lua:52
this is the code:
include("shared.lua")
function ENT:Think()
if !self.Drawing then return; else self.Drawing = false; end;
local owner = self.Entity:GetOwner()
if owner:GetRagdollEntity() then
owner = owner:GetRagdollEntity()
elseif IsValid(owner.Ragdoll) then
owner = owner.Ragdoll
elseif not owner:Alive() then return end
if (!self.LastEffect or self.LastEffect + .15 < CurTime()) and self:GetItemID() and GAMEMODE.OCRP_Items[self:GetItemID()].Effect and ((IsValid(owner) and LocalPlayer() == owner) or LocalPlayer():CanSee(self)) then
self.LastEffect = CurTime();
local pos = self:GetPos();
local boneindex = owner:LookupBone("ValveBiped.Bip01_Head1")
if IsValid(self) and boneindex then
local p = UnusualEmitter:Add(GAMEMODE.ItemDatabase[self:GetItemID()].Effect, owner:GetBonePosition(boneindex)+Vector(0,0, 10))
p:SetVelocity(Vector(0,0, 20))
p:SetDieTime(1)
p:SetStartAlpha(50)
p:SetEndAlpha(70)
p:SetStartSize(1)
p:SetEndSize(10)
p:SetRoll( math.Rand( 0,10 ) )
p:SetRollDelta(math.Rand( -0.2, 0.2 ))
end
end
if self.Entity:GetColor().a ~= self.Entity:GetOwner():GetColor().a then
self.Entity:SetColor(Color(255,255,255, self.Entity:GetOwner():GetColor().a))
self.Entity:SetRenderMode( RENDERMODE_TRANSALPHA )
end
end
function ENT:Initialize()
self:SetRenderBounds(Vector(-40, -40, -18), Vector(40, 40, 84))
end
function ENT:Draw()
if LocalPlayer():ShouldDrawLocalPlayer() == false and LocalPlayer() == self.Entity:GetOwner() then return end
local owner = self.Entity:GetOwner()
if owner:GetRagdollEntity() then
owner = owner:GetRagdollEntity()
elseif IsValid(owner.Ragdoll) then
owner = owner.Ragdoll
elseif not owner:Alive() then return end
local boneindex = owner:LookupBone("ValveBiped.Bip01_Head1")
if IsValid(self) and boneindex then
local hatpos = GAMEMODE.HatsPositions[self:GetModel()];
local pos, ang = owner:GetBonePosition(boneindex)
if pos and pos ~= owner:GetPos() and hatpos and hatpos ~= nil then
if IsValid(self.Entity:GetOwner()) and self.Entity:GetOwner():GetSex() == SEX_FEMALE then hatpos = GAMEMODE.HatsPositionsFemale[self:GetModel()] end
self.Entity:SetPos(pos + ang:Forward()*hatpos.pf + ang:Right()*hatpos.pr)
ang:RotateAroundAxis(ang:Right(),hatpos.ar)
ang:RotateAroundAxis(ang:Up(),hatpos.au)
self.Entity:SetAngles(ang)
if hatpos.resize then
self.Entity:SetModelScale(hatpos.resize, 0)
end
self.Drawing = true;
self.Entity:DrawModel()
end
end
end
Users viewing this thread
Nobody