---
title: "ConnectNPC | open.mp"
description: "Connect an NPC to the server."
canonical: https://omp.itsneufox.com/th/docs/scripting/functions/ConnectNPC
language: th
---

# ConnectNPC

## คำอธิบาย

Connect an NPC to the server.

| Name | Description |
| --- | --- |
| name\[\] | The name the NPC should connect as. Must follow the same rules as normal player names. |
| script\[\] | The NPC script name that is located in the npcmodes folder (without the .amx extension). |

## ส่งคืน

This function always return 1.

## ตัวอย่าง

```c
public OnGameModeInit()
{
    ConnectNPC("[BOT]Pilot", "pilot");
    return 1;
}
```

## บันทึก

หมายเหตุ

NPCs do not have nametags. These can be scripted with Attach3DTextLabelToPlayer.

## ฟังก์ชั่นที่เกี่ยวข้องกัน

-   [IsPlayerNPC](https://omp.itsneufox.com/th/docs/scripting/functions/IsPlayerNPC): Check if a player is an NPC or an actual player.
-   [OnPlayerConnect](https://omp.itsneufox.com/th/docs/scripting/callbacks/OnPlayerConnect): Called when a player connects to the server.
