Need help fixing the glitch with panels im pcmod2.
[code][addons\pcmod2\lua\pcmod\cl_gui.lua:275] attempt to get length of field 'Panels' (a nil value) [/code]
pcmod2 cl_gui
[code]
// ---------------------------------------------------------------------------------------------------------
// cl_gui.lua - Revision 1
// Client-Side
// Controls drawing operations on the client
// ---------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------
// Define our library
// ---------------------------------------------------------------------------------------------------------
PCMod.Gui = {}
PCMod.Gui.Version = "1.0"
PCMod.SelEntity = 0
PCMod.Gui.MouseDown = false
PCMod.Gui.DebugBoxes = {}
PCMod.Gui.Themes = {}
PCMod.Gui.CamLocked = false
PCMod.Gui.CamLockID = 0
PCMod.Msg( "Gui Library Loaded (V" .. PCMod.Gui.Version .. ")", true )
// ---------------------------------------------------------------------------------------------------------
// Load all themes
// ---------------------------------------------------------------------------------------------------------
function PCMod.LoadTheme( id )
THEME = {}
local fn = "pcmod/themes/" .. id
THEME.FileName = fn
THEME.Name = "base"
THEME.Description = "Base theme"
THEME.Author = "[GU]thomasfn"
include( fn )
PCMod.Gui.Themes[ THEME.Name ] = table.Copy( THEME )
PCMod.Msg( "Theme '" .. THEME.Name .. "' loaded!", true )
end
local ths = file.FindInLua( "pcmod/themes/cl_*" )
if ((!ths) || (#ths == 0)) then
PCMod.Warning( "No themes to load!" )
else
for _, v in pairs( ths ) do
THEME = {}
PCMod.LoadTheme( v )
end
end
concommand.Add( "pc_theme_reload", function( pl, com, args ) PCMod.LoadTheme( args[1] ) ; end )
// ---------------------------------------------------------------------------------------------------------
// GetThemeColour - Gets the colour value that a theme specifies
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.GetThemeColour( themename, key, default )
if (!PCMod.Gui.Themes[ themename ]) then return default end
return PCMod.Gui.Themes[ themename ][ key ] or default
end
// ---------------------------------------------------------------------------------------------------------
// ThemeDraw - Calls a theme draw hook
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.ThemeDraw( themename, ... )
if (!PCMod.Cfg.HighQuality) then return end
if (!PCMod.Gui.Themes[ themename ]) then return end
if (!PCMod.Gui.Themes[ themename ].Draw) then return end
return PCMod.Gui.Themes[ themename ]:Draw( ... )
end
// ---------------------------------------------------------------------------------------------------------
// SURFACE: DrawOutline - Draws an unfilled box
// ---------------------------------------------------------------------------------------------------------
function surface.DrawOutline( x, y, w, h, col )
if (col) then surface.SetDrawColor( col.r, col.g, col.b, col.a ) end
surface.DrawLine( x, y, x+w, y ) -- Top Line
surface.DrawLine( x, y+h, x+w, y+h ) -- Bottom Line
surface.DrawLine( x, y, x, y+h ) -- Left Line
surface.DrawLine( x+w, y, x+w, y+h ) -- Right Line
end
// ---------------------------------------------------------------------------------------------------------
// InitFonts - Creates all the fonts we need
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.InitFonts()
PCMod.Msg( "Creating fonts...", true )
surface.CreateFont( "Tahoma", 20, 400, true, false, "pcmod_3d2d" )
end
hook.Add( "Initialize", "PCMod.Gui.InitFonts", PCMod.Gui.InitFonts )
// ---------------------------------------------------------------------------------------------------------
// DrawSelEnt - Draws information for the selected entity to the screen
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.DrawSelEnt()
if (PCMod.SelEntity == 0) then return end -- No entity = no draw
local ent = ents.GetByIndex( PCMod.SelEntity ) -- Get the entity
if ((!ent) || (!ent:IsValid())) then return end -- Check it's validness
// Get the draw coords
local origin = ent:GetPos():ToScreen()
// Tell the ent to draw
if (ent.DrawInfo) then ent:DrawInfo( origin ) end
// Clear the stored entity
PCMod.SelEntity = 0
end
hook.Add( "HUDPaint", "PCMod.Gui.DrawSelEnt", PCMod.Gui.DrawSelEnt )
// ---------------------------------------------------------------------------------------------------------
// DrawWirelessLinks - Draws lines between wireless entities
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.DrawWirelessLinks( ent )
if (!PCMod.Cfg.WirelessInfo) then return end
// Get all entities in range
local range = PCMod.Cfg.WirelessRange
local elist = {}
if (range > 0) then
elist = ents.FindInSphere( ent:GetPos(), range )
else
elist = ents.FindByClass( ent:GetClass() )
end
// Calculate starting position
local startpos = ent:GetPos():ToScreen()
// Cycle through and draw when needed
local col = PCMod.Cfg.WirelessInfoDrawCol
surface.SetDrawColor( col.r, col.g, col.b, col.a )
local offs = 0
for _, v in pairs( elist ) do
if ((v) && (v:IsValid()) && (v.IsPCMod) && (v != ent)) then
if (v:GetGVar( "wireless" )) then
local endpos = v:GetPos():ToScreen()
if (math.IsOnScreen( endpos )) then
surface.DrawLine( startpos.x, startpos.y, endpos.x, endpos.y )
else
offs = offs + 1
end
end
end
end
if (offs > 0) then
// There are 'offs' many wireless links not drawn, what to do with this info??? -thomasfn
end
end
// ---------------------------------------------------------------------------------------------------------
// EnableScreenClicker - Override, we don't want to turn off the mouse whilst we are locked!
// ---------------------------------------------------------------------------------------------------------
if (!gui.ESC) then
gui.ESC = gui.EnableScreenClicker
function gui.EnableScreenClicker( enabled )
if ((PCMod) && (PCMod.Gui)) then
if (PCMod.Gui.CamLocked) then enabled = true end
end
gui.ESC( enabled )
end
end
// ---------------------------------------------------------------------------------------------------------
// ShowDocument - Shows a printed document on the screen
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.ShowDocument( str )
PCMod.Msg( "Showing printed document! (" .. str .. ")", true )
if (PCMod.Gui.PDoc) then
PCMod.Gui.PDoc:Remove()
PCMod.Gui.PDoc = nil
end
local pn = vgui.Create( "PrintedDoc" )
if (!pn) then return end
pn:SetText( str, "ScoreboardText" )
pn:SetVisible( true )
PCMod.Gui.PDoc = pn
gui.EnableScreenClicker( true )
end
PCMod.Beam.Hook( "docu_info", PCMod.Gui.ShowDocument )
// ---------------------------------------------------------------------------------------------------------
// HideDocument - Hides a printed document on the screen
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.HideDocument()
if (PCMod.Gui.PDoc) then
PCMod.Gui.PDoc:Remove()
PCMod.Gui.PDoc = nil
end
gui.EnableScreenClicker( false )
end
// ---------------------------------------------------------------------------------------------------------
// PopupNotice - Pops up a notice window
// ---------------------------------------------------------------------------------------------------------
function PCMod.Gui.PopupNotice( title, text )
if (PCMod.Gui.Popup) then
PCMod.Gui.Popup:Remove()
PCMo
This issue has been fixed several times on the forums, you should have searched,
change line 274 to local pn = dm:GetItems()[#dm:GetItems()]
Okay i will try this, and i also searched for this issue i knew it was very common, but i couldnt find anything on it.
Sorry, you need to Log In to post a reply to this thread.