Hello,
im getting this really annoying error which doesn't make sense to me,
it's in bright yellow and goes as follows:
[code]
[NG] MerK|39|STEAM_0:0:44038311] Lua Error:
[ERROR] addons/merksantiafk/lua/autorun/client/cl_antiafk.lua:10: attempt to index local 'Payy' (a nil value)
1. unknown - addons/merksantiafk/lua/autorun/client/cl_antiafk.lua:10
[/code]
this is the code:
[code]
local w = ScrW()
local h = ScrH()
local Payy = vgui.Create("DFrame")
Payy:SetPos(0, 0)
Payy:SetSize(w, h)
Payy:SetTitle( "" )
Payy:SetVisible( true )
Payy:ShowCloseButton( false )
Payy:SetDeleteOnClose()
function Payy:Paint(w, h)
draw.RoundedBox( 0, 0, 0, w, h, Color( 0,0,0,200 ) )
end
local Payyy = vgui.Create("DFrame")
Payyy:SetPos(ScrW() / 2 - 400, ScrH() / 2 - 150)
Payyy:SetSize(800, 300)
Payyy:SetTitle( "" )
Payyy:ShowCloseButton( false )
Payyy:SetVisible( true )
Payyy:SetDeleteOnClose( false )
Payyy:SetDraggable( false )
Payyy:MakePopup( true )
function Payyy:Paint(w, h)
draw.RoundedBox( 15, 0, 0, 800, 300, Color( 0,0,0,220 ) )
end
DermaImage = vgui.Create( "DImage", Payyy )
DermaImage:SetSize(800, 400)
DermaImage:SetImage("images/merks/afkbg.png")
Payy:Close()
Payyy:Close()[/code]
Thanks for any help :)
I think it's because you're localizing the variable Payy, instead use [lua]Payy.Paint = function( panel, w, h )
...
end[/lua]
[QUOTE=Internet1001;44933698]I think it's because you're localizing the variable Payy, instead use [lua]Payy.Paint = function( panel, w, h )
...
end[/lua][/QUOTE]
I added local since i thought that might be causing it, but i removed it now
[editline]28th May 2014[/editline]
I just noticed a bit higher up in the console it says the error again (in normal yellow) with this message above it:
Warning: vgui.Create failed to create the VGUI component (DFrame)
[editline]28th May 2014[/editline]
I'm guessing it is because it loads the file too soon, i put a timer which loads the whole script only after 5 seconds and it works,
is there any better way to do this?
Hook your function that creates all the derma elements to an "InitPostEntity" hook
[lua]hook.Add( "InitPostEntity", "MyHookName", functionNameWithNoParentheses )[/lua]
Sorry, you need to Log In to post a reply to this thread.