---
title: "IsValidServerRule | open.mp"
description: "检测服务器规则有效性"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsValidServerRule
language: zh-CN
---

# IsValidServerRule

注意

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

## 描述

检测指定服务器规则是否有效。

| 参数 | 说明 |
| --- | --- |
| const rule\[\] | 待检测的服务器规则名称 |

## 返回值

当服务器规则有效时返回 **true**，否则返回 **false**

## 示例代码

```c
if (IsValidServerRule("version"))
{
    // 服务器规则有效
}
else
{
    // 服务器规则无效
}
```

## 相关函数

-   [AddServerRule](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/AddServerRule): 添加服务器规则
-   [RemoveServerRule](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/RemoveServerRule): 移除服务器规则
