When running the code of my custom spawnmenu whitelister, gmod inexplicably crashes as soon as I open the spawnmenu. Here's the code:
[lua]function PropListFilter()
timer.Simple(0.1, function()
spawnmenu.PopulateFromEngineTextFiles()
local PropLists = {}
local SpawnIcons = {}
local MySpawnMenu = g_SpawnMenu
--local CreationMenu = MySpawnMenu.CreateMenu
--local CreationTabs = spawnmenu.GetCreationTabs()
--local PropTabTitle = controlpanel.Get("#spawnmenu.content_tab")
--local PropTab = CreationMenu:GetActiveTab():GetPanel()
--local PropTabContentPanel = PropTab:GetChildren()[1]
local PropTabContentPanel = MySpawnMenu.CreateMenu:GetActiveTab():GetPanel():GetChildren()[1]
local PropTabSideBar = MySpawnMenu.CreateMenu
if IsValid(PropTabContentPanel) then
if IsValid(PropTabContentPanel:GetChildren()[1]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[1]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
if IsValid(PropTabContentPanel:GetChildren()[1]:GetChildren()[1]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[1]:GetChildren()[1]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[1]:GetChildren()[2]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[1]:GetChildren()[2]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[2]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[2]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
if IsValid(PropTabContentPanel:GetChildren()[2]:GetChildren()[1]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[2]:GetChildren()[1]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[2]:GetChildren()[2]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[2]:GetChildren()[2]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[3]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[3]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
if IsValid(PropTabContentPanel:GetChildren()[3]:GetChildren()[1]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[3]:GetChildren()[1]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[3]:GetChildren()[2]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[3]:GetChildren()[2]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[4]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[4]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
if IsValid(PropTabContentPanel:GetChildren()[4]:GetChildren()[1]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[4]:GetChildren()[1]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
if IsValid(PropTabContentPanel:GetChildren()[4]:GetChildren()[2]) then
for k, v in pairs(PropTabContentPanel:GetChildren()[4]:GetChildren()[2]:GetChildren()) do
if v.ClassName == "DTileLayout" then
table.insert(PropLists, v)
end
end
end
end
end
for k, v in pairs(PropLists) do
table.Add(SpawnIcons, v:GetChildren())
end
for k, v in pairs(SpawnIcons) do
if v.ClassName == "SpawnIcon" then
if table.HasValue(propslist_Default, v:GetModelName()) then else
v:Remove()
local reformattingisdone = 1
end
end
end
SelectedNodeNewSpawnIcons = PropTabContentPanel.ContentNavBar.Tree:GetSelectedItem().PropPanel:GetChildren()[1]:GetChildren()[1]
for k, v in pairs(SelectedNodeNewSpawnIcons:GetChildren()) do
if v.ClassName == "SpawnIcon" then
if table.HasValue(propslist_Default, v:GetChild(1):GetModelName()) then else
--v:Remove()
end
end
end
end )
return true
end
hook.Add("SpawnMenuOpen", "SpawnMenu Whitelisting", PropListFilter)
hook.Add("ContentSidebarSelection", "New Section SpawnMenu Whitelisting", PropListFilter)
hook.Add( "SpawnlistContentChanged", "On Content Change SpawnMenu Whitelisting", PropListFilter)
hook.Add( "PopulateContent", "Test", PropListFilter)
if IsValid(PropTabContentPanel) then
end[/lua]
I have no idea what's causing this, but it started after I added this code to the end of the first function:
[lua] for k, v in pairs(SelectedNodeNewSpawnIcons:GetChildren()) do
if v.ClassName == "SpawnIcon" then
if table.HasValue(propslist_Default, v:GetChild(1):GetModelName()) then else
--v:Remove()
end
end
end[/lua]
Any help with this would be greatly appreciated. This is all located in the clientside files of my gamemode.
Sorry, you need to Log In to post a reply to this thread.