# Player Object

The `NovaPlayer` object represents a connected player and provides methods to manage their data.

## Getting a Player

```lua
-- Server-side
local player = Nova.Functions.GetPlayer(source)
-- or
local player = exports['nova_core']:GetPlayer(source)
```

## Properties

| Property      | Type     | Description               |
| ------------- | -------- | ------------------------- |
| `source`      | `number` | FiveM server ID           |
| `identifier`  | `string` | Unique license identifier |
| `charId`      | `number` | Character ID in database  |
| `name`        | `string` | First name                |
| `lastname`    | `string` | Last name                 |
| `fullname`    | `string` | First + Last name         |
| `dob`         | `string` | Date of birth             |
| `nationality` | `string` | Nationality               |
| `gender`      | `number` | 0 = male, 1 = female      |
| `money`       | `number` | Cash on hand              |
| `bank`        | `number` | Bank balance              |
| `job`         | `string` | Job name                  |
| `jobGrade`    | `number` | Job grade level           |
| `jobLabel`    | `string` | Job display name          |
| `group`       | `string` | Admin group               |

## Methods

### Economy

#### `player:GetMoney()`

Returns the player's cash amount.

```lua
local cash = player:GetMoney()  -- Returns: number
```

#### `player:GetBank()`

Returns the player's bank balance.

```lua
local bank = player:GetBank()  -- Returns: number
```

#### `player:AddMoney(amount)`

Adds cash to the player.

```lua
player:AddMoney(500)
```

| Parameter | Type     | Description   |
| --------- | -------- | ------------- |
| `amount`  | `number` | Amount to add |

#### `player:RemoveMoney(amount)`

Removes cash from the player. Returns `false` if insufficient funds.

```lua
local success = player:RemoveMoney(200)
```

#### `player:AddBank(amount)`

Adds money to the player's bank account.

```lua
player:AddBank(1000)
```

#### `player:RemoveBank(amount)`

Removes money from the player's bank account.

```lua
local success = player:RemoveBank(500)
```

#### `player:SetMoney(amount)`

Sets the player's cash to an exact amount.

```lua
player:SetMoney(5000)
```

#### `player:SetBank(amount)`

Sets the player's bank balance to an exact amount.

```lua
player:SetBank(10000)
```

### Inventory

#### `player:GetInventory()`

Returns the player's full inventory table.

```lua
local inv = player:GetInventory()
-- Returns: { {name='bread', count=5, label='Bread', ...}, ... }
```

#### `player:AddItem(name, count)`

Adds items to the player's inventory.

```lua
player:AddItem('bread', 5)
```

| Parameter | Type     | Description           |
| --------- | -------- | --------------------- |
| `name`    | `string` | Item name from config |
| `count`   | `number` | Amount to add         |

#### `player:RemoveItem(name, count)`

Removes items from the player's inventory.

```lua
player:RemoveItem('bread', 2)
```

#### `player:HasItem(name, returnCount)`

Checks if the player has an item. Returns boolean or count.

```lua
local has = player:HasItem('bread')        -- Returns: true/false
local count = player:HasItem('bread', true) -- Returns: number
```

#### `player:GetItem(name)`

Gets a specific item's data from inventory.

```lua
local item = player:GetItem('bread')
-- Returns: { name='bread', count=5, label='Bread', weight=200 }
```

### Job

#### `player:GetJob()`

Returns the player's job information.

```lua
local job = player:GetJob()
-- Returns: { name='police', grade=2, label='Police', gradeLabel='Sergeant' }
```

#### `player:SetJob(name, grade)`

Sets the player's job.

```lua
player:SetJob('police', 2)
```

| Parameter | Type     | Description          |
| --------- | -------- | -------------------- |
| `name`    | `string` | Job name from config |
| `grade`   | `number` | Job grade level      |

### Groups & Permissions

#### `player:GetGroup()`

Returns the player's admin group.

```lua
local group = player:GetGroup()  -- Returns: 'admin', 'user', etc.
```

#### `player:SetGroup(group)`

Sets the player's admin group.

```lua
player:SetGroup('admin')
```

#### `player:HasPermission(node)`

Checks if the player has a specific permission. Uses O(1) cached lookup.

```lua
local can = player:HasPermission('admin.kick')  -- Returns: true/false
```

### Status

#### `player:GetHunger()`

Returns hunger level (0-100).

#### `player:GetThirst()`

Returns thirst level (0-100).

#### `player:SetHunger(value)`

Sets hunger level.

```lua
player:SetHunger(100)
```

#### `player:SetThirst(value)`

Sets thirst level.

```lua
player:SetThirst(100)
```

### Persistence

#### `player:Save()`

Saves all player data to the database immediately.

```lua
player:Save()
```

::: info Player data is automatically saved every `Config.AutoSaveInterval` seconds and on disconnect. :::
