• The New Net Library
    94 replies, posted
  • Avatar of DylanWilson
  • [QUOTE=Jinto;33498446]Will it support PVS and PAS? Maybe net.SendPVS() and net.SendPAS()?[/QUOTE] check the comments on my profile, twoski put a dump of the net library there, PAS and PVS are implemented (thanks twoski)
  • [QUOTE=CmdrMatthew;33500159]It already does support PVS.[/QUOTE] Excellent.
  • Avatar of Science
  • [h2]Im Currently Working On The Wiki Page If Anyone Wants To Help[/h2] [url]http://wiki.garrysmod.com/?title=Net[/url]
  • Avatar of Science
  • [QUOTE=FPtje;33503651]I know PVS, but what is PAS?[/QUOTE] PVS and PAS, what are they both?
  • Avatar of garry
  • PVS is what you can see from that spot, PAS is what you can hear from that spot
  • Avatar of Science
  • [QUOTE=garry;33503734]PVS is what you can see from that spot, PAS is what you can hear from that spot[/QUOTE]Oh my god. You just made me cum a little. This is amazing.
  • [QUOTE=thejjokerr;33494485]By the way I couldn't find this in the thread anywhere, but the net.Receive callback is actually also gives another variable, which is a table: [CODE]1 = Player [1][[RV] TJjokerR] n = 1[/CODE] The sending player and something else?[/QUOTE] [quote=Programming in Lua: 19.1 - Array Size]Usually, a call table.setn(t, n) associates t with n in an internal (weak) table and a call table.getn(t) retrieves the value associated with t in that internal table. [b]However, if the table t has a field "n" with a numeric value, setn updates this value and getn returns it.[/b] The getn function still has a last option: If it cannot get an array size with any of those options, it uses the naive approach: to traverse the array looking for its first nil element. So, you can always use table.getn(t) in an array and get a reasonable result.[/quote]
  • Would anyone know what would cause the following behavior? Net lib wont start sending messages (from server) until I execute sv_allowdownload 1 in server console. This was tested in both listen and dedicated, where download was allowed in both upon start-up of the server. net.Send( ply ) sending net message to all players on server? ply being one player entity. I'm just wondering if anyone is experiencing anything similar while I continue to comb my gamemode for anything I have done incorrectly. edit: This actually just seems to affect the first player that connects, subsequent players start receiving net messages, but messages sent to a single player still seem to be broadcasted.
  • Sending a Table that contains a Table in Net lib causes the sub table to be sent as a number (258) Also seems to not send empty tables {}, can be annoying when sending tables structures.
  • Avatar of TheJjokerR
  • [QUOTE=nextek;33512609]Sending a Table that contains a Table in Net lib causes the sub table to be sent as a number (258) Also seems to not send empty tables {}, can be annoying when sending tables structures.[/QUOTE] Sends as a different number for me, I think it's taking a character from the key string and converts it to the numerical code. Didn't report it as Garry said he was still working on it.
  • [QUOTE=thejjokerr;33512702]Sends as a different number for me, I think it's taking a character from the key string and converts it to the numerical code. Didn't report it as Garry said he was still working on it.[/QUOTE] [url]http://www.facepunch.com/threads/1143704?p=33504343&viewfull=1#post33504343[/url]
  • Avatar of TheJjokerR
  • [QUOTE=nextek;33512936][url]http://www.facepunch.com/threads/1143704?p=33504343&viewfull=1#post33504343[/url][/QUOTE] Yes. I figured that out, but when I: - SetType on the server (for a table) - read the byte on the client to check if it's a table and then net.ReadTable() it should work fine, instead it breaks at the recursive table where it gets a larger number as an index for the net.ReadVars then it should be. It's late, so sorry if that didn't make sense.
  • Avatar of Kopimi
  • I have two net messages that are sent to the clients by the server. [code] net.Receive("UpdateRoundInfo", function(size) ROUND_TIME = net.ReadFloat() ROUND_NUMBER = net.ReadFloat() print(ROUND_NUMBER) end) net.Receive("StartRound", function(size) ROUND_TIME = net.ReadFloat() ROUND_NUMBER = net.ReadFloat() RoundStart() print(ROUND_NUMBER) end) [/code] Here's the code I'm using to call them: [code] if ROUND_NUMBER == 0 and #player.GetAll() >= MINIMUM_PLAYERS then net.Start("StartRound") net.WriteFloat(ROUND_TIME) net.WriteFloat(ROUND_NUMBER) net.Broadcast() RoundStart() print("A") else net.Start("UpdateRoundInfo") net.WriteFloat(ROUND_TIME) net.WriteFloat(ROUND_NUMBER) net.Broadcast() print("B") end [/code] The net message SHOULD be sent, because the server prints both A and B when they should be called. The client prints the round number (So it is receiving) "UpdateRoundInfo", but "RoundStart" is never called. I've tried printing "HI" and stuff like that, so it's not a matter of ROUND_NUMBER being nil. No errors or nothing it's driving me absolutely insane, plus I can't even check the Wiki since it decided to go down for a few hours.
  • My problem is similar Kopimi, May not be related but try issuing sv_allowdownload 1 on the server console, before sending begin round net message. I found doing this (or reconnecting) tended to make the unsent net messages suddenly start sending/receiving.
  • Avatar of Teddi
  • [QUOTE=Science;33503597][h2]Im Currently Working On The Wiki Page If Anyone Wants To Help[/h2] [url]http://wiki.garrysmod.com/?title=Net[/url][/QUOTE] Learn to spell rec[B]ei[/B]ve please. I recreated the page [b][url=wiki.garrysmod.com/?title=Net.Receive]Net.Receive [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] because you had plenty of typos that would confuse people as to why net.rec[B]ie[/B]ve wouldn't work. Also I improved your example :v:.
  • Avatar of _nonSENSE
  • It also doesn't only take a unique identifier as it's argument. It takes an identifier and a function, just like usermessage.Hook. It doesn't return a number either. Those inconsistencies tend to bug me...
  • Avatar of Kamshak
  • on net.Receive serverside, is there a way to know from which client the message originated? That would be good to know
  • Avatar of MadDog986
  • [QUOTE=Kamshak;36030122]on net.Receive serverside, is there a way to know from which client the message originated? That would be good to know[/QUOTE] [code]net.Receive( "name", function( length, player ) end)[/code] Also: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5b6a.html?title=Net&oldid=55437[/url]
  • Avatar of drak_thing
  • Am I able to replace all my usermessages/concommands with this? I'd love too. Right now anytime I update the table server-side I send a usermessage which the client-side has hooked and updates the local table. To display on VGUI menus and such. But I'm unable to hook messages, so I'm assuming I couldn't really replace ether? Thanks. [b]EDIT:[/b] Nevermind, I just saw the old Wiki post.
  • I've been experimenting with the Source engine (while creating a playground mod) and found out how to do this. If Garry uses a similar way, then I can tell you it is better than usermessages. One thing that bothers me though, is how Garry sends the data. Does he always sends the 65535 (or something like that) bytes (which is rather unlikely) or if he sends a number detailing the amount of bits sent (since I've been unable to actually make the engine do that for itself with its bit buffers, I assume this is needed).
  • Avatar of drak_thing
  • Don't mean to double post. But why does this not work? [lua] if SERVER then local test_table = { "eggs", "cheese", "apple", 100200, 3.4567, Vector(1.2345,800,-900), Entity(1) } util.AddNetworkString("test_message") net.Start("test_message") net.WriteTable(test_table) net.Broadcast() print("sending..") end if CLIENT then net.Receive("test_message", function(length) MsgN("Got Message. Len: " , length) PrintTable(net.ReadTable()) end); end [/lua] Dumps: [QUOTE=GMod Console] Got Message. Len: 659 [@lua\includes\modules\net.lua:133] Couldn't read type 4325378 Error [C]:-1 ReadType lua\includes\modules\net.lua:133 ReadTable lua\includes\modules\net.lua:81 func lua\derp2.lua:5 unknown lua\includes\modules\net.lua:26 [/QUOTE]
  • You shouldn't send the message right after registering the message name. About the rest, I have no idea. I've scrolled through the net Lua module and everything seems fine.
  • Avatar of Deadman123
  • [QUOTE=danielga;36597881]You shouldn't send the message right after registering the message name. About the rest, I have no idea. I've scrolled through the net Lua module and everything seems fine.[/QUOTE] net.WriteTable is broken because of Garry removing net.WriteLong and replacing it with net.WriteInt and forgetting to change the occurrences of it.
  • Avatar of Wizard of Ass
  • Just define the functions you need, I posted them in another thread in the gm13 section, see yourself.