|
| 1 | +import AutoStarlightPage from '@src/components/AutoStarlightPage.astro'; |
| 2 | +import { Code } from '@astrojs/starlight/components'; |
| 3 | +import { getSeeAlsoLinksFromList } from '@src/utils/general'; |
| 4 | +import SeeAlsoSection from '@src/components/SeeAlsoSection.astro'; |
| 5 | + |
| 6 | +<AutoStarlightPage frontmatter={{ |
| 7 | + template: 'doc', |
| 8 | + title: 'Visibility', |
| 9 | + tableOfContents: false |
| 10 | +}}> |
| 11 | + |
| 12 | +The visibility system for [markers](/reference/marker), [blips](/reference/blip) and [radar-areas](/reference/radararea) works by the following rule: |
| 13 | +- **if something is visible to a certain [element](/reference/element), it is also visible to all of that element's children. Also, everything is visible to the root element by default.** |
| 14 | + |
| 15 | +This means that if you want to make e.g. a blip only visible for a few specific players, you need to do two things: |
| 16 | +- Make the blip invisible to the [root](/reference/root) element, using [setElementVisibleTo](/reference/setElementVisibleTo). The blip is now hidden for all players. |
| 17 | +- Make the blip visible again for the desired players. |
| 18 | + |
| 19 | +The same things go for markers. |
| 20 | + |
| 21 | +If you only want something to be visible to certain players the most efficient and least buggy thing to do is to when creating the element instead of the default visibility of [root](/reference/root), set it to [resourceRoot](/reference/resourceRoot) (no player will see it as no player is a child of resourceRoot) and then use [setElementVisibleTo](/reference/setElementVisibleTo) on specific players. Otherwise there is a chance that players will see the blip for a fraction of a second, as the blip is created but then destroyed right after. |
| 22 | + |
| 23 | +This is bad (chance of being seen on minimap for about 50ms): |
| 24 | +<Code lang="lua" code="a = createBlip(0, 0, 0, 41) |
| 25 | +setElementVisibleTo(a, root, false) |
| 26 | +setElementVisibleTo(a, somePlayer, true)" /> |
| 27 | + |
| 28 | +This is good: |
| 29 | + |
| 30 | +<Code lang="lua" code="a = createBlip(0, 0, 0, 41, 1, 2, 3, 4, 5, 6, 9999, resourceRoot) |
| 31 | +setElementVisibleTo(a, somePlayer, true)" /> |
| 32 | + |
| 33 | +<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksFromList([ |
| 34 | + 'reference:Predefined_variables', |
| 35 | + 'reference:Element_tree', |
| 36 | +])} currentId='' /> |
| 37 | + |
| 38 | +</AutoStarlightPage> |
0 commit comments