I need to print the weapon name on the screen for 2.5 seconds when the player changes weapons. I looked for help on the Garrysmod Wiki and found that using a repeat loop and os.clock would work best.
Heres what I have so far:
function ShowWeaponName ()
local starttime = os.clock()
local old_wep = LocalPlayer():GetActiveWeapon()
if tonumber(old_wep) != tonumber(LocalPlayer():GetActiveWeapon()) then repeat draw.SimpleText( LocalPlayer():GetActiveWeapon():GetPrintName(), "BANKGOTHICSM", ScrW() - 220, ScrH() - 120, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) until os.clock() - starttime > 2 end
hook.Add( “HUDPaint”, “DrawWeaponName”, ShowWeaponName)
What is wrong? I took the example from the website but this isn’t working… Maybe the weapon check is wrong? I know the text position and everything on that line works.