Net Libraries - util.AddNetworkString creating error

The code all works perfectly besides the error it creates.

net.Receive("ApplyCommand", function(len,ply)

The error is:

[ERROR] addons/apply-command/lua/autorun/init.lua:1: attempt to call field 'AddNetworkString' (a nil value)
  1. unknown - addons/apply-command/lua/autorun/init.lua:1:

I’ve been messing around with this for hours and I don’t see why there’s an error.

[Edit] This problem has been solved.

At a guess, someone re-assigned the global variable “util”

Putting it in lua/autorun means it is running on both the client and the server, despite being named “init.lua”. Put it in lua/autorun/server.

The error is when the client tries to run the code. AddNetworkString is server-only.

I do all of the testing on a blank gmod server on my computer. Everything is as default as can be.

[editline]4th September 2016[/editline]

That was indeed the problem, thank you so much!

but umm… why does this code even exist in the first place…

Making a command that opens a link in steam web browser. Why does it matter?

why are you using net?

Because I’m using SendLua

what meep is asking is:

why are you having the client tell the server to tell the client to open a link, when the client could just do that on its own?

Because I want it to automatically open in the steam web browser right upon the sending of the command.

okay but

instead of the client doing a net.SendToServer, for the server to then use SendLua, why not simply have the client run the gui command and do no net?

Gonna be honest, I have no idea how I’d do that without creating a derma panel or something in it’s likeness.

we are not on the same page

in some piece of clientside code somewhere, you have net.SendToServer

why not replace that specific code with the gui command?

what is triggering the net message?

hook.Add("OnPlayerChat","ApplyLink",function( ply, str , b , d )
	str = string.lower(str)
	if (str == "!apply") then
		net.Start( "ApplyCommand" )
		return true

[lua]hook.Add(“OnPlayerChat”,“ApplyLink”,function( ply, str , b , d )
str = string.lower(str)
if (str == “!apply”) then
if ply == LocalPlayer() then
return true

Oh cool thanks :smiley: