Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NetworkConcealPlayer.md #1133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions NETWORK/NetworkConcealPlayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,42 @@ This is what R* uses to hide players in MP interiors.
* **toggle**:
* **p2**:

To manage player visibility with NetworkConcealPlayer, here’s a solid approach:

**General Population (players not in any instance):**

* Use NetworkConcealPlayer to hide players who are in any instance. This way, general population players won’t see or interact with instance players.

**Instance Players (players in a specific instance):**

* Use NetworkConcealPlayer to hide players who aren’t in the same instance. Instance players can still see and interact with the general population but not with players in other instances.

This setup keeps instance players separate from each other while allowing interaction with the general population.


```lua
-- Function to manage player visibility
function concealPlayers(instanceId)
local allPlayers = GetPlayers()

for _, player in ipairs(allPlayers) do
local playerInstance = GetPlayerInstance(player) -- You need to define this function
Copy link
Contributor

@4mmonium 4mmonium Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need an instance for this native to execute. I believe that this was probably set up for other use cases, based on the condition statements.

All you need is a valid player index and that player needs to be networked, also known as a networked object or netObj.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm aware it's not required, I was just showcasing a use case scenario, for interiors (like GTA:O apartments)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to provide an efficient scenario, with interior instancing for people wanting to use the general population (which to my knowledge, is not supported by routing bucket?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I still don't think it's a good idea to put undefined functions in the documentation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very true, but it's very hard to provide an example without some kind of pseudo code


if instanceId == nil then
-- General population: hide players in any instance
if playerInstance ~= nil then
NetworkConcealPlayer(player, true, false)
else
NetworkConcealPlayer(player, false, false)
end
else
-- Instance players: hide players not in the same instance
if playerInstance ~= instanceId then
NetworkConcealPlayer(player, true, false)
else
NetworkConcealPlayer(player, false, false)
end
end
end
end
```
Loading