OneSync instance problem

when onesync is activated, people can see each other without inviting each other when they enter the House.

The reason for this is simply because the native does not work properly at the moment you want to add SetEntityVisble(entity, bool, 0)
wherever you want them to be invisible or visible, true for visible false for invisible. Hope this helps.

-- Instance players
Citizen.CreateThread(function()
    while true do

        Citizen.Wait(0)

        if Instance.host ~= nil then

            local playerPed = PlayerPedId()

            for i=0, Config.MaxPlayers, 1 do

                local found = false
                for j=1, #Instance.players, 1 do
                    instancePlayer = GetPlayerFromServerId(Instance.players[j])

                    if i == instancePlayer then
                        found = true
                    end
                end

                if not found then
                    local otherPlayerPed = GetPlayerPed(i)

                    SetEntityLocallyInvisible(otherPlayerPed)
                    SetEntityVisible(otherPlayerPed, false, 0)
                    SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
                end

            end

        else

            local playerPed = PlayerPedId()

            for i=0, Config.MaxPlayers, 1 do

                local found = false
                for j=1, #InstancedPlayers, 1 do
                    instancePlayer = GetPlayerFromServerId(InstancedPlayers[j])

                    if i == instancePlayer then
                        found = true
                    end
                end

                if found then
                    local otherPlayerPed = GetPlayerPed(i)

                    SetEntityLocallyInvisible(otherPlayerPed)
                    SetEntityVisible(otherPlayerPed, true, 0)
                    SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
                end

            end

        end

    end
end)
3 Likes