-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, requested some changes, thanks!
NETWORK/NetworkConcealPlayer.md
Outdated
local allPlayers = GetPlayers() | ||
|
||
for _, player in ipairs(allPlayers) do | ||
local playerInstance = GetPlayerInstance(player) -- You need to define this function |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use a state bag in this case, or define the function with a hard coded instance id and let the end user know this is where they should add how they do their instances
Something like this might also work
function GetPlayerInstance(player)
local playerServerId = GetPlayerServerId(player)
return Player(playerServerId).state.instance_id or 0
end
You also don't need the extra if/else branch, you can just check if the instance ids match and if they don't just conceal them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else was added in case that people left the other "instance" they would have to be removed from the NET_CONCEAL filter in R*
State bags are also correct, yes, I just wrote what I assumed to be the best example for a simple use-case scenario
Re-organize code and name third native parameter.
NETWORK/NetworkConcealPlayer.md
Outdated
local allPlayers = GetPlayers() | ||
|
||
for _, player in ipairs(allPlayers) do | ||
local playerInstance = GetPlayerInstance(player) -- You need to define this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use a state bag in this case, or define the function with a hard coded instance id and let the end user know this is where they should add how they do their instances
Something like this might also work
function GetPlayerInstance(player)
local playerServerId = GetPlayerServerId(player)
return Player(playerServerId).state.instance_id or 0
end
You also don't need the extra if/else branch, you can just check if the instance ids match and if they don't just conceal them.
Added more defined example and explanation of use in the native.