Skip to content

Commit

Permalink
tweak: define all functions that will be used in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
AvarianKnight authored Aug 15, 2024
1 parent 2a44550 commit dd0050f
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions NETWORK/NetworkConcealPlayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

0 comments on commit dd0050f

Please sign in to comment.