# Server Functions

Server functions are available through `Nova.Functions` inside nova\_core, or via exports from any script.

## Player Management

### `Nova.Functions.GetPlayer(source)`

Gets a player object by their server ID.

```lua
local player = Nova.Functions.GetPlayer(source)
if player then
    print(player.fullname)
end
```

| Parameter | Type     | Description        |
| --------- | -------- | ------------------ |
| `source`  | `number` | Player's server ID |

**Returns:** `NovaPlayer` object or `nil`

***

### `Nova.Functions.GetPlayerByIdentifier(identifier)`

Gets a player object by their unique identifier.

```lua
local player = Nova.Functions.GetPlayerByIdentifier('license:abc123def456')
```

| Parameter    | Type     | Description                 |
| ------------ | -------- | --------------------------- |
| `identifier` | `string` | Player's license identifier |

**Returns:** `NovaPlayer` object or `nil`

***

### `Nova.Functions.GetPlayers()`

Gets all currently online player objects.

```lua
local players = Nova.Functions.GetPlayers()
for _, player in pairs(players) do
    print(player.fullname .. ' - Source: ' .. player.source)
end
```

**Returns:** `table` of `NovaPlayer` objects

***

## Communication

### `Nova.Functions.Notify(source, message, type)`

Sends a notification to a player (requires nova\_notify).

```lua
Nova.Functions.Notify(source, 'Item purchased!', 'success')
Nova.Functions.Notify(source, 'Not enough money', 'error')
Nova.Functions.Notify(source, 'Server restarting in 5 minutes', 'info')
```

| Parameter | Type     | Description                                   |
| --------- | -------- | --------------------------------------------- |
| `source`  | `number` | Player's server ID                            |
| `message` | `string` | Notification text                             |
| `type`    | `string` | `'success'`, `'error'`, `'info'`, `'warning'` |

***

### `Nova.Functions.CreateCallback(name, handler)`

Registers a server callback that clients can trigger.

```lua
Nova.Functions.CreateCallback('myScript:getData', function(source, cb, arg1, arg2)
    local player = Nova.Functions.GetPlayer(source)
    cb({
        name = player.fullname,
        value = arg1 + arg2,
    })
end)
```

| Parameter | Type       | Description                          |
| --------- | ---------- | ------------------------------------ |
| `name`    | `string`   | Unique callback name                 |
| `handler` | `function` | Handler function `(source, cb, ...)` |

The handler receives:

* `source` - Player's server ID
* `cb` - Callback function to send response
* `...` - Additional arguments from client

***

## Exports (from other scripts)

```lua
-- All Nova.Functions are also available via exports:
local player = exports['nova_core']:GetPlayer(source)
local players = exports['nova_core']:GetPlayers()
local config = exports['nova_core']:GetConfig()
```
