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

Merged
merged 3 commits into from
Aug 15, 2024
Merged

Conversation

dotmbf
Copy link
Contributor

@dotmbf dotmbf commented Jun 20, 2024

Added more defined example and explanation of use in the native.

Copy link
Contributor

@4mmonium 4mmonium left a 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!

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

Copy link
Collaborator

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.

Copy link
Contributor Author

@dotmbf dotmbf Aug 2, 2024

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.
local allPlayers = GetPlayers()

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

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.

@AvarianKnight AvarianKnight added the needs validation This looks good, but needs additional confirmation of suggested change. label Aug 7, 2024
@AvarianKnight AvarianKnight merged commit af6f47e into citizenfx:master Aug 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs validation This looks good, but needs additional confirmation of suggested change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants