• Help fixing some code
    17 replies, posted
Hey Guys I was wondering if anyone could help fix some code with my basewars gamemode. Here are the errors I'm getting: [code] Warning: vgui.Create failed to create the VGUI component (GMS_TribeMenu) [ERROR] gamemodes/basewars/gamemode/cl_init.lua:1925: attempt to index field 'TribeMenu' (a nil value) 1. unknown - gamemodes/basewars/gamemode/cl_init.lua:1925 2. unknown - lua/includes/modules/concommand.lua:69 [/code] [code] [ERROR] gamemodes/basewars/gamemode/cl_helpvgui.lua:6: '}' expected (to close '{' at line 3) near '"Words"' 1. unknown - gamemodes/basewars/gamemode/cl_helpvgui.lua:0 [/code] And here are the files in question: [url]https://dl.dropboxusercontent.com/u/43729201/cl_helpvgui.lua[/url] [url]https://dl.dropboxusercontent.com/u/43729201/cl_init.lua[/url] If anyone could help it would be greatly appreciated. Thanks Hamish
1. TribeMenu isn't defined anywhere. 2. "Words" should have commas at the end because it's in a table.
Thanks for your reply. Where and how do I define it?
Is TribeMenu anywhere else in the code besides GMS_TribeMenu? The GMS_TribeMenu is registered in the cl_helpvgui, but I couldn't find TribeMenu anywhere.
The Tribes System code is also located in the init.lua. Here you go: [url]https://dl.dropboxusercontent.com/u/43729201/init.lua[/url]
I said TribeMenu, not tribes system.
Yeah I was meaning the complete Tribes System was in all three of those files. TribeMenu is not located in anything else.
Alright so TribeMenu isn't defined, what code would I write to define it?
Why are you calling it GM. instead of GM: ? Typically when you call a function using . it will make the first argument self followed by the other arguments. [lua]/*--------------------------------------------------------- Tribe menu ---------------------------------------------------------*/ function GM.OpenTribeMenu() local GM = GAMEMODE if !GM.TribeMenu then GM.TribeMenu = vgui.Create("GMS_TribeMenu") end GM.TribeMenu:SetVisible(!GM.TribeMenu:IsVisible()) end concommand.Add("bw_factionmenu",GM.OpenTribeMenu)[/lua] becomes [lua]/*--------------------------------------------------------- Tribe menu ---------------------------------------------------------*/ function GM:OpenTribeMenu() if !self.TribeMenu then self.TribeMenu = vgui.Create("GMS_TribeMenu") end -- Although if GMS_TribeMenu doesn't exist, the other call will error giving the error you had. self.TribeMenu:SetVisible(!self.TribeMenu:IsVisible()) end concommand.Add("bw_factionmenu",function( ) hook.Call( "OpenTribeMenu", GAMEMODE ); end )[/lua]
I have little to none knowledge of LUA and Garrysmod. I thought I'd take a shot at fixing up a friends gamemode for my server. Everything works except this.
You shoved some code from GMod Stranded into basewars and expect it to work? :v:
As far as I know this is a private gamemode. I took no part in creating it.
It's not that it's undefined. If you look, [code]Warning: vgui.Create failed to create the VGUI component (GMS_TribeMenu)[/code] GMS_TribeMenu (conveniently located where your second error is) wasn't being registered. i.e. Fixing your second error fixes your first error as well.
[QUOTE=KingofBeast;44263128]It's not that it's undefined. If you look, [code]Warning: vgui.Create failed to create the VGUI component (GMS_TribeMenu)[/code] GMS_TribeMenu (conveniently located where your second error is) wasn't being registered. i.e. Fixing your second error fixes your first error as well.[/QUOTE] I was talking about GM:TribeMenu, not GMS_TribeMenu.
[QUOTE=KingofBeast;44263128]It's not that it's undefined. If you look, [code]Warning: vgui.Create failed to create the VGUI component (GMS_TribeMenu)[/code] GMS_TribeMenu (conveniently located where your second error is) wasn't being registered. i.e. Fixing your second error fixes your first error as well.[/QUOTE] Thanks, did not realise that. Upon testing the menu opens but looking in the console I get: Warning: Unhandled usermessage 'opentrailmenu'
[QUOTE=code_gs;44263146]I was talking about GM:TribeMenu, not GMS_TribeMenu.[/QUOTE] GM.TribeMenu was being set to the panel returned from vgui.Create("GMS_TribeMenu"). GMS_TribeMenu wasn't registered because of the second error occurring in the vgui file. So what I was saying that by fixing the second error, GM.TribeMenu would no longer be undefined. As for that unhandled usermessage, it's unrelated to this issue.
Alright, how would I go about dealing with it?
You'll need to find what function on the client handles this "trail menu", then the code will go like this: [code]usermessage.Hook("opentrailmenu", function(um) *THAT FUNCTION()* end)[/code]
Sorry, you need to Log In to post a reply to this thread.