Wierd Lua Problem

I have seen quite a few people get an error message like this, which i have not been able to duplicate:


[Zombie Invasion] lua/autorun/client/client.lua:342: Calling net.Start with unpooled message name [http://goo.gl/qcx0y]
  1. Start - [C]:-1
   2. OnValueChanged - lua/autorun/client/client.lua:342
    3. ValueChanged - lua/vgui/dnumslider.lua:199
     4. OnValueChanged - lua/vgui/dnumslider.lua:41
      5. SetValue - lua/vgui/dnumberscratch.lua:47
       6. SetValue - lua/vgui/dnumslider.lua:125
        7. TranslateValues - lua/vgui/dnumslider.lua:218
         8. OnCursorMoved - lua/vgui/dslider.lua:120
          9. unknown - lua/vgui/dslider.lua:45

My basic files (cut down) are:

lua/autorun/server/init.lua (This is from the start)


include( "shared.lua" )
AddCSLuaFile( "shared.lua" )

util.AddNetworkString("send_ztable_cl")
util.AddNetworkString("send_ztable_sr")
util.AddNetworkString("zinv")
util.AddNetworkString("zinv_explode")
util.AddNetworkString("zinv_maxdist")
util.AddNetworkString("zinv_mindist")
util.AddNetworkString("zinv_maxspawn")
util.AddNetworkString("zinv_chaseplayers")

lua/autorun/server/client.lua (first line is line 342)


p.OnValueChanged = function(self)
		if LocalPlayer():IsSuperAdmin() then
			net.Start("zinv_mindist")
			net.WriteFloat(self:GetValue())
			net.SendToServer()
		else
			chat.AddText(Color(255,62,62), "WARNING: ", Color(255,255,255), "You must be a super-admin to change this option.")
			chat.PlaySound()
		end			
	end

lua/shared.lua


if !ConVarExists("zinv") then
    CreateConVar("zinv", '1', {FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY})
end

if !ConVarExists("zinv_explode") then
    CreateConVar("zinv_explode", '0', {FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY})
end

if !ConVarExists("zinv_maxdist") then
    CreateConVar("zinv_maxdist", '3000', {FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY})
end

if !ConVarExists("zinv_mindist") then
    CreateConVar("zinv_mindist", '1000', {FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY})
end

if !ConVarExists("zinv_maxspawn") then
    CreateConVar("zinv_maxspawn", '50', {FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY})
end

if !ConVarExists("zinv_chaseplayers") then
    CreateConVar("zinv_chaseplayers", '0', {FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY})
end

if !SERVER then return end

net.Receive("zinv", function(len,ply)
	if ply:IsValid() and ply:IsPlayer() and ply:IsSuperAdmin() then
		RunConsoleCommand("zinv", net.ReadFloat())
	end
end)

net.Receive("zinv_explode", function(len,ply)
	if ply:IsValid() and ply:IsPlayer() and ply:IsSuperAdmin() then
		RunConsoleCommand("zinv_explode", net.ReadFloat())
	end
end)

net.Receive("zinv_maxdist", function(len,ply)
	if ply:IsValid() and ply:IsPlayer() and ply:IsSuperAdmin() then
		RunConsoleCommand("zinv_maxdist", net.ReadFloat())
	end
end)

net.Receive("zinv_mindist", function(len,ply)
	if ply:IsValid() and ply:IsPlayer() and ply:IsSuperAdmin() then
		RunConsoleCommand("zinv_mindist", net.ReadFloat())
	end
end)

net.Receive("zinv_maxspawn", function(len,ply)
	if ply:IsValid() and ply:IsPlayer() and ply:IsSuperAdmin() then
		RunConsoleCommand("zinv_maxspawn", net.ReadFloat())
	end
end)

net.Receive("zinv_chaseplayers", function(len,ply)
	if ply:IsValid() and ply:IsPlayer() and ply:IsSuperAdmin() then
		RunConsoleCommand("zinv_chaseplayers", net.ReadFloat())
	end
end)

Why is that error occuring? I have added the network string already and it never happens for me!

Sorry but what the hell are you doing there?

Why don’t you use serverside convars? They sync automatically

I updated the client.lua code to show it more in context, it is called by a gui element. Is that the wrong was to do it?

It seems to be all fine, there must be some error including the lua/autorun/server/init.lua file.
You should put a print inside the init.lua to check if it actually executes correctly.

Yea thats exatcly what i thought! (about the including)

What would cause that?? its not because ive left it a generic name like init.lua or something

[editline]24th November 2014[/editline]

Heres the guys bug post if thats any help: http://pastebin.com/7WE6nvA9

Perhaps files are being loaded before you util.AddNetworkString? try moving includes/addcsluafiles to after the util.AddNetworkStrings

Archived console commands are ran before Lua.

Also, it would help to see the code which actually adds p.OnValueChanged as a callback function. Maybe you’re calling it instead of referencing it.

If I understand your code correctly, you want to make a GUI where you can change convars for admins (?)

If so, you could still use server-side convars. You would still need net-message(s), but once you told the server to change it (via lua), the server will sync it automatically with all it’s clients.

(Performance tip: Only declare one network String, like “zinv_changeconvar” and pass a string at the beginning specifying which convar you want to change)