# Events

## Server Events

### `Nova:PlayerLoaded`

Fired when a player's character data is fully loaded.

```lua
AddEventHandler('Nova:PlayerLoaded', function(source, player)
    print(player.fullname .. ' (Source: ' .. source .. ') has loaded')
    print('Job: ' .. player:GetJob().label)
    print('Money: $' .. player:GetMoney())
end)
```

| Parameter | Type         | Description        |
| --------- | ------------ | ------------------ |
| `source`  | `number`     | Player's server ID |
| `player`  | `NovaPlayer` | Full player object |

***

### `Nova:PlayerDropped`

Fired when a player disconnects (after data is saved).

```lua
AddEventHandler('Nova:PlayerDropped', function(source, player, reason)
    print(player.fullname .. ' disconnected: ' .. reason)
end)
```

| Parameter | Type         | Description                           |
| --------- | ------------ | ------------------------------------- |
| `source`  | `number`     | Player's server ID                    |
| `player`  | `NovaPlayer` | Player object (data still accessible) |
| `reason`  | `string`     | Disconnect reason                     |

***

### `Nova:Ready`

Fired when the framework has fully initialized (all modules loaded).

```lua
AddEventHandler('Nova:Ready', function()
    print('NOVA Framework is ready!')
end)
```

***

### `Nova:PlayerMoneyChange`

Fired when a player's cash amount changes.

```lua
AddEventHandler('Nova:PlayerMoneyChange', function(source, player, oldAmount, newAmount, reason)
    print(player.fullname .. ': $' .. oldAmount .. ' -> $' .. newAmount)
end)
```

***

### `Nova:PlayerJobChange`

Fired when a player's job changes.

```lua
AddEventHandler('Nova:PlayerJobChange', function(source, player, oldJob, newJob)
    print(player.fullname .. ': ' .. oldJob.name .. ' -> ' .. newJob.name)
end)
```

***

## Client Events

### `Nova:PlayerLoaded`

Fired on the client when the local player's data is loaded.

```lua
AddEventHandler('Nova:PlayerLoaded', function(playerData)
    print('My character: ' .. playerData.fullname)
    print('My job: ' .. playerData.job)
end)
```

| Parameter    | Type    | Description       |
| ------------ | ------- | ----------------- |
| `playerData` | `table` | Player data table |

***

## Custom Events

When creating your own scripts, follow the naming convention:

```lua
-- Server
TriggerClientEvent('nova_myscript:eventName', source, data)

-- Client
RegisterNetEvent('nova_myscript:eventName')
AddEventHandler('nova_myscript:eventName', function(data)
    -- handle event
end)
```
