• Pooling Net Messages
    1 replies, posted
I don't exactly feel like an idiot, because when I look at this everything is exactly right. It kind of pisses me off, because I'm not confused about how net messages work, I'm just confused why I always have trouble using them. I have some pretty simple code that ignites a player, it says claims I didn't pool with util.AddNetwork string? sv_menu.lua [CODE]util.AddNetworkString("IgnitePly") net.Receive("IgnitePly", function(len, ply) ply:Ignite(10, 5) end)[/CODE] cl_menu.lua [CODE]local Frame = vgui.Create("DFrame") Frame:SetSize(100, 100) Frame:Center() Frame:SetVisible(true) Frame:MakePopup() local Btn = vgui.Create("DButton", Frame) Btn:Center() Btn:SetText("Suicide!") Btn.DoClick = function() surface.PlaySound("garrysmod/ui_click.wav") net.Start("IgnitePly") net.SendToServer() end[/CODE] This is what it looks like in the console. [CODE]] lua_openscript sv_menu.lua Running script sv_menu.lua... ] lua_openscript_cl cl_menu.lua Running script cl_menu.lua... [ERROR] lua/cl_menu.lua:12: Calling net.Start with unpooled message name! [http://goo.gl/qcx0y] 1. Start - [C]:-1 2. DoClick - lua/cl_menu.lua:12 3. unknown - lua/vgui/dlabel.lua:218 [/CODE] I know how much people ask about net messages because I lurk, so if I did something wrong you have a right to get frustrated. :suicide: Anyways thanks for the help [B]:love:[/B]
1) Make sure sv_menu.lua is ran by adding print()s. The name is very generic and could be overridden to some other addon, so change the name. 2) Give util.AddNetworkString some time to network. It is not instant, and it will not be processed while in menu in singleplayer. Just give it a second. Not a lua timer, just physically wait. Ideally you want to run util.AddNetworkString as soon as the server starts, so from the lua/autorun/ folder.
Sorry, you need to Log In to post a reply to this thread.