i coded entity that when i spawn it it draw ulr image and when i spawn the entity i dont see the image.
pls help me with that
code cl_init.lua :
include("shared.lua")
net.Receive( "ImageSet", function( len )
local IMAGE_URL = net.ReadString()
local pnlHTML = vgui.Create("HTML")
pnlHTML:SetVisible(true)
--pnlHTML:SetPos(50,50)
pnlHTML:SetPos(ScrW()-1, ScrH()-1)
pnlHTML:SetSize(size, size)
pnlHTML:SetHTML(
[[
<img src= "https://imgur.com/9Et9mRN" alt= "test" style= "width:256px;height:256px;">
]]
)
timer.Simple(5, function()
if IsValid(pHtml) and pHtml:GetHTMLMaterial() then
mat_url_image = pnlHTML:GetHTMLMaterial()
end
end)
end )
function ENT:Draw()
self:DrawModel()
local DrawPos = self:LocalToWorld(Vector(1, -111, 58))
local DrawAngles = self:GetAngles()
DrawAngles:RotateAroundAxis(self:GetAngles():Forward(), 90)
DrawAngles:RotateAroundAxis(self:GetAngles():Up(), 90)
cam.Start3D2D(DrawPos, DrawAngles, 0.4)
if mat_url_image then
surface.SetMaterial(mat_url_image)
end
surface.DrawTexturedRect(0, 0, 558, 290)
cam.End3D2D()
end
Where do you define mat_url_image? In the shared.lua?
i dont do that and how i define this?
Right now, your mat_url_image is local to net.Receive code block and its always nil in ENT:Draw() hook. Add after include: (it will make this variable local to file)
local mat_url_image
Sorry, you need to Log In to post a reply to this thread.