I’m practicing some Lua and I’m wondering what the easiest way to go about doing this is:
A SWEP changes a player boolean to true. Within the cl_hud of the Gamemode, if this is true, then it draws text.
Within the SWEP:
function SWEP:SecondaryAttack() if SERVER then self.Owner.toggle = true self:Remove() end end
Within the Gamemode cl_hud.lua
function GM:DrawGameHUD() if LocalPlayer().toggle then drawTextShadow("Hello Facepunch", "HudHintTextLarge", 5, ScrH() - 135, Color(255,0,0,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT) end end
I already realize I’m doing it wrong, but hopefully somebody can help me understand how to make this work. In the context of this code, Right Clicking with the SWEP should show “Hello Facepunch” on the screen even when the SWEP isn’t there. The reason I don’t want to GM:DrawGameHUD() in the SWEP itself is because the SWEP must be removed after it’s been used, so it would no longer draw the text if it’s been removed.