garrysmod-requests icon indicating copy to clipboard operation
garrysmod-requests copied to clipboard

Add another PVS function "AddEntityToPVS"

Open HellaMadMax opened this issue 10 years ago • 12 comments

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.

HellaMadMax avatar May 02 '14 14:05 HellaMadMax

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.

MattJeanes avatar May 03 '14 16:05 MattJeanes

Yeah I already know that, but you can't set that on entities that are already created (for example players).

HellaMadMax avatar May 04 '14 00:05 HellaMadMax

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...

Acecool avatar May 08 '14 16:05 Acecool

Indeed, but I would still say such a function would be beneficial for developers.

MattJeanes avatar May 08 '14 16:05 MattJeanes

Agreed; it could be useful for non-players, or players you're spectating without hackery.

Acecool avatar May 08 '14 16:05 Acecool

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.

HellaMadMax avatar May 09 '14 23:05 HellaMadMax

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.

mcd1992 avatar Apr 24 '15 17:04 mcd1992

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.

LeQuackers avatar Dec 13 '16 11:12 LeQuackers

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?

sammyt291 avatar Feb 06 '17 08:02 sammyt291

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.

chelog avatar May 31 '17 19:05 chelog

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.

nkilmer avatar Dec 06 '20 06:12 nkilmer

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

blobles-dev avatar Feb 03 '24 19:02 blobles-dev