---
title: "IsObjectMaterialSlotUsed | open.mp"
description: "检查物体材质槽位是否被使用"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsObjectMaterialSlotUsed
language: zh-CN
---

# IsObjectMaterialSlotUsed

注意

这个函数是在omp v1.1.0.2612中添加的，在以前的版本中不起作用！

## 描述

检测物体指定材质槽位的使用类型。

| 参数 | 说明 |
| --- | --- |
| objectid | 物体 ID |
| materialIndex | 材质槽位索引（0-15） |

## 返回值

返回材质槽位使用类型：

`0` - 未使用 `1` - 材质贴图 `2` - 文本贴图

## 示例

```c
// 创建物体并设置标准材质
new objectid = CreateObject(19371, 978.71143, -925.25708, 42.63720, 0.0, 0.0, 2.0);
SetObjectMaterial(objectid, 0, 19341, "egg_texts", "easter_egg01", 0xFFFFFFFF);

new type = IsObjectMaterialSlotUsed(objectid, 0); // 返回1
```

```c
// 创建物体并设置文本材质
new objectid = CreateObject(19174, 986.42767, -983.14850, 40.95220, 0.0, 0.0, 186.0);
SetObjectMaterialText(objectid, "OPEN.MP", 0, OBJECT_MATERIAL_SIZE_256x128, "Arial", 38, true, 0xFF0000FF, 0x00000000, OBJECT_MATERIAL_TEXT_ALIGN_LEFT);

new type = IsObjectMaterialSlotUsed(objectid, 0); // 返回2
```

## 相关函数

-   [SetObjectMaterial](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetObjectMaterial): 为物体设置游戏内建材质
-   [SetObjectMaterialText](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetObjectMaterialText): 为物体设置文本材质
-   [GetObjectMaterial](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetObjectMaterial): 获取物体材质数据
-   [GetObjectMaterialText](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetObjectMaterialText): 获取物体文本材质数据
-   [IsPlayerObjectMaterialSlotUsed](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsPlayerObjectMaterialSlotUsed): 检查玩家物体材质槽位使用状态
