• Scoreboard help
    3 replies, posted
Just wondering how I am to set up the scoreboard, I've tried to following but I get an error message. [CODE] function scoreboard:show() local blur = Material('pp/blurscreen') local function draw_Blur(panel, amount) local x, y = panel:LocalToScreen( 0, 0 ) local scrW, scrH = ScrW(), ScrH() surface.SetDrawColor( 255, 255, 0 ) surface.SetMaterial( blur ) for i = 1, 6 do blur:SetFloat('$blur', (i / 6) * (amount ~= nil and amount or 6)) blur:Recompute() render.UpdateScreenEffectTexture() surface.DrawTexturedRect(x * -1, y * -1, scrW, scrH) end end local Base = vgui.Create( "DFrame") Base:SetPos(500,0) Base:SetSize( 920, 1050 ) Base:SetDraggable( true ) Base:SetTitle( " " ) Base:ShowCloseButton(true) Base.Paint = function( self, w, h ) draw_Blur( self, 5 ) draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 160 ) ) end function scoreboard:hide() Base:Remove() end end function GM:ScoreboardShow() scoreboard:show() end function GM:ScoreboardHide() scoreboard:hide() end [/CODE] and the error... [CODE][ERROR] lua/test.lua:4: attempt to index global 'scoreboard' (a nil value) 1. unknown - lua/test.lua:4[/CODE]
Looks like you haven't defined scoreboard before creating the functions.
ive placed the following infront of the code... [CODE]scoreboard = scoreboard or {}[/CODE] and my error code has now turned to this [CODE][ERROR] lua/test.lua:34: attempt to index global 'GM' (a nil value) 1. unknown - lua/test.lua:34[/CODE]
Adding [lua]GM = GM or GAMEMODE[/lua] at the top will fix it I believe. Also if you're not making your own gamemode you should just use hooks. [lua]hook.Add("ScoreboardShow", "myuniqueid", function() -- do stuff end ) [/lua]
Sorry, you need to Log In to post a reply to this thread.