Every time I search for an item in the spawn menu it continuously duplicates the search results and creates script errors
The error it keeps giving:
[ERROR] gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua:99: attempt to index field 'icon' (a nil value)
1. RefreshResults - gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua:99
2. fn - gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua:65
3. Run - addons/ulib/lua/ulib/shared/hook.lua:110
4. unknown - gamemodes/sandbox/gamemode/cl_search_models.lua:41
Timer Failed! [search_models_update][@gamemodes/sandbox/gamemode/cl_search_models.lua (line 41)]
What it looks like:
[IMG]https://cdn.discordapp.com/attachments/294702829388431360/339226259903217664/Screenshot_54.png[/IMG]
Thanks for reading
Do you have a lot of mods? I'd like to know what can possibly cause this.
Is this singleplayer? Are there any other errors in the console?
[QUOTE=Robotboy655;52505569]Do you have a lot of mods? I'd like to know what can possibly cause this.
Is this singleplayer? Are there any other errors in the console?[/QUOTE]
i have almost 200 mods but none of them have anything to do with the spawn menu. it also started happening when i was offline unable to download mods
it happens when im in a listen and multiplayer server
the only error im getting in console is the one i posted
Alright do this for me:
Go to the file gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua
And put this in between lines 98 and 99:
[code]
if ( !IsValid( result.icon ) ) then PrintTable( result ) end
[/code]
So it looks like this:
[code]
local results = search.GetResults( str )
for id, result in pairs( results ) do
if ( !IsValid( result.icon ) ) then PrintTable( result ) end
result.icon:SetParent( GetHUDPanel() ) -- Don't parent the icons to search panel prematurely
end
[/code]
Then go to singleplayer and try this again. As soon as any errors pop up, just paste the entire console log here in between [code] [/ code] tags
[QUOTE=Robotboy655;52505925]Alright do this for me:
Go to the file gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua
And put this in between lines 98 and 99:
[code]
if ( !IsValid( result.icon ) ) then PrintTable( result ) end
[/code]
So it looks like this:
[code]
local results = search.GetResults( str )
for id, result in pairs( results ) do
if ( !IsValid( result.icon ) ) then PrintTable( result ) end
result.icon:SetParent( GetHUDPanel() ) -- Don't parent the icons to search panel prematurely
end
[/code]
Then go to singleplayer and try this again. As soon as any errors pop up, just paste the entire console log here in between [code] [/ code] tags[/QUOTE]
this is what i got
[code] func = function: 0x6b811658
text = cbtree5_big.mdl
words:
1 = models/cbtree5_big.mdl
[ERROR] gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua:100: attempt to index field 'icon' (a nil value)
1. RefreshResults - gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua:100
2. fn - gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contentsearch.lua:65
3. Run - addons/ulib/lua/ulib/shared/hook.lua:110
4. unknown - gamemodes/sandbox/gamemode/cl_search_models.lua:41
Timer Failed! [search_models_update][@gamemodes/sandbox/gamemode/cl_search_models.lua (line 41)] [/code]
Alright.
[code]function PANEL:RefreshResults( str )
if ( !str ) then -- User tried to search for something
CurrentSearch = self.Search:GetText()
str = CurrentSearch
OldResults = -1
else
-- Don't force open the search when you click away from search while this function is called from cl_search_models.lua
if ( ContentPanel.SelectedPanel != self.PropPanel ) then
return
end
end
if ( !str or str == "" ) then return end
local results = search.GetResults( str )
for id, result in pairs( results ) do
if ( !IsValid( result.icon ) ) then print( "====================") PrintTable( result ) print( "====================") continue end
result.icon:SetParent( GetHUDPanel() ) -- Don't parent the icons to search panel prematurely
end
print( OldResults == #results )
-- I know this is not perfect, but this is the best I am willing to do with how the search library was set up
if ( OldResults == #results ) then -- No updates, don't rebuild
for id, result in pairs( results ) do
if ( IsValid( result.icon ) ) then result.removedicon = true result.icon:Remove() end -- Kill all icons
end
return
end
OldResults = #results
self.PropPanel:Clear()
local Header = self:Add( "ContentHeader" )
Header:SetText( #results .. " Results for \"" .. str .. "\"" )
self.PropPanel:Add( Header )
for k, v in pairs( results ) do
self:AddSearchResult( v.text, v.func, v.icon )
end
self.PropPanel:SetParent( ContentPanel )
ContentPanel:SwitchPanel( self.PropPanel )
end[/code]
I want you to replace the function "function PANEL:RefreshResults( str )" (Lines 82 to 122) in your copy to the one above.
Then try the search again. This should fix your problem (for singleplayer only), but I still want you to do something for me, to understand what is happening and hopefully fix it for everyone.
After the search finishes ( when the blue bar on the top disappears ), please type the following in your console:
whereis models/cbtree5_big.mdl
And then please post the console log (all of it) here.
[QUOTE=Robotboy655;52507113]Alright.
[code]function PANEL:RefreshResults( str )
if ( !str ) then -- User tried to search for something
CurrentSearch = self.Search:GetText()
str = CurrentSearch
OldResults = -1
else
-- Don't force open the search when you click away from search while this function is called from cl_search_models.lua
if ( ContentPanel.SelectedPanel != self.PropPanel ) then
return
end
end
if ( !str or str == "" ) then return end
local results = search.GetResults( str )
for id, result in pairs( results ) do
if ( !IsValid( result.icon ) ) then print( "====================") PrintTable( result ) print( "====================") continue end
result.icon:SetParent( GetHUDPanel() ) -- Don't parent the icons to search panel prematurely
end
print( OldResults == #results )
-- I know this is not perfect, but this is the best I am willing to do with how the search library was set up
if ( OldResults == #results ) then -- No updates, don't rebuild
for id, result in pairs( results ) do
if ( IsValid( result.icon ) ) then result.removedicon = true result.icon:Remove() end -- Kill all icons
end
return
end
OldResults = #results
self.PropPanel:Clear()
local Header = self:Add( "ContentHeader" )
Header:SetText( #results .. " Results for \"" .. str .. "\"" )
self.PropPanel:Add( Header )
for k, v in pairs( results ) do
self:AddSearchResult( v.text, v.func, v.icon )
end
self.PropPanel:SetParent( ContentPanel )
ContentPanel:SwitchPanel( self.PropPanel )
end[/code]
I want you to replace the function "function PANEL:RefreshResults( str )" (Lines 82 to 122) in your copy to the one above.
Then try the search again. This should fix your problem (for singleplayer only), but I still want you to do something for me, to understand what is happening and hopefully fix it for everyone.
After the search finishes ( when the blue bar on the top disappears ), please type the following in your console:
whereis models/cbtree5_big.mdl
And then please post the console log (all of it) here.[/QUOTE]
now its just serching infinitely and spamming this in console
[code] ====================
func = function: 0x690ee748
text = light_streetlight.mdl
words:
1 = models/props/de_inferno/light_streetlight.mdl
====================
====================
func = function: 0x6f0fd620
text = tree_group.mdl
words:
1 = models/props/de_inferno/tree_group.mdl
====================
====================
func = function: 0x689f8f88
text = tree_large.mdl
words:
1 = models/props/de_inferno/tree_large.mdl
====================
====================
func = function: 0x1ac70a18
text = tree_small.mdl
words:
1 = models/props/de_inferno/tree_small.mdl
====================
====================
func = function: 0x62af5d38
text = tides_streetlight.mdl
words:
1 = models/props/de_tides/tides_streetlight.mdl
====================
====================
func = function: 0x6f10f038
text = tree.mdl
words:
1 = models/props/dossf/tree.mdl
====================
====================
func = function: 0x6ddf7c28
text = tree.mdl
words:
1 = models/props/gtasf/tree.mdl
====================
====================
func = function: 0x6b49ef50
text = oh_xmas_tree_demo.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_demo.mdl
====================
====================
func = function: 0x6b871e48
text = oh_xmas_tree_engineer.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_engineer.mdl
====================
====================
func = function: 0x6e922260
text = oh_xmas_tree_heavy.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_heavy.mdl
====================
====================
func = function: 0x7044e0e8
text = oh_xmas_tree_medic.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_medic.mdl
====================
====================
func = function: 0x6e26c070
text = oh_xmas_tree_pyro.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_pyro.mdl
====================
====================
func = function: 0x6901b558
text = oh_xmas_tree_scout.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_scout.mdl
====================
====================
func = function: 0x6e6c1998
text = oh_xmas_tree_sniper.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_sniper.mdl
====================
====================
func = function: 0x6df58330
text = oh_xmas_tree_soldier.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_soldier.mdl
====================
====================
func = function: 0x6c2750e0
text = oh_xmas_tree_spy.mdl
words:
1 = models/player/items/all_class/oh_xmas_tree_spy.mdl
====================
true [/code]
It's not searching infinitely, the bar going the opposite direction is normal as the game finds more folders to scan. It all hugely depends on the amount of models your game has installed.
You can replace the line 99 with the following to stop the spam:
[code]
if ( !IsValid( result.icon ) ) then continue end
[/code]
If you still want to help, since those models will not appear in your search results, to figure out why that happens, go to your lua/includes/modules/spawnmenu.lua and replace lines 240-245 with the following and post the full console log after the search is finished.
[code]
function CreateContentIcon( type, parent, tbl )
local cp = GetContentType( type )
if ( cp ) then
local ico = cp( parent, tbl )
if ( !IsValid( ico ) ) then print( "CreateContentIcon - FAILED TO CREATE ICON ", type, parent ) PrintTable( tbl ) end
return ico
else
print( "CreateContentIcon - NO TYPE ", type, parent, tbl )
end
end[/code]
Sorry, you need to Log In to post a reply to this thread.