• Network to new players [Gmod lua helpme please]
    5 replies, posted
Hello So basically I have a billboard that shows you some areas and who owns them based off of what someone inputs into a menu, This all works fine and dandy if your on the server at the same time when someone updates the booking areas. However if you join the server post updated you just see Nil until that area is re-updated whilst you are connected. I would like to know how to network existing strings to new players when they join via hook.Add( "InitPostEntity", "regconb1load", function() net.Start("regconb1load") net.SendToServer() end) So basically ^ thats in the cl_init.lua which can be found here - cl_init lua and I needa make it network with the server to resend the already set network strings. (if thats even how its worded) via the svbook.lua located here - svbook lua that is used to open the derma that has all the buttons, all the buttons on the panel do the same thing but with a different output by 1 number as seen in cl_init here is what happens when you click a button on the derma menu local BOOKButton1 = vgui.Create( "DButton", BOOKFrame ) BOOKButton1:SetText( "Assign Booking" )                                    BOOKButton1:SetSize( 120, 50 )     BOOKButton1:SetFont( "epicfont" ) BOOKButton1:SetPos( 20, 180 ) BOOKButton1.Paint = function(self, w, h)     draw.RoundedBox( 0, 0, 0, w, h, Color(255, 255, 255, 170))     end BOOKButton1.DoClick = function()   net.Start("regconb1") net.WriteString(bookregi1) -- Strings and stuffs right here   net.SendToServer() end    if you could help me with this I would really appreciate it.
util.JSONToTable and util.TableToJSON if you are writing a relatively large table then you should be compressing it with util.Compress and util.Decompress then the net message as a string. if the data is REALLY large then you can take a look at the built in gmod duplicator tools scripts to see how to compress, split and send large data over the net library.
I'm not trying to do this
-- server hook.Add("PlayerInitialSpawn", "RegConB1Load", function(ply) net.Start("regconb1load") net.WriteString(regconb1) net.WriteString(regconb2) -- ... net.Send(ply) end) -- client net.Receive("regconb1load", function() regconb1 = net.ReadString() regconb2 = net.ReadString() -- ... end)
Hey thanks man this worked however when the server first starts up theirs an error [ERROR] addonlineblahblah/svbook.lua:47: bad argument #1 to 'WriteString' (String Expected, got nil) is there a way I could determine the string on server start/map change? I have tried but each of my attempts have broken the joining the server and having what it has been set to this restart so far.
Sorry, you need to Log In to post a reply to this thread.