• Client-Server networking questions.
    4 replies, posted
[I]Here's a question someone could maybe answer or discuss on with me considering I got bumped and most of the stuff below isn't really worth reading.[/I] Is it better to use usermessages for smaller networked items when you know you will not surpass the size limit? 255 bytes seems like it would send faster than 64kb right? Or is that the reason net was created, because any packet less than 64kb sent to the client isn't a noticable change compared to 64kb anyways? Is there any good way to do it? I'm talking about for things like "money", something the server and all clients need to be updated on per player, although is it possible to create a better network than the good ole 'setnetworkedint' ect? I know using networked variables can be expensive which is why I want to go about creating my own structured way if it would prove any significance. And I don't want to create some big system, then scrap it and end up re doing it a week later so I figured I would get some input from people first. And here is something that has gotten me thinking, you know the new net. library? Is it better to only use it for bigger networking issues, or is it overall better compared to user messages even with a few bytes of data? Because the way I see it, sending 64kb to the client would be more stress then the limited 255 bytes right? But then again what was the main reason for net libraries? To be used generally for bigger things so people don't have to machine gun bits of data to the client, or does the gap between 255bytes and 64kb really not change the stress level even in a high end practical uses? Right now I'm caught between the two, I'm thinking the best thing to do is utilize both libraries and use user messages for smaller bits of data like "rank", "money" then use net. library for bigger serialized tables such as "weapons", "Items" ect. It would be nice if anyone could provide some insight on this for me. Another thing, I had the idea of just stuffing all variables that need to be networked into a table on a per player basis. Then updating parts of the table when needed. Would that be of any difference, or would it just create one huge complex networked message that does that same thing as multiple small ones except for the fact that it contains one extra table that they are all kept in? Any knowledge on networking from anyone would be great, maybe you have a link that really helped you on something that you could pass my way as I am not opposed to reading up on stuff. Right now I am trying to get a couple leads as what I should do or look for before I start working on anything major. Here is mostly what I was thinking about doing, or something similar. If anyone wants to critique them be all means go ahead I don't even know if this is the way things like this should even be done. [U][B]COULD SOMEONE PLEASE FIX THIS, WHEN YOU GO INTO EDITING MODE ON A POST THAT CONTAINS LUA TAGS, THE TAGS GET REMOVED WHICH TURNS THE CODE INTO [I]THIS[/I] WHEN YOU SAVE CHANGES AND FORGET TO RE ADD LUA TAGS.[/B][/U] About the 50th time I've done this in the last month or so -.- if SERVER then function PLAYER:SetNetworkRank( Int ) if self == NULL then return false end if Int == nil then return false end self.Server_Rank = Int net.Start( "Server_Rank" ) net.WriteInt( Int ) net.Broadcast() return true end function UpdatePlayerOnRanks( pl ) for k, v in pairs( player.GetAll() ) do local ID = v:SteamID() local Rank = v:GetNetworkRank() net.Start( "UpdatePlayerRanks" ) net.WriteString( ID ) net.WriteInt( Rank ) net.Send( pl ) end end hook.Add( "PlayerInitialSpawn", "Network_Rank_FillIn", UpdatePlayerOnRanks ) else Players_Info = {} net.Receive( "Server_Rank", function( len ) local Int = net.ReadInt() LocalPlayer().Server_Rank = Int end ) net.Receive( "UpdatePlayerRanks", function( len ) local ID = net.ReadString() local Int = net.ReadInt() for k, v in pairs( player.GetAll() ) do if v:SteamID() == ID then v.Server_Rank = Int end end end ) end function PLAYER:GetNetworkRank() if self == NULL then return nil end if !self.Server_Rank then self.Server_Rank = nil end return self.Server_Rank end
ok i didnt finish reading your post so ye.. but im assuming you are after a new version of NWVars. if you arent, tough shit. if you are then good :D cos i just spent the last hour and a half writing a new nwvar thingy. heres the source: -snip- [url]http://facepunch.com/showthread.php?t=1225858[/url]
Hey thanks man! (: I was specifically looking for new nw variables but I'm definitely going to toy around with what you wrote up!
haha awesome :)
Bump. I'm very curious as to the answers of some of the questions asked in the opening post, if anyone has the knowledge and would be so kind as to share. GM13 Lua is such a mystery. :v:
Sorry, you need to Log In to post a reply to this thread.