• Calling net.Start with unpooled message name!
    4 replies, posted
Hey! I've ran into an issue where I am increasingly confident Garry's Mod is to blame for the error here, [B]despite a verify of the game cache[/B], but hoping a smartie could have a brief look at the code to assure me I am not going crazy! Originally it was spitting back an error saying the player is "0" (in integer form), now its saying [CODE] [ERROR] lua/goto.lua:20: Calling net.Start with unpooled message name! [http://goo.gl/qcx0y] 1. Start - [C]:-1 2. DoClick - lua/goto.lua:20 3. unknown - lua/vgui/dlabel.lua:218 [/CODE] To be absolutely confident I am not to blame, I even replaced my code partly with what [URL="https://youtu.be/ODlGyS6lR1M?t=10m33s"]Code Blue did in this tutorial video here.[/URL] and it works for him, but of course, not for me. The relevant codes [B] Client:[/B] [CODE] DermaMidget.DoClick = function() net.Start("TimeToMove") print("SentToServer") net.SendToServer() net.Receive("MoveIt",function() print("Recieved") end)[/CODE] [B][U]"net.Start("TimeToMove")" is the referenced line of code by the error[/U][/B] [B] Server:[/B] [CODE]util.AddNetworkString( "TimeToMove" ) util.AddNetworkString( "MoveIt" ) net.Receive("TimeToMove",function(ply) print("Recieved") print(ply) print(ply:Nick()) net.Start("MoveIt") print(ply) net.Send(ply) end)[/CODE] Full code can be found on the following pastebin if wanted Client: [url]http://pastebin.com/1PLSnGBJ[/url] Server: [url]http://pastebin.com/1Fx5UR2E[/url] Massive thanks in advance, as I said it shouldn't be a code problem, probably a GMoD problem, but some confirmation of that would be fantastic :) Big Thanks, Bings :smile:
Your serverside code must be ran before you can send net messages from client or server.
[QUOTE=Robotboy655;50750846]Your serverside code must be ran before you can send net messages from client or server.[/QUOTE] Forgot to mention that, but at a quick check of the console it confirms that I was running the serverside script first. [CODE]] lua_openscript gotoserver.lua Running script gotoserver.lua... ] lua_openscript_cl goto.lua Running script goto.lua... [/CODE]
Make sure your files with the servercode are actually being ran serverside. You can do this by just putting a print statement in there when the server loads up to make sure 100% it is being ran. If your file is just in the plain folder of autorun/server then make sure your filename is relatively unique. By the looks of it your goto.lua file is not being automatically ran + it's not being ran serverside Also, net.Receive takes 2 callback arguments. The length of the message and the player who sent it. You would essentially be printing out a number (the length) instead of the player (which is why you were getting the number 0) when that message does get received. Finally, you probably don't want to receive a message from the server when its in a DoClick function, moving it outside should be fine. I just did this and everything worked well for me Client: lua\autorun\client\mycoolmessages.lua [CODE]local function help2rescue() local frm = vgui.Create("DFrame") frm:SetSize(200,200) frm:SetPos(ScrW()*.5,ScrH()*.5) local btn = vgui.Create("DButton",frm) btn:SetPos(100,100) btn.DoClick = function() print("I was just clicked!") net.Start("playerMulti") net.SendToServer() end net.Receive("playerMulti", function() print("Hey can you not click me?") end) end[/CODE] Server: lua\autorun\server\coolservermessages.lua [CODE] util.AddNetworkString("playerMulti") net.Receive("playerMulti", function(len,ply) print(ply:Nick().." just clicked me!") net.Start("playerMulti") print("I am sending a message back to the client to tell him to not click me anymore!") net.Send(ply) end)[/CODE]
Thanks for your superb response! In response to a few bits, [QUOTE=dence47;50750965]If your file is just in the plain folder of autorun/server then make sure your filename is relatively unique. By the looks of it your goto.lua file is not being automatically ran + it's not being ran serverside[/QUOTE] I just quickly made the file as I got tired of trying to run the full thing I'm working on so I thought id make a little script which I can test things ion individually. I was also running it manually as I hadn't got round to doing it automatically! [QUOTE=dence47;50750965] Also, net.Receive takes 2 callback arguments. The length of the message and the player who sent it. You would essentially be printing out a number (the length) instead of the player (which is why you were getting the number 0) when that message does get received.[/QUOTE] This is fantastic and solved the issue, big thumbs up for that :D [QUOTE=dence47;50750965]Finally, you probably don't want to receive a message from the server when its in a DoClick function, moving it outside should be fine. I just did this and everything worked well for me[/QUOTE] As said above, just a button to active the compartment I'm working on :) Overall, massive massive thanks! Bings :)
Sorry, you need to Log In to post a reply to this thread.