---
title: "GetPlayerFacingAngle | open.mp"
description: "获取玩家当前朝向角度"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetPlayerFacingAngle
language: zh-CN
---

# GetPlayerFacingAngle

## 描述

获取玩家当前面朝方向的水平旋转角度

| 参数 | 说明 |
| --- | --- |
| playerid | 需要获取角度的玩家 ID |
| &Float:angle | 存储角度的浮点变量（通过引用传递） |

## 返回值

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

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

玩家当前角度将存储在指定变量中

## 示例代码

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/angle", true))
    {
        new string[64];
        new Float:angle;

        GetPlayerFacingAngle(playerid, angle);
        format(string, sizeof(string), "当前朝向角度: %0.2f", angle);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
        return 1;
    }
    return 0;
}
```

## 注意事项

备注

当玩家处于车辆内时，此函数返回的角度通常不准确。建议使用[GetVehicleZAngle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleZAngle)获取车辆 Z 轴旋转角度

注意

GTA:SA 中的角度方向与现实相反：90 度实际指向西方（现实为东方）。角度转换公式为：360 - 角度值。北/南方向仍对应 0/360 度和 180 度

## 相关函数

-   [GetVehicleZAngle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleZAngle): 获取车辆 Z 轴旋转角度
-   [SetPlayerFacingAngle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetPlayerFacingAngle): 设置玩家朝向角度
-   [GetPlayerRotationQuat](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetPlayerRotationQuat): 获取玩家的四元数旋转参数
