---
title: "IsPlayerConnected | open.mp"
description: "Checks if a player is connected (if an ID is taken by a connected player)."
canonical: https://omp.itsneufox.com/th/docs/scripting/functions/IsPlayerConnected
language: th
---

# IsPlayerConnected

## คำอธิบาย

Checks if a player is connected (if an ID is taken by a connected player).

| Name | Description |
| --- | --- |
| playerid | The ID of the player to check. |

## ส่งคืน

0: Player is NOT connected.

1: Player IS connected.

## ตัวอย่าง

```c
KillPlayer(playerid)
{
    if (!IsPlayerConnected(playerid))
    {
        printf("Player ID %i is not connected!", playerid);
    }
    else
    {
        SetPlayerHealth(playerid, 0);
    }
}
```

## บันทึก

เคล็ดลับ

This function can be omitted in a lot of cases. Many other functions already have some sort of connection check built in.

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

-   [IsPlayerAdmin](https://omp.itsneufox.com/th/docs/scripting/functions/IsPlayerAdmin): Checks if a player is logged into RCON.
-   [OnPlayerConnect](https://omp.itsneufox.com/th/docs/scripting/callbacks/OnPlayerConnect): Called when a player connects to the server.
-   [OnPlayerDisconnect](https://omp.itsneufox.com/th/docs/scripting/callbacks/OnPlayerDisconnect): Called when a player leaves the server.
