---
title: "OnPlayerRequestSpawn | open.mp"
description: "Called when a player attempts to spawn via class selection either by pressing SHIFT or clicking the 'Spawn' button."
canonical: https://omp.itsneufox.com/th/docs/scripting/callbacks/OnPlayerRequestSpawn
language: th
---

# OnPlayerRequestSpawn

## คำอธิบาย

Called when a player attempts to spawn via class selection either by pressing SHIFT or clicking the 'Spawn' button.

| Name | Description |
| --- | --- |
| playerid | The ID of the player that requested to spawn. |

## ส่งคืน

Returning 0 in this callback will prevent the player from spawning.

It is always called first in filterscripts so returning 0 there also blocks other scripts from seeing it.

## ตัวอย่าง

```c
public OnPlayerRequestSpawn(playerid)
{
    if (!IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid, -1, "You may not spawn.");
        return 0;
    }
    return 1;
}
```

## บันทึก

หมายเหตุ

NPC สามารถเรียก Callback นี้ได้

เคล็ดลับ

To prevent players from spawning with certain classes, the last viewed class must be saved in a variable in OnPlayerRequestClass.

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