• attempt to index global 'vgui' (a nil value)
    8 replies, posted
flerpes\gamemode\shared.lua:56: attempt to index global 'vgui' (a nil value) [lua] local WepMenu = nil function GM:ShowWepMenu() if ( !IsValid( WepMenu ) ) then if ( WepMenu ) then WepMenu:Remove() end WepMenu = vgui.CreateFromTable( vgui_Splash ) WepMenu:SetHeaderText( "Choose your weapon!" ) WepMenu:SetHoverText( "Select all your weapons and powerups here." ) local Button = WepMenu:AddSelectButton( "Shotgun test", LocalPlayer():Give( "weapon_shotgun" ) ) Button.m_colBackground = Color(255, 90, 90, 255) local function2 = function() LocalPlayer():GiveAmmo( 30, "buckshot" ) end local Button2 = WepMenu:AddSelectButton( "Shotgun Ammo", function2 ) Button2.m_colBackground = Color(255, 90, 90, 255) Button2.Think = function( self ) self:SetDisabled( !LocalPlayer():HasWeapon( "weapon_shotgun" ) ) end WepMenu:AddCancelButton() end WepMenu:MakePopup() end concommand.Add( "WepMenu", GM:ShowWepMenu() ) [/lua] What am I doing wrong? From what I can gather from searches I need to include some vGUI stuff somewhere, but where and what?
Put it in a clientside Lua file, not a shared one. [editline]04:02PM[/editline] vgui is client only.
I moved it to cl_init.lua but now I get this: [code] Lua initialized (Lua 5.1) Registering gamemode 'fretta' derived from 'base' Registering gamemode 'flerpes' derived from 'fretta' ScriptEnforce is disabled Executing listen server config file exec: couldn't exec listenserver.cfg InitFastCopy: only 51% fast props. Bug? Lua initialized (Lua 5.1) Registering gamemode 'fretta' derived from 'base' includes/extensions/vgui_sciptedpanels.lua:166: vgui.Create: Error when calling 'PANELTABLE':Init (fretta\gamemode\cl_selectscreen.lua:13: attempt to index global 'GAMEMODE' (a nil value)) ********************************************** ********************************************** ********** COULDN'T LOAD GAMEMODE!! ********** ********************************************** ********************************************** There was a problem opening the gamemode file 'flerpes/gamemode/cl_init.lua' Registering gamemode 'flerpes' derived from 'fretta' Sending 10 'User Info' ConVars to server (cl_spewuserinfoconvars to see) fretta\gamemode\cl_selectscreen.lua:220: attempt to index field 'lblMain' (a nil value) fretta\gamemode\cl_selectscreen.lua:220: attempt to index field 'lblMain' (a nil value) Redownloading all lightmaps [/code]
Have you altered cl_selectscreen.lua in fretta\gamemode? [editline]04:11PM[/editline] Or have you overridden GAMEMODE?
No and no. :(
It won't even load the gamemode for me...
Also GiveAmmo and Give are Serverside.
2009...
Sorry, you need to Log In to post a reply to this thread.