Need help with some scripting

Admins if this isn’t the right place for this please send me a pm and I will remove it, although I don’t know why it wouldn’t be the right place.

So I’m fairly new to Lua coding and I’m attempting to have a Derma box run on initial spawn.
My issue is that it will not boot on spawn and I get an error using util.AddNetworkString

This is what I have located it my Lua files.

---- INIT.LUA ----

AddCSLuaFile(‘cl_init.lua’)
AddCSLuaFile(‘shared.lua’)

include(‘shared.lua’)

util.AddNetworkString( “NetServer” ) <------ I get errors using this code telling me that I’m calling on a nil value.

hook.Add(‘PlayerInitialSpawn’, ‘HOOKED’, function(ply)
print(ply:GetName()… "joined the server.
")
end)

MsgC( Color( 0, 232, 223), "Script Has Loaded
" )

hook.Add( ‘PlayerInitialSpawn’, ‘HOOKER’, function(v)
net.Start(‘NetServer’)
net.Send(v)
end )

---- CL_INIT.LUA ----

include(‘shared.lua’)

net.Receive(‘NetServer’, function ()
local base = vgui.Create(‘DFrame’)
base:SetSize (600, 300)
base:Center()
base:SetTitle(’ ')
base:ShowCloseButton(true)
base:SetDraggable(false)
base:MakePopup()
function base:Paint(w, h)
draw.RoundedBox(0, 0, 0, w, h, Color( 255, 255, 255))

	end
local button = vgui.Create('DButton')
	button:SetSize(100, 25)
	button:SetText('')
	button:Center()

end)

As a sidenote if anyone can tell me how to make it so that my Dpannel, Buttons, and Text will scale down with resolution sizes that would be amazing!

Thanks!

Can you post the exact error?

[ERROR] addons/my addon/lua/autorun/init.lua:8: attempt to call field ‘AddNetworkString’ (a nil value)

  1. unknown - addons/my addon/lua/autorun/init.lua:8

The reason you’re getting that error is because init.lua is inside autorun/ a SHARED directory. Note: You do not need include or AddCSLuaFile inside of the autorun/, autorun/client/, or autorun/server/ directories where the client and server directories are self-explanatory in terms of realm used, autorun/ is SHARED. The error is occurring when the client runs it because it is a server function.

For your panels, take a look at this: https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/understanding_hardcoding_of_screensizes.lua.html

Same principle…

And another note: Don’t use common file-names inside of the lua/autorun/ directories… You will potentially OVERWRITE another file running… Use prefixes / postfixes or whatever to ensure your filename is unique so another file isn’t overwritten.

Cheers mate! Thanks for the help!