> ## Documentation Index
> Fetch the complete documentation index at: https://ugcore.urging.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# UgLib.Npc

> Standing peds, such as shop clerks, that exist only near the player.

Client Runs in your resource.

```lua theme={"dark"}
UgLib.Npc.Create(options) -> npc
UgLib.Npc.Remove(npcOrId) -> boolean
UgLib.Npc.GetPed(npcOrId) -> integer?
UgLib.Npc.Clear() -> count
```

**options.model** `string | integer` *required*

Model name or hash.

**options.coords** `vector4` *required*

Position and heading. The feet stand at `z - 1`, so use the coords of a player standing there.

**options.distance** `number` (default: 50)

The ped spawns within this distance and is deleted beyond it. At most 500.

**options.animation** `table`

`{ dict, name, flag? }` or `{ scenario }`.

**options.invincible** `boolean` (default: true)

**options.frozen** `boolean` (default: true)

**options.onSpawn** `fun(npc)`

Runs after the ped exists. `npc.ped` is its handle.

**options.onDespawn** `fun(npc)`

Runs before the ped is deleted.

**options.data** `any`

Kept on `npc.data`.

* Peds are local to the player: other players see their own copy.
* They ignore events and never ragdoll, so shots and cars do not move them.
* `GetPed` returns nil while the player is too far away. Do not keep the handle.
* Your NPCs are deleted when your resource stops.

## Example

```lua client.lua theme={"dark"}
local clerk = UgLib.Npc.Create({
    model = 's_f_y_shop_mid',
    coords = vector4(73.9, -1392.9, 29.4, 270.0),
    distance = 40.0,
    animation = { scenario = 'WORLD_HUMAN_STAND_IMPATIENT' },
    onSpawn = function(npc)
        print('clerk spawned', npc.ped)
    end,
})

-- Later
UgLib.Npc.Remove(clerk)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.