Okay i got this code:
[lua]
function players()
if playersenabled == 1 then
if enabled == 1 then
for _,v in ipairs (ents.FindByClass("player")) do -- Get players
local pos = v:GetPos() + Vector(0,0,90)
pos = pos:ToScreen()
color = team.GetColor(v:Team())
local Dist = math.floor(v:GetPos():Distance(LocalPlayer():GetPos()))
draw.DrawText(v:Name(), "ScoreboardText", pos.x, pos.y - 30, color,1)
if v.DarkRPVars and v.DarkRPVars.money then
local Money = v.DarkRPVars.money
draw.DrawText("Money: " .. Money .. "$", "ScoreboardText", pos.x, pos.y - 20, color,1)
end
--draw.DrawText("Distance: " .. Dist, "ScoreboardText", pos.x, pos.y - 10, color,1)
end
end
else
hook.Remove("HUDPaint", "players")
end
end
function menu()
DFrame1 = vgui.Create('DFrame')
DFrame1:SetSize(320, 380)
DFrame1:SetPos(10, 10)
DFrame1:SetTitle('Main Menu')
DFrame1:SetDeleteOnClose(false)
DFrame1:MakePopup()
chkPlayers = vgui.Create('DCheckBoxLabel')
chkPlayers:SetParent(DPanel1)
chkPlayers:SetPos(10, 30)
chkPlayers:SetText('Players')
chkPlayers:SetValue(playersenabled)
chkPlayers.DoClick = function() end
chkPlayers:SizeToContents()
btnOn = vgui.Create('DSysButton')
btnOn:SetParent(DPanel1)
btnOn:SetSize(70, 30)
btnOn:SetPos(10, 190)
btnOn:SetType('tick')
btnOn.DoClick = function()
enabled = 1
if chkPlayers.GetChecked(true) then
playersenabled = 1
hook.Add("HUDPaint", "goz3rr_players", players)
else
playersenabled = 0
end
end
concommand.Add("goz3rr_menu", menu)
[/lua]
And when i run it, open my little menu, check the checkbox and press the button it gives:
[lua\vgui\dcheckbox.lua:138] attempt to index local 'self' (a boolean value)
And when i open my menu again it's unchecked :|
Well whatever it is, it isn't in this code. There's no use of self in the code you provided or 138 lines of code.
[lua]if chkPlayers.GetChecked(true) then[/lua]
Should be
[lua]if chkPlayers:GetChecked() then[/lua]
[QUOTE=Dr Magnusson;27300121][lua]if chkPlayers.GetChecked(true) then[/lua]
Should be
[lua]if chkPlayers:GetChecked() then[/lua][/QUOTE]
Same error.
[QUOTE=-TB-;27299918]Well whatever it is, it isn't in this code. There's no use of self in the code you provided or 138 lines of code.[/QUOTE]
The error clearly says its in lua\vgui\dcheckbox.lua, which i haven't modified
[editline]9th January 2011[/editline]
Also example on wiki:
[lua]
if myCheckBox:GetChecked(true) then
myButton:SetText("YES!!!");
else
myButton:SetText("no :(");
end
[/lua]
Oh for some reason I thought that was your file. Your also trying to pass an argument to the function, take out true.
[CODE]
if myCheckBox:GetChecked() then
[/CODE]
That was already said, and i replied it was like that in the wiki example.
[editline]9th January 2011[/editline]
Also i get the error doesn't change if i check/uncheck the checkbox and then click button
This is only the part where the error is, i could show the whole 430 lines if you want
The current code has if myCheckBox:GetChecked(true) then changed to if myCheckBox:GetChecked() then
Try
[CODE]
if myCheckBox.Button:GetChecked() then
[/CODE]
I already did
Oh snap! How could i miss that! Thanks!
Also, if you look up the source of the GetChecked function you'll see that the argument actually doesn't do anything
[url]http://luabin.foszor.com/code/addons/derma/lua/vgui/DCheckBox.lua#137[/url]
Sorry, you need to Log In to post a reply to this thread.