• attempt to call method 'GetEyeTrace' (a nil value)
    8 replies, posted
So im getting this error on my server and its flooding my console. Im wondering how i could fix it here is my code: [CODE]function GM.Property:PaintDoorText() local door = LocalPlayer():GetEyeTrace().Entity if not IsValid( door ) or not self.m_tblDoorCache[door:EntIndex()] then return end if LocalPlayer():GetPos():DistToSqr( door:GetPos() ) > 16384 then return end local pos, ang, posBack, angBack, width, hitWorld = self:CalculateDoorPositioning( door ) render.SuppressEngineLighting( true ) cam.Start3D2D( pos, ang, 0.02 ) self:PaintDoorCard( pos, door, door:GetModel() ) cam.End3D2D() cam.Start3D2D( posBack, angBack, 0.02 ) self:PaintDoorCard( pos, door, door:GetModel(), true ) cam.End3D2D() render.SuppressEngineLighting( false ) end [/CODE]
Make sure LocalPlayer is valid before running the code.
Ya see i am doctor dumb ass and don't even know how to do that :P
if (LocalPlayer() == NULL) then return end
Like so? [CODE]function GM.Property:PaintDoorText() if (LocalPlayer() == NULL) then return end local door = LocalPlayer():GetEyeTrace().Entity if not IsValid( door ) or not self.m_tblDoorCache[door:EntIndex()] then return end if LocalPlayer():GetPos():DistToSqr( door:GetPos() ) > 16384 then return end local pos, ang, posBack, angBack, width, hitWorld = self:CalculateDoorPositioning( door ) render.SuppressEngineLighting( true ) cam.Start3D2D( pos, ang, 0.02 ) self:PaintDoorCard( pos, door, door:GetModel() ) cam.End3D2D() cam.Start3D2D( posBack, angBack, 0.02 ) self:PaintDoorCard( pos, door, door:GetModel(), true ) cam.End3D2D() render.SuppressEngineLighting( false ) end [/CODE]
Yes
That still does not fix the error May i add you on steam?
I rather not; it disadvantages people who have a similar issue from finding the source of the issue. Try this: [code]function GM.Property:PaintDoorText() if (not LocalPlayer().GetEyeTrace) then return end local door = LocalPlayer():GetEyeTrace().Entity if not IsValid( door ) or not self.m_tblDoorCache[door:EntIndex()] then return end if LocalPlayer():GetPos():DistToSqr( door:GetPos() ) > 16384 then return end local pos, ang, posBack, angBack, width, hitWorld = self:CalculateDoorPositioning( door ) render.SuppressEngineLighting( true ) cam.Start3D2D( pos, ang, 0.02 ) self:PaintDoorCard( pos, door, door:GetModel() ) cam.End3D2D() cam.Start3D2D( posBack, angBack, 0.02 ) self:PaintDoorCard( pos, door, door:GetModel(), true ) cam.End3D2D() render.SuppressEngineLighting( false ) end[/code]
Oh thank you very much that fixed it.
Sorry, you need to Log In to post a reply to this thread.