• draw.SimpleText() not working?
    8 replies, posted
Hey, For some reason, when I'm using this code, the avatar works correctly, but the text won't display. I've tried just trying it with regular text rather than the name, and when i move it out of the loop, it works fine. It's being ran in a frame.Paint function, and the staff table is holding players. Any ideas as to why this doesn't work would be lovely.     net.Receive("omotd_sendstaff", function()       staff = net.ReadTable() for k,v in pairs(staff) do draw.SimpleText(v:Name(), "OLogs_TitleFont", ScrW() * 0.65, MotdStaffY, Color(255, 255, 255), 0, 0) local Avatar = vgui.Create("AvatarCircled", frame) Avatar:SetPos(ScrW() * 0.65, MotdStaffY) Avatar:SetSize(ScrW() * 0.025, ScrH() * 0.04) Avatar:SetPlayer(v, 64) MotdStaffY = MotdStaffY + 50 end     end) Here's what it's displaying https://files.facepunch.com/forum/upload/112953/3fda6947-a79f-402f-bef8-5a80ea349da2/image.png Thanks!
draw functions must be called within a hook with a 2d rendering context. An example of this would be GM:HUDPaint or PANEL:Paint.
use dLabel instead, as you need a render context to use the draw library, and net messages aren't a render context.
I've tried just trying it with regular text rather than the name, and also using DLabels instead. Read the full post before posting on any thread...
A thread is all about conversation, and if you aren't willing to expand into further detail, choosing instead to be condescending, then I don't know why you bothered to ask for help. The draw library should be used on a per-frame basis, meaning that for any frame rendered, you need to tell it what to render, each and every time. Your net message, not only does it not get sent for every frame, will never be received during the rendering of a frame. You can instead use a dLabel, and override it's paint method, and render whatever you want in there. tldr; maybe listen to someone trying to help you, instead of being a dick.
What i was saying there was that i had said the the first post that i had tried using DLabels, but again did not work. I'm not trying to be a dick, I'm telling you what i had tried.
What does your code look like when your using dLabels?
net.Receive("omotd_sendstaff", function()       staff = net.ReadTable() for k,v in pairs(staff) do local label = vgui.Create("DLabel") label:SetPos(400, 400) label:SetText("Test") local Avatar = vgui.Create("AvatarCircled", frame) Avatar:SetPos(ScrW() * 0.65, MotdStaffY) Avatar:SetSize(ScrW() * 0.025, ScrH() * 0.04) Avatar:SetPlayer(v, 64) MotdStaffY = MotdStaffY + 50 end
You didn't parent it to the frame (which I'm now wondering, where even is that defined?). On top of that, the position is static, therefore all the dLabels would overlap. While I'm here I'm going to drop this link The XY Problem
Sorry, you need to Log In to post a reply to this thread.