Hi people, I've got some more dummy questions for you.
[CODE]function GM:ScoreboardShow ()
sb_base = vgui.Create ("DPanel")
sb_base:SetSize (1000, 700)
sb_base:Center ()
sb_base.Paint = function (self, w, h)
draw.RoundedBox (0, 0, 0, w, h, CGS200)
end
end
function GM:ScoreboardHide ()
sb_base:Remove ()
end[/CODE]
It tells me
[QUOTE][ERROR] addons/socam/lua/vgui/cl_com_scoreboard.lua:1: attempt to index global 'GM' (a nil value)
1. unknown - addons/socam/lua/vgui/cl_com_scoreboard.lua:1[/QUOTE]
After that I managed to look to another scoreboard addon and replaced GM: with GAMEMODE. .
But this works only from second run - that means that I have the same error (GAMEMODE is a nil value now) just after I connect to the server, but after I refresh the .lua file manually it works fine.
Sorry if I made a bad explanation of the problem, I'll be happy to answer any question or to see any advise!
Do "local GM = GM or GAMEMODE" at the top of the file. Also, make your sb_base local to the file.
[lua]
local GM = gmod.GetGamemode()
[/lua]
[QUOTE=code_gs;52206444]Do "local GM = GM or GAMEMODE" at the top of the file. Also, make your sb_base local to the file.[/QUOTE]
Thanks for the reply, but:
1) If I make sb_base local the second function isn't able to see it
[ERROR] addons/socam/lua/vgui/cl_com_scoreboard.lua:23: attempt to index global 'sb_base' (a nil value)
1. unknown - addons/socam/lua/vgui/cl_com_scoreboard.lua:23
2) The problem stays as it was before:
[ERROR] addons/socam/lua/vgui/cl_com_scoreboard.lua:3: attempt to index local 'GM' (a nil value)
1. unknown - addons/socam/lua/vgui/cl_com_scoreboard.lua:3
The code:
[CODE]local GM = GM or GAMEMODE
function GM:ScoreboardShow ()
sb_base = vgui.Create ("DPanel")
sb_base:SetSize (1000, 700)
sb_base:Center ()
sb_base.Paint = function (self, w, h)
draw.RoundedBox (0, 0, 0, w, h, CGS20) -- CGS20 = Color (20,20,20)
end
end
function GM:ScoreboardHide ()
sb_base:Remove ()
end[/CODE]
[editline]9th May 2017[/editline]
[QUOTE=MeepDarknessM;52206457][lua]
local GM = gmod.GetGamemode()
[/lua][/QUOTE]
It didn't help, unfortunately :(
You make sb_base local to the FILE, not the function.
[editline]9th May 2017[/editline]
Try putting this in a PostGamemodeLoaded or Initialize hook.
[QUOTE=code_gs;52206501]You make sb_base local to the FILE, not the function.
[editline]9th May 2017[/editline]
Try putting this in a PostGamemodeLoaded or Initialize hook.[/QUOTE]
Thanks, now it works fine. But the main question is still actual D:
And how does default scoreboard work so it uses simple GM:Scoreboard functions, without GM manipulations or anything like that?
[QUOTE=MediCat;52206511]Thanks, now it works fine. But the main question is still actual D:
And how does default scoreboard work so it uses simple GM:Scoreboard functions, without GM manipulations or anything like that?[/QUOTE]
Because its normally in a gamemode file which provides the GM table in that instance. You are trying to make it an addon instead of a gamemode component, and while you would normally use the hook library, scoreboards are the exception in which you would want to override gamemode behaviour.
you know you can override scoreboards by returning any non nil value in a hook right, you don't need to override the gamemode table
[QUOTE=MeepDarknessM;52206753]you know you can override scoreboards by returning any non nil value in a hook right, you don't need to override the gamemode table[/QUOTE]
Then you would be interfering with any hooks that are using the event for any non-overriding purposes.
[QUOTE=code_gs;52206827]Then you would be interfering with any hooks that are using the event for any non-overriding purposes.[/QUOTE]
why would anyone that isn't overriding scoreboard hooks need to listen?
[QUOTE=MeepDarknessM;52206912]why would anyone that isn't overriding scoreboard hooks need to listen?[/QUOTE]
Theoretically, people could use it to know when the scoreboard was open for whatever reason.
[QUOTE=MeepDarknessM;52206753]you know you can override scoreboards by returning any non nil value in a hook right, you don't need to override the gamemode table[/QUOTE]
Thank you darling, it works completely fine now :*
Sorry, you need to Log In to post a reply to this thread.