So i just want to say i have never had this issue before and this is only the base for the addon and this is all that is made, file dirs bellow:
addons/admincp/lua/autorun/admincp_init.lua
print("Initializing Admin Control Panel")
if SERVER then
util.AddNetworkString("admincpnormalopen")
include("admincp_menu/admincp_menu_commands.lua")
AddCSLuaFile("admincp_menu/admincp_menu_normal.lua")
end
print("Admin Control Panel Loaded!")
addons/admincp/lua/admincp_menu/admincp_menu_commands.lua
print("[ACP] Loading Menu Commands!")
local function admincpchatnet( sender, text, isTeam )
if ( text == "!admincp" ) then
print("[ACP] Menu Net Started!")
net.Start("admincpnormalopen")
net.Send(sender)
print("[ACP] Debug 1")
end
end
hook.Add("PlayerSay", "admincp_normal_chatnet", admincpchatnet )
print("[ACP] All Menu Commands Loaded!")
addons/admincp/lua/admincp_menu/admincp_menu_normal.lua
function admincpnormalmenu()
print("[ACP] Making Menu!")
local admincpnormal = vgui.Create("DFrame")
admincpnormal:SetPos(0,0)
admincpnormal:SetSize(ScrW(),ScrH())
admincpnormal:MakePopup()
print("[ACP] Done!")
end
net.Receive("admincpnormalopen", admincpnormalmenu )
print("[ACP] Loaded ACP Menu!")
So i get no errors in the console and when i type !admincp the console says, [ACP] Menu Net Started! and [ACP] Debug 1 like it is suposed to but then no menu is created and all console messages stop there, please help.
You're using a local function in the server file so anything inside of it (the function) can't be called by another file.
It didnt seem to work, i also tried making a new file in the same file structure but using OnPlayerChat and having it all in one client side file made sure the function wasnt a local one copied the example DFrame from the wiki and still didnt work. I have no idea what im doing wrong, im hooking the OnPlayerChat ( in the example ) and ending all eofs
Show me the code you have in sv_admincp_menu_commands.lua and cl_admincp_menu_normal.lua
sv_admincp_menu_commands.lua:
print("[ACP] Loading Menu Commands!")
function admincpchatnet( ply, text, isTeam )
if ( text == "!admincp" ) then
print("[ACP] Menu Net Started!")
net.Start("admincpnormalopen")
net.Send(ply)
print("[ACP] Debug 1")
end
end
hook.Add("PlayerSay", "admincp_normal_chatnet", admincpchatnet )
print("[ACP] All Menu Commands Loaded!")
cl_admincp_menu_normal.lua:
if SERVER then return end
function admincpnormalmenu()
print("[ACP] Making Menu!")
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 100, 100 )
DermaPanel:SetSize( 300, 200 )
DermaPanel:SetTitle( "My new Derma frame" )
DermaPanel:SetDraggable( true )
DermaPanel:MakePopup()
print("[ACP] Done!")
end
net.Receive("admincpnormalopen", admincpnormalmenu )
print("[ACP] Loaded ACP Menu!")
The if SERVER then return end wasnt there before i have tried it without still no look just saw it on another post so i tried it
get rid of the if SERVER then return end you don't need it and do the util.AddNetworkString("admincpnormalopen") on the "sv_admincp_menu_commands.lua"
20180912211013 1 — imgbb.com
Ok so it works when i put the 2 files into admincp/lua/autorun/FILES but it doesnt work when i include and addcsluafile and by having the files in admincp/lua/admincp_menu/FILES
you ADDCSLuaFile() Client files
you include() server files
part of the reason I had you rename the files with cl_ and sv_ infront of them
i do i have, lua/autorun/admincp_init.lua
print("Initializing Admin Control Panel")
if SERVER then
include("admincp_menu/sv_admincp_menu_commands.lua")
AddCSLuaFile("admincp_menu/cl_admincp_menu_normal.lua")
end
print("Admin Control Panel Loaded!")
yeah sorry was slow on the draw get rid of the if SERVER then statement and the end.
what do you mean
yeah that's fine.
[ERROR] addons/redux_admincp/lua/admincp_menu/sv_admincp_menu_commands.lua:1: attempt to call field 'AddNetworkString' (a nil value)
1. unknown - addons/redux_admincp/lua/admincp_menu/sv_admincp_menu_commands.lua:1
2. include - [C]:-1
3. unknown - addons/redux_admincp/lua/autorun/admincp_init.lua:3
give me to remember (had this issue last night)
Just cause I'm curious, I didn't see anywhere you including the clientside file? Only doing the AddCSLuaFile part.
util.AddNetworkString("admincpnormalopen")
print("[ACP] Loading Menu Commands!")
function admincpchatnet( ply, text, isTeam )
if ( text == "!admincp" ) then
print("[ACP] Menu Net Started!")
net.Start("admincpnormalopen")
net.Send(ply)
print("[ACP] Debug 1")
end
end
hook.Add("PlayerSay", "admincp_normal_chatnet", admincpchatnet )
print("[ACP] All Menu Commands Loaded!")
Yes, AddCSLuaFile() does it on the server. You also have to do include() on the client realm otherwise it won't be loaded.
OMG! im smh rn, that worked. I didnt event know you could include a client side file i thought AddCSLuaFile did that, im dumb thank you!
I see the issue so admincpnormal open isn't defined as a function in the file that it's in. If i'm correct you're trying to use it to open the frame. You don't need
util.AddNetworkString("admincpnormalopen")
to do that. Instead just do
net.receive("admincpnormalopen", admincpnormalmenu)
where the frame is called (after the frame like a hook).
You can either use that net string, or a concommand. But if you're gonna use net lib, you need the util.AddNetworkString(), his entire issue was that the file was being sent to the client but never loaded, thus the functions were never created.
Thank you, I think I was just overthinking the problem lol
Ah, thank you could you assist me with one more quick issue, im getting an error when creating a surface font, code bellow:
surface.CreateFont( "SuperHeaderFont", {
font = "CloseCaption_BoldItalic", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
extended = false,
size = 20,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = true,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
net.Receive( "acpsuperpanelnet", function()
local ACPSPanel = vgui.Create( "DFrame" )
ACPSPanel:SetPos( 0, 0 )
ACPSPanel:SetSize( ScrW(), ScrH() )
ACPSPanel:SetTitle( "" )
ACPSPanel:SetDraggable( false )
ACPSPanel:MakePopup()
ACPSPanel:SetDeleteOnClose( true )
ACPSPanel:SetScreenLock( true )
ACPSPanel:SetSizable( false )
ACPSPanel:ShowCloseButton( false )
ACPSPanel.Paint = function()
surface.SetDrawColor( 40,40,40,255 )
surface.DrawRect( 0, 0, ScrW(), ScrH() )
surface.SetDrawColor( ACPConfig.HeaderColor )
surface.DrawRect( 0, 0, ScrW(), 75 )
surface.SetFont( "SuperHeaderFont" )
surface.SetTextColor( 1,1,1,255 )
surface.SetTextPos( 5, 5 )
surface.DrawText( ACPConfig.ServerTitle )
end
local ACPSCButton = vgui.Create( "DButton", ACPSPanel )
ACPSCButton:SetText( ACPConfig.CloseKeyText )
ACPSCButton:SetPos( ScrW() - 75, 10 )
ACPSCButton:SetSize( 50, 30 )
ACPSCButton.DoClick = function()
ACPSPanel:Close()
end
end)
Right off the bat I don't see anything wrong from skimming it, but the error would be useful?
nvm i fixed it i just moved the font into the ner.Receive funtion
Sorry, you need to Log In to post a reply to this thread.