---
title: "GetPlayerAnimationIndex | open.mp"
description: "获取玩家当前播放的动画索引"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetPlayerAnimationIndex
language: zh-CN
---

# GetPlayerAnimationIndex

## 描述

获取玩家当前正在应用的动画索引编号。

| 参数 | 说明 |
| --- | --- |
| playerid | 需要获取动画索引的玩家 ID |

## 返回值

返回动画库中的索引编号，当没有应用动画时返回 0。

## 示例代码

```c
public OnPlayerUpdate(playerid)
{
    if (GetPlayerAnimationIndex(playerid))
    {
        new
            animationLibrary[32],
            animationName[32],
            string[128];

        GetAnimationName(GetPlayerAnimationIndex(playerid), animationLibrary, sizeof(animationLibrary), animationName, sizeof(animationName));

        format(string, sizeof(string), "正在播放动画：%s 库中的 %s", animationLibrary, animationName);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
    }
    return 1;
}
```

## 注意事项

技巧

动画索引对应 SA-MP 内置动画库的编号，可通过[GetAnimationName](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetAnimationName)获取具体动画名称

## 相关函数

-   [ApplyAnimation](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/ApplyAnimation): 为玩家应用指定动画
-   [GetAnimationName](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetAnimationName): 通过索引获取动画库及动画名称
