My first scoreboard , attempt to index local 'ply' .
1 replies, posted
Hello. Please help me. This is my first script on lua,and i have a trouble with him.
Lua interpreter has writing error on 46 line.
[lua]AddCSLuaFile( "sky_board.lua" );
local Menu = {}
local Frame
function Menu.Open(ply)
surface.CreateFont ("coolvetica", 32, 400, true, false, "ScoreBoardHost")
Frame = vgui.Create('DPanel')
Frame:SetSize(600, 500)
Frame:Center()
Frame:MakePopup()
Frame:Clear(true)
Frame.Paint = function()
surface.SetDrawColor( 0, 0, 0, 0 )
end
local x, y = Frame:GetPos()
local Host = vgui.Create('DPanel',Frame)
Host:SetSize(555, 60)
Host:SetPos(x+25,y+25)
Host:MakePopup()
Host.Paint = function()
draw.RoundedBox ( 10, 0, 0, 555, 60, Color( 14, 150, 240, 200 ))
end
local DLabel = vgui.Create('DLabel',Host)
DLabel:SetPos(25,15)
DLabel:SetFont("ScoreBoardHost")
DLabel:SetText(GetHostName())
DLabel:SizeToContents()
DLabel:SetColor(Color(255,40,40,255))
local function Update(ply)
local DermaListView = vgui.Create("DListView")
DermaListView:SetParent(Frame)
DermaListView:SetPos(25, 100)
DermaListView:SetSize(555, 385)
DermaListView:SetMultiSelect(false)
DermaListView:AddColumn("Name")
DermaListView:AddColumn("Props")
DermaListView:AddColumn("Kills")
DermaListView:AddColumn("Deaths")
DermaListView:AddColumn("Ping")
if ply:IsAdmin() then
DermaListView.OnRowSelected = function( panel , line )
local MenuButtonOptions = DermaMenu()
MenuButtonOptions:AddOption("Kick", function() Msg(panel:GetLine(line):GetValue(6)) end )
MenuButtonOptions:AddOption("Ban 1h", function() Msg(panel:GetLine(line):GetValue(6)) end )
MenuButtonOptions:AddOption("Perm ban", function() Msg(panel:GetLine(line):GetValue(6)) end )
MenuButtonOptions:Open()
end
end
DermaListView.Paint = function()
draw.RoundedBox ( 10, 0, 0, DermaListView:GetWide(), DermaListView:GetTall(), Color( 50, 50, 50, 150 ))
end
for k,v in pairs(player.GetAll()) do
DermaListView:AddLine(v:Nick(),v:GetCount( "props" ) + v:GetCount( "ragdolls" ) + v:GetCount( "effects" ),v:Frags(),v:Deaths(),v:Ping(),v:SteamID())
end
end
Update(ply)
end
function Menu.Close()
if Frame and Frame:IsValid() then
Frame:Remove()
gui.EnableScreenClicker(false)
end
end
timer.Simple(1.5, function(ply)
function GAMEMODE.ScoreboardShow()
Menu.Open(ply)
gui.EnableScreenClicker(true)
gui.SetMousePos( ScrW()/2, ScrH()/2 )
end
function GAMEMODE.ScoreboardHide()
Menu.Close()
end
end)[/lua]
Use [lua] tags please, and try replacing the ply with LocalPlayer()
Sorry, you need to Log In to post a reply to this thread.