---
title: "TogglePlayerClock | open.mp"
description: "切换指定玩家的游戏内时钟显示（位于右上角）。"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/TogglePlayerClock
language: zh-CN
---

# TogglePlayerClock

## 描述

切换指定玩家的游戏内时钟显示（位于右上角）。启用后，游戏时间将以每分钟对应现实一秒的速度推进。使用[SetWeather](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetWeather)/[SetPlayerWeather](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetPlayerWeather)设置天气时，天气效果将呈现渐变过渡。

| 参数 | 说明 |
| --- | --- |
| playerid | 需要启用/禁用时钟的玩家 ID |
| bool:toggle | 显示时钟设为'true'，隐藏设为'false'（默认隐藏） |

## 返回值

**true** - 函数执行成功

**false** - 函数执行失败（指定玩家不存在）

## 示例

```c
public OnPlayerConnect(playerid)
{
    TogglePlayerClock(playerid, true); // 显示时钟
    return 1;
}
```

## 注意事项

备注

-   玩家时间不会自动同步！需使用[SetPlayerTime](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetPlayerTime)实现时间同步
-   玩家死亡时，时间将自动推进 6 小时

## 相关函数

-   [GetPlayerTime](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetPlayerTime): 获取玩家的当前时间
-   [SetPlayerTime](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetPlayerTime): 设置玩家的个性化时间
-   [SetWorldTime](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetWorldTime): 设置服务器全局世界时间
