> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-pt/runtime-da-scene/modulos-de-runtime/restricted-actions.md).

# Ações restritas

O `RestrictedActions` o módulo permite que scenes acessem funcionalidades sensíveis (e, portanto, restritas). Ele está ligado ao [`permissão`](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md#permissions) sistema, que as scenes usam para solicitar o uso de métodos individuais.

```ts
const RestrictedActions = require("~system/RestrictedActions");
```

{% hint style="info" %}
Como implementador do World Explorer, o seu runtime pode não ter aplicação de permissões. Nós **fortemente** desaconselhamos isso, pois coloca os jogadores em perigo.
{% endhint %}

A maior parte da funcionalidade restrita é fornecida por este módulo, mas também há [funções globais](https://github.com/decentraland/docs/tree/main/contributor/globals/README.md).

O módulo contém os seguintes métodos e tipos:

* [`função movePlayerTo`](#movePlayerTo)
* [`função teleportTo`](#teleportTo)
* [`função triggerEmote`](#triggerEmote)
* [`função changeRealm`](#changeRealm)
* [`função openExternalUrl`](#openExternalUrl)
* [`função openNftDialog`](#openNftDialog)
* [`função setCommunicationsAdapter`](#setCommunicationsAdapter)
* [`interface Vector3`](#Vector3)

### Métodos

Cada um dos métodos abaixo está associado a uma [permissão](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md#permissions) que pode ser solicitada no manifesto da scene.

**`movePlayerTo`**

Desloque o jogador para uma nova posição relativa à atual e, opcionalmente, defina o alvo da câmera com [vetores](#Vector3).

Requer a [`ALLOW_TO_MOVE_PLAYER_INSIDE_SCENE`](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md#permissions) permissão.

```ts
interface Request {
  newRelativePosition: Vector3;
  cameraTarget?: Vector3;
}

interface Response {
    // Assim que o jogador tiver se movido para a nova posição, e se o jogador não tiver interrompido o movimento, isso será true.
  success: boolean;
}

function movePlayerTo(Request): Promise<Response>;
```

**`teleportTo`**

Reposicione o jogador em um parcel, opcionalmente em outro realm.

Em vez de exigir uma permissão pré-aprovada, cada chamada para `teleportTo` deve ser aprovada pelo jogador.

```ts
interface Request {
  // O parcel de destino. Omitido: o spawn padrão do realm
  // (só faz sentido juntamente com `realm`).
  worldCoordinates?: Vector2;

  // O realm ao qual o parcel pertence: um nome de world (`foo.dcl.eth`) ou uma URL de realm.
  // Quando definido, o client muda de realm (uma reconexão completa, até mesmo para o realm em que o
  // jogador já estiver) e então aterrissa no parcel lá.
  // Omitido: o parcel está no realm atual do jogador.
  realm?: string;
}

interface Response {}

function teleportTo(Request): Promise<Response>;
```

**`triggerEmote`**

Faça o avatar do jogador exibir uma animação de emote, usando um dos nomes predefinidos.

Requer a [`ALLOW_TO_TRIGGER_AVATAR_EMOTE`](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md#permissions) permissão.

```ts
interface Request {
  predefinedEmote: string;
}

interface Response {}

function triggerEmote(Request): Promise<Response>;
```

**`openExternalUrl`**

Ofereça mostrar um site ao jogador, usando uma UI apropriada (que pode ser outro aplicativo).

Requer a [`OPEN_EXTERNAL_LINK`](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md#permissions) permissão.

```ts
interface Request {
  url: string;
}

interface Response {
  // Se o jogador autorizou a abertura do link.
  success: boolean;
}

function openExternalUrl(Request): Promise<Response>;
```

**`openNftDialog`**

Mostre informações sobre um NFT ao jogador, usando uma UI apropriada.

```ts
interface Request {
  // O URN do NFT.
  urn: string;
}

interface Response {
  // Se o NFT foi localizado com sucesso e referenciado a uma imagem ou vídeo.
  success: boolean;
}

function openNftDialog(Request): Promise<Response>;
```

**`changeRealm`** (deprecated)

Troque o World Explorer para outro servidor de conteúdo, usando sua URL base.

Obsoleto em favor de [`teleportTo`](#teleportTo) com um `realm` (e sem `worldCoordinates` para o spawn padrão do realm). `changeRealm` é resolvido assim que a alteração é aceita, e não quando o novo realm entra no ar, portanto um `teleportTo` emitido logo depois disso é executado no realm anterior.

```ts
interface Request {
  // A URL do novo realm.
  realm: string;

  // Uma mensagem opcional para mostrar aos usuários quando eles tiverem de aprovar a alteração.
  message?: string;
}

interface Response {
  // Se a alteração de realm foi autorizada e bem-sucedida.
  success: boolean;
}

function changeRealm(Request): Promise<Response>;
```

### Tipos

O único tipo adicional usado pelos métodos neste módulo é o `Vector3`.

**`Vector3`**

Contém uma posição 3D relativa ou absoluta.

```ts
interface Vector3 {
  x: number;
  y: number;
  z: number;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/contributor/contributor-pt/runtime-da-scene/modulos-de-runtime/restricted-actions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
