Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Simple test that shows how awful the net library is, and what makes it so impractical as a 'usermessage' alernative in source.
- --The problems in the 'net' library stem from the fact that it sends it's queue out a frame earlier than usermessages, so they're received, and handled first.
- --Because source engine relies on usermessages for entity creation, and everything else there's no guarentee.
- --That these objects that should exist when the message is received, do exist on the client.
- --This is NOT PVS related, there are cases with 'usermessage' when the object that's created is too far and it is,
- --But not in this case, the object can be created on the server BEFORE the server sends out the net-msg,
- --And at-least 1 frame before the client receives the usermessage telling it that this entity has been created,
- --The 'net' library has already received, and handled it's message, this creates problems like:
- --1) You will have to use timer.Simple(0, function() end) needlessy throughout your script when sending information
- -- about a new entity over the network via the 'net' library. (And even this isn't reliable w/ the net library, umsg guarentees delivery order.)
- --2) All source-object related networking functions don't guarentee that the client has knowledge of this object existing
- -- before handling the received 'net' msg that contains info about said object.
- if SERVER then
- hook.Add("PlayerSpawn", "NETMSGSUCKS::PlayerSpawn", function(player)
- local ent = ents.Create("prop_physics")
- ent:SetModel("models/error.mdl")
- ent:SetPos(player:GetPos())
- ent:Spawn()
- net.Start("test")
- net.WriteEntity(ent)
- net.Send(player)
- umsg.Start("test", player)
- umsg.Entity(ent)
- umsg.End()
- end)
- end
- if CLIENT then
- net.Receive("test", function(len)
- print("Net: " .. tostring(IsValid(net.ReadEntity))
- end)
- umsg.Hook("test", function(msg) --msg being our bf_read object. (Part of source engine.)
- print("Umsg: "tostring(msg:ReadEntity()))
- end)
- ebd
Add Comment
Please, Sign In to add comment