> 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-zh/chang-jing-yun-xing-shi/yun-xing-shi-mo-kuai/restricted-actions.md).

# 受限操作

该 `RestrictedActions` 该模块允许场景访问敏感（因此受限）的功能。它与 [`权限`](https://github.com/decentraland/docs/blob/main/contributor/content/entity-types/scenes/README.md#permissions) 系统相关，场景通过它来请求使用单个方法。

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

{% hint style="info" %}
作为 World Explorer 的实现者，你的运行时可能不强制执行权限。我们 **强烈** 不建议这样做，因为这会让玩家处于危险之中。
{% endhint %}

大部分受限功能由此模块提供，但也有受限的 [全局函数](https://github.com/decentraland/docs/blob/main/contributor/globals/README.md).

该模块包含以下方法和类型：

* [`函数 movePlayerTo`](#movePlayerTo)
* [`函数 teleportTo`](#teleportTo)
* [`函数 triggerEmote`](#triggerEmote)
* [`函数 changeRealm`](#changeRealm)
* [`函数 openExternalUrl`](#openExternalUrl)
* [`函数 openNftDialog`](#openNftDialog)
* [`函数 setCommunicationsAdapter`](#setCommunicationsAdapter)
* [`接口 Vector3`](#Vector3)

### 方法

下面的每个方法都与一个特定的 [权限](https://github.com/decentraland/docs/blob/main/contributor/content/entity-types/scenes/README.md#permissions) 相关，该权限可在场景清单中请求。

**`movePlayerTo`**

将玩家移动到相对于当前位置的新位置，并可选择使用 [向量](#Vector3).

需要 [`ALLOW_TO_MOVE_PLAYER_INSIDE_SCENE`](https://github.com/decentraland/docs/blob/main/contributor/content/entity-types/scenes/README.md#permissions) 权限。

```ts
接口 Request {
  newRelativePosition: Vector3;
  cameraTarget?: Vector3;
}

interface Response {
    // 一旦玩家移动到新位置，并且如果玩家没有中断移动，这将为 true。
  success: boolean;
}

函数 movePlayerTo(Request): Promise<Response>;
```

**`teleportTo`**

将玩家重新定位到由给定的绝对世界位置 [向量](#Vector3).

不是要求预先批准的权限，而是对 `teleportTo` 的每次调用都必须由玩家批准。

```ts
接口 Request {
  worldPosition: Vector3;
}

接口 Response {}

函数 teleportTo(Request): Promise<Response>;
```

**`triggerEmote`**

让玩家的头像显示一个表情动作动画，使用预定义名称之一。

需要 [`ALLOW_TO_TRIGGER_AVATAR_EMOTE`](https://github.com/decentraland/docs/blob/main/contributor/content/entity-types/scenes/README.md#permissions) 权限。

```ts
接口 Request {
  predefinedEmote: string;
}

接口 Response {}

函数 triggerEmote(Request): Promise<Response>;
```

**`openExternalUrl`**

使用适当的界面（可能是另一个应用程序）向玩家提供显示网站的选项。

需要 [`OPEN_EXTERNAL_LINK`](https://github.com/decentraland/docs/blob/main/contributor/content/entity-types/scenes/README.md#permissions) 权限。

```ts
接口 Request {
  url: string;
}

interface Response {
  // 玩家是否授权打开链接。
  success: boolean;
}

函数 openExternalUrl(Request): Promise<Response>;
```

**`openNftDialog`**

使用适当的界面向玩家显示有关 NFT 的信息。

```ts
接口 Request {
  // NFT 的 URN。
  urn: string;
}

interface Response {
  // NFT 是否已成功定位并指向一张图片或一段视频。
  success: boolean;
}

函数 openNftDialog(Request): Promise<Response>;
```

**`changeRealm`**

使用其基础 URL 将 World Explorer 切换到另一个内容服务器。

```ts
接口 Request {
  // 新领域的 URL。
  realm: string;

  // 当用户需要批准更改时显示给他们的可选消息。
  message?: string;
}

interface Response {
  // 领域更改是否已获授权并成功。
  success: boolean;
}

函数 changeRealm(Request): Promise<Response>;
```

### 类型

此模块中的方法所使用的唯一附加类型是 `Vector3`.

**`Vector3`**

表示相对或绝对的 3D 位置。

```ts
接口 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-zh/chang-jing-yun-xing-shi/yun-xing-shi-mo-kuai/restricted-actions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
