---
title: "UseGangZoneCheck | open.mp"
description: "启用当玩家进入/离开该区域时的回调触发"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/UseGangZoneCheck
language: zh-CN
---

# UseGangZoneCheck

注意

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

## 描述

启用当玩家进入/离开指定帮派区域时的回调触发功能。

| 参数 | 说明 |
| --- | --- |
| zoneid | 需要启用区域检测的帮派区域 ID |
| bool:enable | 是否启用区域检测功能（`true`启用/`false`停用） |

## 返回值

**1:** 函数执行成功

**0:** 函数执行失败（指定的帮派区域不存在）

## 示例

```c
new gGangZoneID = INVALID_GANG_ZONE;

public OnGameModeInit()
{
    gGangZoneID = GangZoneCreate(1248.011, 2072.804, 1439.348, 2204.319);

    // 启用该区域的进出检测回调
    UseGangZoneCheck(gGangZoneID, true);
}

public OnPlayerEnterGangZone(playerid, zoneid)
{
    if (zoneid == gGangZoneID)
    {
        new string[64];
        format(string, sizeof(string), "你正在进入帮派区域 %i", zoneid);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
    }
    return 1;
}

public OnPlayerLeaveGangZone(playerid, zoneid)
{
    if (zoneid == gGangZoneID)
    {
        new string[64];
        format(string, sizeof(string), "你正在离开帮派区域 %i", zoneid);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
    }
    return 1;
}
```

## 相关回调

以下回调函数与本文档功能相关：

-   [OnPlayerEnterGangZone](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnPlayerEnterGangZone): 当玩家进入帮派区域时触发
-   [OnPlayerLeaveGangZone](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnPlayerLeaveGangZone): 当玩家离开帮派区域时触发

## 相关函数

以下函数与本文档功能相关：

-   [GangZoneCreate](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneCreate): 创建帮派区域
-   [GangZoneDestroy](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneDestroy): 销毁帮派区域
-   [GangZoneShowForPlayer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneShowForPlayer): 为玩家显示帮派区域
-   [GangZoneShowForAll](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneShowForAll): 全体显示帮派区域
-   [GangZoneHideForPlayer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneHideForPlayer): 对玩家隐藏帮派区域
-   [GangZoneHideForAll](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneHideForAll): 全体隐藏帮派区域
-   [GangZoneFlashForPlayer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneFlashForPlayer): 为玩家闪烁显示区域
-   [GangZoneFlashForAll](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneFlashForAll): 全体闪烁显示区域
-   [GangZoneStopFlashForPlayer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneStopFlashForPlayer): 停止玩家区域闪烁
-   [GangZoneStopFlashForAll](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GangZoneStopFlashForAll): 停止全体区域闪烁
-   [IsValidGangZone](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsValidGangZone): 验证帮派区域有效性
-   [IsPlayerInGangZone](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsPlayerInGangZone): 检测玩家是否在区域内
-   [IsGangZoneVisibleForPlayer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsGangZoneVisibleForPlayer): 检测区域对玩家可见性
