From e1df17079a964c96228bb040128ef9612f78e1cc Mon Sep 17 00:00:00 2001 From: Mikkel Friis Date: Thu, 20 Jun 2024 20:58:55 +0200 Subject: [PATCH 1/3] Update NetworkConcealPlayer.md --- NETWORK/NetworkConcealPlayer.md | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/NETWORK/NetworkConcealPlayer.md b/NETWORK/NetworkConcealPlayer.md index e1661fd10..435753c30 100644 --- a/NETWORK/NetworkConcealPlayer.md +++ b/NETWORK/NetworkConcealPlayer.md @@ -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 + + 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 +``` From 2a44550876744ae923b812a17cd9db34944b56c0 Mon Sep 17 00:00:00 2001 From: ammonia-cfx <38232208+4mmonium@users.noreply.github.com> Date: Mon, 24 Jun 2024 03:24:18 +0300 Subject: [PATCH 2/3] Update NetworkConcealPlayer.md Re-organize code and name third native parameter. --- NETWORK/NetworkConcealPlayer.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/NETWORK/NetworkConcealPlayer.md b/NETWORK/NetworkConcealPlayer.md index 435753c30..ce3b6195d 100644 --- a/NETWORK/NetworkConcealPlayer.md +++ b/NETWORK/NetworkConcealPlayer.md @@ -5,16 +5,11 @@ ns: NETWORK ```c // 0xBBDF066252829606 0x72052DB3 -void NETWORK_CONCEAL_PLAYER(Player player, BOOL toggle, BOOL p2); +void NETWORK_CONCEAL_PLAYER(Player player, BOOL toggle, BOOL bAllowDamagingWhileConcealed); ``` This is what R* uses to hide players in MP interiors. -## Parameters -* **player**: -* **toggle**: -* **p2**: - To manage player visibility with NetworkConcealPlayer, here’s a solid approach: **General Population (players not in any instance):** @@ -27,6 +22,10 @@ To manage player visibility with NetworkConcealPlayer, here’s a solid approach This setup keeps instance players separate from each other while allowing interaction with the general population. +## Parameters +* **player**: +* **toggle**: +* **bAllowDamagingWhileConcealed**: ```lua -- Function to manage player visibility From dd0050f053b6c39ce3283468ad3436d35c655c56 Mon Sep 17 00:00:00 2001 From: Dillon Skaggs Date: Thu, 15 Aug 2024 15:03:00 -0500 Subject: [PATCH 3/3] tweak: define all functions that will be used in the example --- NETWORK/NetworkConcealPlayer.md | 49 ++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/NETWORK/NetworkConcealPlayer.md b/NETWORK/NetworkConcealPlayer.md index ce3b6195d..bb2de07bb 100644 --- a/NETWORK/NetworkConcealPlayer.md +++ b/NETWORK/NetworkConcealPlayer.md @@ -28,28 +28,39 @@ This setup keeps instance players separate from each other while allowing intera * **bAllowDamagingWhileConcealed**: ```lua +function GetPlayerInstance(player) + -- you can replace this with your own data + local playerServerId = GetPlayerServerId(player) + return Player(playerServerId).state.instance_id or 0 +end + +local playerId = PlayerId() -- Function to manage player visibility -function concealPlayers(instanceId) - local allPlayers = GetPlayers() +function concealPlayers() + local allPlayers = GetActivePlayers() + local localPlayerInstance = GetPlayerInstance(playerId) for _, player in ipairs(allPlayers) do - local playerInstance = GetPlayerInstance(player) -- You need to define this function - - 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 + if player == playerId then goto continue end + + local playerInstance = GetPlayerInstance(player) + + if playerInstance == localPlayerInstance then + -- if we're in the same instance then we want to be able to see them + NetworkConcealPlayer(player, false, false) + else + -- they're in a different instance, so hide them + NetworkConcealPlayer(player, true, false) + end + + ::continue:: end end + +CreateThread(function() + while true do + concealPlayers() + Wait(250) + end +end) ```