I don't know what happened, but everything was working fine and suddenly this error popped up.
[code]
[ERROR] gamemodes/murder/gamemode/cl_scoreboard.lua:138: attempt to index local 'mlist' (a nil value)
1. doPlayerItems - gamemodes/murder/gamemode/cl_scoreboard.lua:138
2. unknown - gamemodes/murder/gamemode/cl_scoreboard.lua:178
[/code]
Very confused.... here's the rest of the code...
[code]
local menu
websites = {}
websites.main = "http://talongaming2.site.nfoservers.com/website/"
websites.donate = ""
websites.rules = ""
surface.CreateFont( "ScoreboardPlayer" , {
font = "coolvetica",
size = 32,
weight = 500,
antialias = true,
italic = farules
} )
surface.CreateFont( "TitleFont", {
font = "Arial",
size = 96,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont('404_Heading', { font = 'coolvetica', size = 35 })
surface.CreateFont('404_Connect', { font = 'coolvetica', size = 35 })
surface.CreateFont('404_Body', { font = 'calibri', size = 15 })
surface.CreateFont('404_Info', { font = 'calibri', size = 17 })
surface.CreateFont('404_ServerName', { font = 'calibri', size = 20 })
surface.CreateFont('404_ServerIP', { font = 'calibri', size = 12 })
surface.CreateFont('404_Heading2', { font = 'coolvetica', size = 200 })
function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
local muted = Material("icon32/muted.png")
local admin = Material("icon32/wand.png")
local function addPlayerItem(self, mlist, ply, pteam)
local but = vgui.Create("DButton")
but.player = ply
but.ctime = CurTime()
but:SetTall(40)
but:SetText("")
function but:Paint(w, h)
local showAdmins = GAMEMODE.RoundSettings.ShowAdminsOnScoreboard
if IsValid(ply) && ply:IsPlayer() then
local s = 0
if ply:IsMuted() then
surface.SetMaterial(muted)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(s + 4, h / 2 - 16, 32, 32)
s = s + 32
end
draw.DrawText(ply:Ping(), "ScoreboardPlayer", w - 11, 9, color_black, 2)
draw.DrawText(ply:Ping(), "ScoreboardPlayer", w - 10, 8, color_white, 2)
draw.DrawText(ply:Nick(), "ScoreboardPlayer", s + 11, 9, color_black, 0)
draw.DrawText(ply:Nick(), "ScoreboardPlayer", s + 10, 8, color_white, 0)
draw.DrawText(firstToUpper(ply:GetNWString("usergroup")), "ScoreboardPlayer", ScrW()/2.5, 9, color_black, TEXT_ALIGN_CENTER)
draw.DrawText(firstToUpper(ply:GetNWString("usergroup")), "ScoreboardPlayer", ScrW()/2.5, 8, color_white, TEXT_ALIGN_CENTER)
end
end
function but:DoClick()
GAMEMODE:DoScoreboardActionPopup(ply)
end
mlist:AddItem(but)
end
function GM:DoScoreboardActionPopup(ply)
local actions = DermaMenu()
if ply != LocalPlayer() then
local t = "Mute"
if ply:IsMuted() then
t = "Unmute"
end
local mute = actions:AddOption( t )
mute:SetIcon("icon16/sound_mute.png")
function mute:DoClick()
if IsValid(ply) then
ply:SetMuted(!ply:IsMuted())
end
end
end
if IsValid(LocalPlayer()) then
actions:AddSpacer()
if ply:Team() == 2 then
local spectate = actions:AddOption( "Move to " .. team.GetName(1) )
spectate:SetIcon( "icon16/status_busy.png" )
function spectate:DoClick()
RunConsoleCommand("mu_movetospectate", ply:EntIndex())
end
local force = actions:AddOption( "Force murderer next round" )
force:SetIcon( "icon16/delete.png" )
function force:DoClick()
RunConsoleCommand("mu_forcenextmurderer", ply:EntIndex())
end
if ply:Alive() then
local specateThem = actions:AddOption( "Spectate" )
specateThem:SetIcon( "icon16/status_online.png" )
function specateThem:DoClick()
RunConsoleCommand("mu_spectate", ply:EntIndex())
end
end
end
end
actions:Open()
end
local function doPlayerItems(self, mlist, pteam)
for k, ply in pairs(team.GetPlayers(pteam)) do
local found = false
for t,v in pairs(mlist:GetCanvas():GetChildren()) do
if v.player == ply then
found = true
v.ctime = CurTime()
end
end
if !found then
addPlayerItem(self, mlist, ply, pteam)
end
end
local del = false
for t,v in pairs(mlist:GetCanvas():GetChildren()) do
if v.ctime != CurTime() then
v:Remove()
del = true
end
end
-- make sure the rest of the elements are moved up
if del then
timer.Simple(0, function() mlist:GetCanvas():InvalidateLayout() end)
end
end
local function makeTeamList(parent, pteam)
local mlist
local chaos
local pnl = vgui.Create("DPanel", parent)
pnl:DockPadding(8,8,8,8)
function pnl:Paint(w, h)
surface.SetDrawColor(Color(255,255,255,255))
surface.DrawRect(0, 0, w - 4, 40)
surface.SetDrawColor(Color(50,50,50,100))
surface.DrawRect(0, 40, w - 4, h*0.5)
end
function pnl:Think()
if !self.RefreshWait || self.RefreshWait < CurTime() then
self.RefreshWait = CurTime() + 0.1
doPlayerItems(self, mlist, pteam)
// update chaos/control
if pteam == 2 then
-- chaos:SetText("Control: " .. GAMEMODE:GetControl())
else
-- chaos:SetText("Chaos: " .. GAMEMODE:GetChaos())
end
end
end
local headp = vgui.Create("DPanel", pnl)
headp:DockMargin(0,0,0,4)
-- headp:DockPadding(4,0,4,0)
headp:Dock(TOP)
function headp:Paint() end
local but = vgui.Create("DButton", headp)
but:Dock(RIGHT)
but:SetText("Join")
but:SetTextColor(color_white)
but:SetFont("Trebuchet18")
function but:DoClick()
RunConsoleCommand("mu_jointeam", pteam)
end
function but:Paint(w, h)
surface.SetDrawColor(team.GetColor(pteam))
surface.DrawRect(0, 0, w, h)
surface.SetDrawColor(255,255,255,10)
surface.DrawRect(0, 0, w, h * 0.45 )
surface.SetDrawColor(color_black)
surface.DrawOutlinedRect(0, 0, w, h)
if self:IsDown() then
surface.SetDrawColor(50,50,50,120)
surface.DrawRect(1, 1, w - 2, h - 2)
elseif self:IsHovered() then
surface.SetDrawColor(255,255,255,30)
surface.DrawRect(1, 1, w - 2, h - 2)
end
end
-- chaos = vgui.Create("DLabel", headp)
-- chaos:Dock(RIGHT)
-- chaos:DockMargin(0,0,10,0)
-- if pteam == 2 then
-- -- chaos:SetText("Control: " .. GAMEMODE:GetControl())
-- else
-- -- chaos:SetText("Chaos: " .. GAMEMODE:GetChaos())
-- end
-- function chaos:PerformLayout()
-- self:ApplySchemeSettings()
-- self:SizeToContentsX()
-- if ( self.m_bAutoStretchVertical ) then
-- self:SizeToContentsY()
-- end
-- end
-- chaos:SetFont("Trebuchet24")
-- chaos:SetTextColor(team.GetColor(pteam))
local head = vgui.Create("DLabel", headp)
slist:SetPos(4, -100)
head:SetText(team.GetName(pteam))
head:SetFont("Trebuchet24")
head:SetTextColor(team.GetColor(pteam))
head:Dock(FILL)
head:SetHeight(100)
mlist = vgui.Create("DScrollPanel", pnl)
mlist:Dock(NODOCK)
mlist:SetSize(sbWidth*0.7195, sbHeight*0.4755)
mlist:SetPos(4,40)
// child positioning
local canvas = mlist:GetCanvas()
function canvas:OnChildAdded( child )
child:Dock( TOP )
child:DockMargin( 0,0,0,4 )
end
return pnl
end
local function makeTeamListSpec(parent, pteam)
local mlist
local chaos
local pnl = vgui.Create("DPanel", parent)
pnl:DockPadding(8,8,8,8)
function pnl:Paint(w, h)
surface.SetDrawColor(Color(255,255,255,255))
surface.DrawRect(0, 0, w - 4, 40)
surface.SetDrawColor(Color(50,50,50,100))
surface.DrawRect(0, 40, w - 4, h*0.5)
end
function pnl:Think()
if !self.RefreshWait || self.RefreshWait < CurTime() then
self.RefreshWait = CurTime() + 0.1
doPlayerItems(self, slist, pteam)
// update chaos/control
if pteam == 2 then
-- chaos:SetText("Control: " .. GAMEMODE:GetControl())
else
-- chaos:SetText("Chaos: " .. GAMEMODE:GetChaos())
end
end
end
local headp = vgui.Create("DPanel", pnl)
headp:DockMargin(0,0,0,4)
-- headp:DockPadding(4,0,4,0)
headp:Dock(TOP)
function headp:Paint() end
Line 279, you are using slist instead of mlist as the argument. You never defined slist though. There are also a few other uses of slist in the file.
[QUOTE=syl0r;44574296]Line 279, you are using slist instead of mlist as the argument. You never defined slist though. There are also a few other uses of slist in the file.[/QUOTE]
Thanks for pointing this out, but the same error still occurs after fixing that . . .
Post the new error.
In line 178 you are calling the same function with mlist, mlist is a local variable that hasn't been initialized though (and therefore is null).
the error is exactly the same and the mlist on line 178 has a local mlist connected to it. they are in the same function :P
[QUOTE=WolfNinja2;44579123]the error is exactly the same and the mlist on line 178 has a local mlist connected to it. they are in the same function :P[/QUOTE]
You just do
[code]
local mlist
[/code]
And then you call your function with this nil value as a parameter :/
[QUOTE=DEFCON1;44579354]You just do
[code]
local mlist
[/code]
And then you call your function with this nil value as a parameter :/[/QUOTE]
uhm... no. I call a function with a EMPTY parameter, that then gets UN-EMPTIED by the function. Nil means non existent, not empty. :::///
You can't pass by reference in Lua...
Sorry, you need to Log In to post a reply to this thread.