garrysmod-requests
garrysmod-requests copied to clipboard
Add another PVS function "AddEntityToPVS"
There is currently "AddOriginToPVS" but there are times where we only want that specific entity to be added, and having a function to only add an entity to pvs would be great.
If you're trying to make your entity update NWVars to all players at all times, you can use this:
function ENT:UpdateTransmitState()
return TRANSMIT_ALWAYS
end
But otherwise yeah, this would be a good addition if it's possible to do in the engine.
Yeah I already know that, but you can't set that on entities that are already created (for example players).
Not having PVS enabled on players is a good thing; it prevents cheats from being able to know EXACTLY where players are around the map...
Indeed, but I would still say such a function would be beneficial for developers.
Agreed; it could be useful for non-players, or players you're spectating without hackery.
Not having PVS enabled on players is a good thing; it prevents cheats from being able to know EXACTLY where players are around the map...
But there are times where a developer might want to always show a player to another player (e.g. teammates that have glows around them). You could use "AddOriginToPVS" for that but it adds a bunch of entities that you never end up seeing, and it'll crash the server if too many entities are added. This problem wouldn't exist if you could only add the specific entity you want.
This issue isn't really related to the PVS as the PVS is just the source engine's way of finding out which entities are visible to a client and need to be networked. Adding a PVS to the players PVS does give you the desired result but it's networking everything else because that's just how the PVS works.
I haven't read into this too much, nor have I tested anything I'm saying below, but from what I'm seeing we currently have a binding to ENTITY:AddEFlags which will call ENTITY:UpdateTransmitState. As a temporary workaround I think you can re-define the entity's UpdateTransmitState function to TRANSMIT_ALWAYS then add the EFL_FORCE_CHECK_TRANSMIT flag to the entity with AddEFlags. I think this will network the entity to ALL players, not sure how to go about networking an entity to a single/group of players.
If I had to guess I think what you want is a hook like ENTITY:ShouldTransmit which would allow us to change the CCheckTransmitInfo's m_pClientEnt to specific clients. I'll have to read up some more when I get home from work on how the engine picks which players to network entities to.
I agree with HellaMadMax and Matt's comments about how this would be beneficial. I think a stealth system that networks a person to nearby players for a few seconds if they made a loud enough noise would be an interesting concept. AddEntityToPVS as well as ENTITY:ShouldTransmit have lots of potential.
Id love to see this added also, It would fit perfectly for what im trying to find a way around: InfoHUD
Having a way to set always transmit AFTER an ent is created would have great potential.
@willox I see you are assigned to some other PVS related issues, do you think you would be able to do something with this at all?
I would definitely love to see AddEntityToPVS( ent )
function to use inside GM:SetupPlayerVisibility( ply, viewEnt )
just like AddOriginToPVS.
It would be great for spectators, some clientside gui maps and lots of different stuff. It won't allow hackers to get position when they want, it's up to server to decide whether to include entity in player's PVS or not so no benefits for hackers here.
I'd also find an AddEntityToPVS function useful. I'm trying to create a TTT add-on that allows the Detective to track a single player wherever they go and the lack of a good way to force player positions to always be transmitted is making it quite painful. I have a hacky workaround but AddEntityToPVS would be the 'correct' way to do what I'm trying to accomplish.
I'd also find an AddEntityToPVS function useful. I'm trying to create a TTT add-on that allows the Detective to track a single player wherever they go and the lack of a good way to force player positions to always be transmitted is making it quite painful. I have a hacky workaround but AddEntityToPVS would be the 'correct' way to do what I'm trying to accomplish.
@robotboy655 any chance of this? Ive had to do some hacky non performant stuff to achieve this, would be great